mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-28 23:38:25 +01:00
298c9022b0
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing
Bukkit Changes:
ccb9614e #548: LivingEntity - add methods for getting/setting invisibility
CraftBukkit Changes:
f8d4da08
#743: LivingEntity - add methods for getting/setting invisibility
Spigot Changes:
17d78dbd Rebuild patches
156 lines
8 KiB
Diff
156 lines
8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jedediah Smith <jedediah@silencegreys.com>
|
|
Date: Tue, 1 Mar 2016 14:47:52 -0600
|
|
Subject: [PATCH] Player affects spawning API
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/Entity.java b/src/main/java/net/minecraft/server/Entity.java
|
|
index d8766f302ed6512d3b4e8bb6508a71e5c8910b54..39ee76225bcb6b44050d41bc5da1dbc63cab1220 100644
|
|
--- a/src/main/java/net/minecraft/server/Entity.java
|
|
+++ b/src/main/java/net/minecraft/server/Entity.java
|
|
@@ -1269,6 +1269,7 @@ 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;
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index e16be546b22c09e1c6ed50c453e1f2c711832a81..683d98dea1b46931478ac7b55e49bc9d92d36f77 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -70,6 +70,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/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
index 71e8d8c0c4c5ec1ebb67a4cf5ce3c751a5fd052a..4e46685e9d0564ed9330fbec35848f4cd1fb516c 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
|
@@ -691,7 +691,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/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java
|
|
index 17a0ebfcd7eefa63adc581479244231b20150340..35f15c8ddd7c85aeb599bc7921053abe09130e59 100644
|
|
--- a/src/main/java/net/minecraft/server/EntitySilverfish.java
|
|
+++ b/src/main/java/net/minecraft/server/EntitySilverfish.java
|
|
@@ -95,7 +95,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/server/IEntityAccess.java b/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
index 797249069b0b2adf91b4e69497752eed7116f02a..b6cf294e785b36b8bc800f26dbb8cfcb2119eae1 100644
|
|
--- a/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
+++ b/src/main/java/net/minecraft/server/IEntityAccess.java
|
|
@@ -83,8 +83,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();
|
|
@@ -117,6 +118,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/server/IEntitySelector.java b/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
index 8061f33c01b9c2382f72d2d1d1fa2fb8a731e3c8..e8e7532493c973ce10d94a41676859674fc4e6f6 100644
|
|
--- a/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
+++ b/src/main/java/net/minecraft/server/IEntitySelector.java
|
|
@@ -24,6 +24,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/server/MobSpawnerAbstract.java b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
index 90af43930f9141b0c7f51bb3d887d7b9c4d935eb..1741ec5e241f8ae7a3c30a9021d14cb0224da840 100644
|
|
--- a/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
+++ b/src/main/java/net/minecraft/server/MobSpawnerAbstract.java
|
|
@@ -49,7 +49,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 495470f9c397e80b9e6e8e3c9360b0d659b916ed..11f80c6f58e611f33ad8bbd09aa8bf90c7933426 100644
|
|
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
|
|
@@ -1686,7 +1686,19 @@ 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() {
|