2020-05-06 11:48:49 +02:00
|
|
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
2016-11-17 03:23:38 +01:00
|
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
|
|
Date: Tue, 1 Mar 2016 14:47:52 -0600
|
|
|
|
Subject: [PATCH] Player affects spawning API
|
|
|
|
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
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
|
2020-08-25 04:22:08 +02:00
|
|
|
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;
|
2021-03-16 08:19:45 +01:00
|
|
|
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 {
|
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
|
2021-03-16 08:19:45 +01:00
|
|
|
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 {
|
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
|
|
|
}
|
2021-03-16 08:19:45 +01:00
|
|
|
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 {
|
2020-06-25 11:27:25 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
- @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();
|
2021-03-16 08:19:45 +01:00
|
|
|
@@ -126,6 +127,27 @@ public interface IEntityAccess {
|
2020-06-25 11:27:25 +02:00
|
|
|
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();
|
|
|
|
|
2021-03-16 08:19:45 +01:00
|
|
|
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 {
|
2020-06-25 11:27:25 +02:00
|
|
|
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() {
|
2016-11-17 03:23:38 +01:00
|
|
|
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2021-03-16 08:19:45 +01:00
|
|
|
index 137870c7d18c9ef3ae637e83c5457d42ec40c669..e9f5ef73de6fd100dda7ed006dde6635f65b1ab5 100644
|
2016-11-17 03:23:38 +01:00
|
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
2021-03-03 23:43:45 +01:00
|
|
|
@@ -1767,8 +1767,20 @@ 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-11-17 03:23:38 +01:00
|
|
|
+ public void setAffectsSpawning(boolean affects) {
|
|
|
|
+ this.getHandle().affectsSpawning = affects;
|
2021-02-21 20:45:33 +01:00
|
|
|
}
|
|
|
|
|
2016-11-17 03:23:38 +01:00
|
|
|
+ @Override
|
|
|
|
+ public boolean getAffectsSpawning() {
|
|
|
|
+ return this.getHandle().affectsSpawning;
|
2021-02-21 20:45:33 +01:00
|
|
|
+ }
|
2018-07-15 03:53:17 +02:00
|
|
|
+ // Paper end
|
2021-02-21 20:45:33 +01:00
|
|
|
+
|
2018-08-12 08:08:09 +02:00
|
|
|
@Override
|
|
|
|
public void updateCommands() {
|
2021-02-21 20:45:33 +01:00
|
|
|
if (getHandle().playerConnection == null) return;
|