2014-08-09 06:18:38 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2015-05-19 02:22:48 +02:00
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
2016-03-01 00:09:49 +01:00
|
|
|
Date: Tue, 1 Mar 2016 14:47:52 -0600
|
2014-08-09 06:18:38 +02:00
|
|
|
Subject: [PATCH] Player affects spawning API
|
|
|
|
|
|
|
|
|
2020-08-25 04:22:08 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
|
|
@@ -0,0 +0,0 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, Ke
|
|
|
|
return MathHelper.c(f * f + f1 * f1 + f2 * f2);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ public double getDistanceSquared(double x, double y, double z) { return h(x, y, z); } // Paper - OBFHELPER
|
|
|
|
public double h(double d0, double d1, double d2) {
|
|
|
|
double d3 = this.locX() - d0;
|
|
|
|
double d4 = this.locY() - d1;
|
2014-08-09 06:18:38 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2014-08-09 06:18:38 +02:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
2014-11-28 02:17:45 +01:00
|
|
|
@@ -0,0 +0,0 @@ public abstract class EntityHuman extends EntityLiving {
|
2020-08-25 04:22:08 +02:00
|
|
|
private final ItemCooldown bM;
|
2016-11-17 03:23:38 +01:00
|
|
|
@Nullable
|
2014-11-28 02:17:45 +01:00
|
|
|
public EntityFishingHook hookedFish;
|
2018-07-15 03:53:17 +02:00
|
|
|
+ // Paper start
|
2016-11-19 01:55:14 +01:00
|
|
|
+ public boolean affectsSpawning = true;
|
2018-07-15 03:53:17 +02:00
|
|
|
+ // Paper end
|
2015-03-08 02:16:09 +01:00
|
|
|
|
2014-11-28 02:17:45 +01:00
|
|
|
// CraftBukkit start
|
|
|
|
public boolean fauxSleeping;
|
2016-11-19 01:55:14 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2016-11-19 01:55:14 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
|
|
@@ -0,0 +0,0 @@ public abstract class EntityInsentient extends EntityLiving {
|
2020-06-25 11:27:25 +02:00
|
|
|
if (this.world.getDifficulty() == EnumDifficulty.PEACEFUL && this.L()) {
|
|
|
|
this.die();
|
|
|
|
} else if (!this.isPersistent() && !this.isSpecialPersistence()) {
|
|
|
|
- EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
|
|
|
|
+ EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D, IEntitySelector.affectsSpawning); // Paper
|
2016-11-17 03:23:38 +01:00
|
|
|
|
2020-06-25 11:27:25 +02:00
|
|
|
if (entityhuman != null) {
|
|
|
|
double d0 = entityhuman.h((Entity) this); // CraftBukkit - decompile error
|
2016-11-19 01:55:14 +01:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2016-11-19 01:55:14 +01:00
|
|
|
--- a/src/main/java/net/minecraft/server/EntitySilverfish.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/EntitySilverfish.java
|
|
|
|
@@ -0,0 +0,0 @@ public class EntitySilverfish extends EntityMonster {
|
2020-08-25 04:22:08 +02:00
|
|
|
if (c(entitytypes, generatoraccess, enummobspawn, blockposition, random)) {
|
2019-07-20 06:01:24 +02:00
|
|
|
EntityHuman entityhuman = generatoraccess.a((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0D, true);
|
2018-07-15 03:53:17 +02:00
|
|
|
|
2016-11-19 01:55:14 +01:00
|
|
|
- return entityhuman == null;
|
|
|
|
+ return !(entityhuman != null && !entityhuman.affectsSpawning) && entityhuman == null; // Paper - Affects Spawning API
|
|
|
|
} else {
|
|
|
|
return false;
|
2016-11-17 03:23:38 +01:00
|
|
|
}
|
2020-06-25 11:27:25 +02:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
|
|
@@ -0,0 +0,0 @@ public interface IEntityAccess {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- @Nullable
|
|
|
|
- default EntityHuman a(double d0, double d1, double d2, double d3, @Nullable Predicate<Entity> predicate) {
|
|
|
|
+ default EntityHuman findNearbyPlayer(Entity entity, double d0, @Nullable Predicate<Entity> predicate) { return this.findNearbyPlayer(entity.locX(), entity.locY(), entity.locZ(), d0, predicate); } // Paper
|
|
|
|
+ @Nullable default EntityHuman findNearbyPlayer(double d0, double d1, double d2, double d3, @Nullable Predicate<Entity> predicate) { return a(d0, d1, d2, d3, predicate); } // Paper - OBFHELPER
|
|
|
|
+ @Nullable default EntityHuman a(double d0, double d1, double d2, double d3, @Nullable Predicate<Entity> predicate) { // Paper
|
|
|
|
double d4 = -1.0D;
|
|
|
|
EntityHuman entityhuman = null;
|
|
|
|
Iterator iterator = this.getPlayers().iterator();
|
|
|
|
@@ -0,0 +0,0 @@ public interface IEntityAccess {
|
|
|
|
return this.a(d0, d1, d2, d3, predicate);
|
|
|
|
}
|
|
|
|
|
|
|
|
+ // Paper end
|
|
|
|
+ default boolean isAffectsSpawningPlayerNearby(double d0, double d1, double d2, double d3) {
|
|
|
|
+ Iterator iterator = this.getPlayers().iterator();
|
|
|
|
+ double d4;
|
|
|
|
+ do {
|
|
|
|
+ EntityHuman entityhuman;
|
|
|
|
+ do {
|
|
|
|
+ if (!iterator.hasNext()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ entityhuman = (EntityHuman) iterator.next();
|
|
|
|
+ } while (!IEntitySelector.affectsSpawning.test(entityhuman));
|
|
|
|
+
|
2020-08-25 04:22:08 +02:00
|
|
|
+ d4 = entityhuman.getDistanceSquared(d0, d1, d2);
|
2020-06-25 11:27:25 +02:00
|
|
|
+ } while (d3 >= 0.0D && d4 >= d3 * d3);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
default boolean isPlayerNearby(double d0, double d1, double d2, double d3) {
|
|
|
|
Iterator iterator = this.getPlayers().iterator();
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
|
|
@@ -0,0 +0,0 @@ public final class IEntitySelector {
|
|
|
|
return !entity.isSpectator();
|
|
|
|
};
|
|
|
|
|
|
|
|
+ // Paper start
|
|
|
|
+ public static final Predicate<Entity> affectsSpawning = (entity) -> {
|
|
|
|
+ return !entity.isSpectator() && entity.isAlive() && (entity instanceof EntityPlayer) && ((EntityPlayer) entity).affectsSpawning;
|
|
|
|
+ };
|
|
|
|
+ // Paper end
|
|
|
|
+
|
|
|
|
public static Predicate<Entity> a(double d0, double d1, double d2, double d3) {
|
|
|
|
double d4 = d3 * d3;
|
|
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
|
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
|
|
@@ -0,0 +0,0 @@ public abstract class MobSpawnerAbstract {
|
|
|
|
private boolean h() {
|
|
|
|
BlockPosition blockposition = this.b();
|
|
|
|
|
|
|
|
- return this.a().isPlayerNearby((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, (double) this.requiredPlayerRange);
|
|
|
|
+ return this.a().isAffectsSpawningPlayerNearby((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, (double) this.requiredPlayerRange); // Paper
|
|
|
|
}
|
|
|
|
|
|
|
|
public void c() {
|
2014-08-09 06:18:38 +02:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2020-05-06 11:48:49 +02:00
|
|
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
2014-08-09 06:18:38 +02:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
2017-05-28 06:25:17 +02:00
|
|
|
@Override
|
|
|
|
public String getLocale() {
|
|
|
|
return getHandle().locale;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
2018-07-15 03:53:17 +02:00
|
|
|
+ // Paper start
|
2016-04-13 22:57:34 +02:00
|
|
|
+ public void setAffectsSpawning(boolean affects) {
|
|
|
|
+ this.getHandle().affectsSpawning = affects;
|
2016-03-01 00:09:49 +01:00
|
|
|
+ }
|
2014-08-09 06:18:38 +02:00
|
|
|
+
|
2016-03-01 00:09:49 +01:00
|
|
|
+ @Override
|
2016-04-13 22:57:34 +02:00
|
|
|
+ public boolean getAffectsSpawning() {
|
|
|
|
+ return this.getHandle().affectsSpawning;
|
2017-05-28 06:25:17 +02:00
|
|
|
}
|
2018-07-15 03:53:17 +02:00
|
|
|
+ // Paper end
|
2017-05-28 06:25:17 +02:00
|
|
|
|
2018-08-12 08:08:09 +02:00
|
|
|
@Override
|
|
|
|
public void updateCommands() {
|