aboutsummaryrefslogtreecommitdiffhomepage
path: root/Spigot-Server-Patches/0016-Player-affects-spawning-API.patch
blob: 27dc440958b0a0d80c7741fa0a188c4f4ef58e4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
From 712d5956c8de0c6e33b8bb09bf92c90b19cd7627 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/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index ec8f581a..43e28d61 100644
--- 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;
 
     // 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 21f5df3c..a7283d36 100644
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
@@ -616,7 +616,7 @@ public abstract class EntityInsentient extends EntityLiving {
         } else {
             EntityHuman entityhuman = this.world.findNearbyPlayer(this, -1.0D);
 
-            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
index 5af51cc0..7531c9ba 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;
         }
diff --git a/src/main/java/net/minecraft/server/SpawnerCreature.java b/src/main/java/net/minecraft/server/SpawnerCreature.java
index 17bf3e41..a05fad54 100644
--- 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) {
                     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 40685515..70d62e8d 100644
--- a/src/main/java/net/minecraft/server/World.java
+++ b/src/main/java/net/minecraft/server/World.java
@@ -2721,7 +2721,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) {
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 08f3b080..b6cfd0dc 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -1468,6 +1468,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
 
     }
 
+    @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()
     {
-- 
2.12.0.windows.1