mirror of
https://github.com/PaperMC/Paper.git
synced 2024-12-11 09:23:42 +01:00
4c9bdf53ac
Upstream has released updates that appear 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: 9d0ad318 Fix javadoc errors in previous commits 9501daa2 #578: Add methods to modify the rate of regeneration and starvation 197d8f3d #577: Add EntityExhaustionEvent CraftBukkit Changes: a021e334 #795: Add methods to modify the rate of regeneration and starvation 509e523c #792: Add EntityExhaustionEvent Spigot Changes: db99f821 Rebuild patches
157 lines
8.1 KiB
Diff
157 lines
8.1 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 09bab3828197e3078a4ed95e7c8a9f34e8bf1b8d..dc996792df6046d442565a7993ec299af6605d92 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 1a4f49a019134ecd50542f0099e44f164aa9b690..dcc9984665a1b6458cee317bb79a3343656cea23 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 15b0d48e9dfe707b2859564b33206085f5a4e0db..a819fc46bebc4b1aaae63f822087574e976e2ab8 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 f5899fc014cfcc4b7e769d51e867ce1eaf625188..28b490cc14f5881eb83acfbd6f30f9163ffe1926 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 f433e1f6e6d430bd35a0fb54ee85295ea06f53bd..14400d0e4b0713e852861ed55e289e4dead95cea 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 143cfd9e99e9e0639bc32dd19efa84535a1fe03d..ff1ddb4db5406f81453a8f075033d00e06bce6a5 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 c0154a14a4da53b933b121fea585d1c1e4d0e87f..5d446eb731621e2205b684923a06b932d41ba421 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;
|