aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches-Unmapped/0021-Player-affects-spawning-API.patch
diff options
context:
space:
mode:
Diffstat (limited to 'Spigot-Server-Patches-Unmapped/0021-Player-affects-spawning-API.patch')
-rw-r--r--Spigot-Server-Patches-Unmapped/0021-Player-affects-spawning-API.patch157
1 files changed, 157 insertions, 0 deletions
diff --git a/Spigot-Server-Patches-Unmapped/0021-Player-affects-spawning-API.patch b/Spigot-Server-Patches-Unmapped/0021-Player-affects-spawning-API.patch
new file mode 100644
index 0000000000..022a7af002
--- /dev/null
+++ b/Spigot-Server-Patches-Unmapped/0021-Player-affects-spawning-API.patch
@@ -0,0 +1,157 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Jedediah Smith <[email protected]>
+Date: Tue, 1 Mar 2016 14:47:52 -0600
+Subject: [PATCH] Player affects spawning API
+
+
+diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
+index d7dfb89faa47817c51257bb124cfb3806c5e27da..ca620977666f4d4173089876f506f041ab278bd3 100644
+--- a/src/main/java/net/minecraft/world/entity/Entity.java
++++ b/src/main/java/net/minecraft/world/entity/Entity.java
+@@ -1354,6 +1354,7 @@ public abstract class Entity implements INamableTileEntity, ICommandListener, ne
+ 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;
+diff --git a/src/main/java/net/minecraft/world/entity/EntityInsentient.java b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
+index f93af56f68d5fd27eca38d333ca429ce22fc397b..0631cd531647239858b2a7298f58cc770720f69a 100644
+--- a/src/main/java/net/minecraft/world/entity/EntityInsentient.java
++++ b/src/main/java/net/minecraft/world/entity/EntityInsentient.java
+@@ -756,7 +756,7 @@ public abstract class EntityInsentient extends EntityLiving {
+ 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
+
+ if (entityhuman != null) {
+ double d0 = entityhuman.h((Entity) this); // CraftBukkit - decompile error
+diff --git a/src/main/java/net/minecraft/world/entity/IEntitySelector.java b/src/main/java/net/minecraft/world/entity/IEntitySelector.java
+index 6e78192a5898df017d96acba845a288011d24e35..dfcfdb31ca9531913d705aaaf85fb67399cfdc8c 100644
+--- a/src/main/java/net/minecraft/world/entity/IEntitySelector.java
++++ b/src/main/java/net/minecraft/world/entity/IEntitySelector.java
+@@ -29,6 +29,12 @@ 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/world/entity/monster/EntitySilverfish.java b/src/main/java/net/minecraft/world/entity/monster/EntitySilverfish.java
+index 0b3b430766fba602e74727f78173567ca10fabc6..e1fcb1be102822e87eaf7757fbd64a516b2f58ac 100644
+--- a/src/main/java/net/minecraft/world/entity/monster/EntitySilverfish.java
++++ b/src/main/java/net/minecraft/world/entity/monster/EntitySilverfish.java
+@@ -122,7 +122,7 @@ public class EntitySilverfish extends EntityMonster {
+ if (c(entitytypes, generatoraccess, enummobspawn, blockposition, random)) {
+ EntityHuman entityhuman = generatoraccess.a((double) blockposition.getX() + 0.5D, (double) blockposition.getY() + 0.5D, (double) blockposition.getZ() + 0.5D, 5.0D, true);
+
+- return entityhuman == null;
++ return !(entityhuman != null && !entityhuman.affectsSpawning) && entityhuman == null; // Paper - Affects Spawning API
+ } else {
+ return false;
+ }
+diff --git a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
+index 1017ee73b8617ce2b6734469fa49aaff7563c2b1..f42e16589476c1bd10b13214dda5ac7bb3e52131 100644
+--- a/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
++++ b/src/main/java/net/minecraft/world/entity/player/EntityHuman.java
+@@ -164,6 +164,9 @@ public abstract class EntityHuman extends EntityLiving {
+ private final ItemCooldown bM;
+ @Nullable
+ public EntityFishingHook hookedFish;
++ // Paper start
++ public boolean affectsSpawning = true;
++ // Paper end
+
+ // CraftBukkit start
+ public boolean fauxSleeping;
+diff --git a/src/main/java/net/minecraft/world/level/IEntityAccess.java b/src/main/java/net/minecraft/world/level/IEntityAccess.java
+index 4ece69851e7b05016f52c291ce911eb791cf3a23..6d5d4c3df65995b9a13b66d070ba08d553cc98a2 100644
+--- a/src/main/java/net/minecraft/world/level/IEntityAccess.java
++++ b/src/main/java/net/minecraft/world/level/IEntityAccess.java
+@@ -92,8 +92,9 @@ 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();
+@@ -126,6 +127,27 @@ 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));
++
++ d4 = entityhuman.getDistanceSquared(d0, d1, d2);
++ } 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/world/level/MobSpawnerAbstract.java b/src/main/java/net/minecraft/world/level/MobSpawnerAbstract.java
+index 33cba4e475edc0573b901f70c61d3659fd63ad62..8d8b03074df1635946f81bec0feae18d2f3e20aa 100644
+--- a/src/main/java/net/minecraft/world/level/MobSpawnerAbstract.java
++++ b/src/main/java/net/minecraft/world/level/MobSpawnerAbstract.java
+@@ -66,7 +66,7 @@ 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() {
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+index 137870c7d18c9ef3ae637e83c5457d42ec40c669..e9f5ef73de6fd100dda7ed006dde6635f65b1ab5 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+@@ -1767,8 +1767,20 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
+ @Override
+ public String getLocale() {
+ return getHandle().locale;
++
++ }
++
++ // Paper start
++ public void setAffectsSpawning(boolean affects) {
++ this.getHandle().affectsSpawning = affects;
+ }
+
++ @Override
++ public boolean getAffectsSpawning() {
++ return this.getHandle().affectsSpawning;
++ }
++ // Paper end
++
+ @Override
+ public void updateCommands() {
+ if (getHandle().playerConnection == null) return;