Paper/Spigot-Server-Patches/0016-Player-affects-spawning-API.patch

96 lines
4.4 KiB
Diff
Raw Normal View History

From c36382de32e928b4d76ce823104cfea9573abf90 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
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
2016-12-20 23:34:27 +01:00
index 82146de..f1823af 100644
2016-11-17 03:23:38 +01:00
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -63,6 +63,7 @@ public abstract class EntityHuman extends EntityLiving {
private final ItemCooldown bV;
@Nullable
public EntityFishingHook hookedFish;
+ public boolean affectsSpawning = true;
2016-11-17 03:23:38 +01:00
// 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
2016-12-20 23:34:27 +01:00
index d3cf840..b6ecd02 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -617,7 +617,7 @@ public abstract class EntityInsentient extends EntityLiving {
} else {
EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
2016-11-17 03:23:38 +01:00
- if (entityhuman != null) {
+ if (entityhuman != null && entityhuman.affectsSpawning) { // Paper - Affects Spawning API
double d0 = entityhuman.locX - this.locX;
double d1 = entityhuman.locY - this.locY;
double d2 = entityhuman.locZ - this.locZ;
diff --git a/src/main/java/net/minecraft/server/EntitySilverfish.java b/src/main/java/net/minecraft/server/EntitySilverfish.java
2016-12-20 23:34:27 +01:00
index 5af51cc..7531c9b 100644
--- a/src/main/java/net/minecraft/server/EntitySilverfish.java
+++ b/src/main/java/net/minecraft/server/EntitySilverfish.java
@@ -99,8 +99,7 @@ public class EntitySilverfish extends EntityMonster {
public boolean cM() {
if (super.cM()) {
EntityHuman entityhuman = this.world.b(this, 5.0D);
-
- 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
}
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
2016-12-20 23:34:27 +01:00
index 17bf3e4..a05fad5 100644
2016-11-17 03:23:38 +01:00
--- a/src/main/java/net/minecraft/server/SpawnerCreature.java
+++ b/src/main/java/net/minecraft/server/SpawnerCreature.java
@@ -52,7 +52,7 @@ public final class SpawnerCreature {
while (iterator.hasNext()) {
EntityHuman entityhuman = (EntityHuman) iterator.next();
- if (!entityhuman.isSpectator()) {
+ if (!entityhuman.isSpectator() && entityhuman.affectsSpawning) {
2016-11-17 03:23:38 +01:00
int l = MathHelper.floor(entityhuman.locX / 16.0D);
j = MathHelper.floor(entityhuman.locZ / 16.0D);
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
index c5c4fad..64120c7 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -2722,7 +2722,7 @@ public abstract class World implements IBlockAccess {
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman = (EntityHuman) this.players.get(i);
- if (IEntitySelector.e.apply(entityhuman)) {
+ if (IEntitySelector.e.apply(entityhuman) && entityhuman.affectsSpawning) { // Paper - Affects Spawning API
double d4 = entityhuman.d(d0, d1, d2);
if (d3 < 0.0D || d4 < d3 * d3) {
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
2016-12-16 22:00:16 +01:00
index 877a0c8..5e9834c 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
2016-12-16 22:00:16 +01:00
@@ -1457,6 +1457,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
2016-11-17 03:23:38 +01:00
}
+ @Override
+ public void setAffectsSpawning(boolean affects) {
+ this.getHandle().affectsSpawning = affects;
+ }
+
+ @Override
+ public boolean getAffectsSpawning() {
+ return this.getHandle().affectsSpawning;
+ }
+
// Spigot start
private final Player.Spigot spigot = new Player.Spigot()
{
--
2016-12-16 22:00:16 +01:00
2.9.3
2016-11-17 03:23:38 +01:00