summaryrefslogtreecommitdiffstats
path: root/nms-patches
diff options
context:
space:
mode:
authormd_5 <git@md-5.net>2016-12-17 14:26:09 +1100
committermd_5 <git@md-5.net>2016-12-17 14:26:09 +1100
commit7f313269d751d25336a1575c4848d83c150f9517 (patch)
tree6abe26dd8465447ad9eba605ed51b64156c53f75 /nms-patches
parent532457e41d1928bb0589b241b9f38584fbbd62cc (diff)
downloadcraftbukkit-7f313269d751d25336a1575c4848d83c150f9517.tar
craftbukkit-7f313269d751d25336a1575c4848d83c150f9517.tar.gz
craftbukkit-7f313269d751d25336a1575c4848d83c150f9517.tar.lz
craftbukkit-7f313269d751d25336a1575c4848d83c150f9517.tar.xz
craftbukkit-7f313269d751d25336a1575c4848d83c150f9517.zip
SPIGOT-2926: Check spawn-npcs setting for NPCs.
Probably should refactor this code to be more similar to Vanilla in future.
Diffstat (limited to 'nms-patches')
-rw-r--r--nms-patches/World.patch55
1 files changed, 28 insertions, 27 deletions
diff --git a/nms-patches/World.patch b/nms-patches/World.patch
index 63230475..921a5b9e 100644
--- a/nms-patches/World.patch
+++ b/nms-patches/World.patch
@@ -272,7 +272,7 @@
int i = MathHelper.floor(entity.locX / 16.0D);
int j = MathHelper.floor(entity.locZ / 16.0D);
boolean flag = entity.attachedToPlayer;
-@@ -793,6 +977,34 @@
+@@ -793,6 +977,35 @@
flag = true;
}
@@ -281,9 +281,10 @@
+ if (entity instanceof EntityLiving && !(entity instanceof EntityPlayer)) {
+ boolean isAnimal = entity instanceof EntityAnimal || entity instanceof EntityWaterAnimal || entity instanceof EntityGolem;
+ boolean isMonster = entity instanceof EntityMonster || entity instanceof EntityGhast || entity instanceof EntitySlime;
++ boolean isNpc = entity instanceof NPC;
+
+ if (spawnReason != SpawnReason.CUSTOM) {
-+ if (isAnimal && !allowAnimals || isMonster && !allowMonsters) {
++ if (isAnimal && !allowAnimals || isMonster && !allowMonsters || isNpc && !getServer().getServer().getSpawnNPCs()) {
+ entity.dead = true;
+ return false;
+ }
@@ -307,7 +308,7 @@
if (!flag && !this.isChunkLoaded(i, j, false)) {
return false;
} else {
-@@ -815,6 +1027,7 @@
+@@ -815,6 +1028,7 @@
((IWorldAccess) this.u.get(i)).a(entity);
}
@@ -315,7 +316,7 @@
}
protected void c(Entity entity) {
-@@ -822,6 +1035,7 @@
+@@ -822,6 +1036,7 @@
((IWorldAccess) this.u.get(i)).b(entity);
}
@@ -323,7 +324,7 @@
}
public void kill(Entity entity) {
-@@ -857,7 +1071,15 @@
+@@ -857,7 +1072,15 @@
this.getChunkAt(i, j).b(entity);
}
@@ -340,7 +341,7 @@
this.c(entity);
}
-@@ -1068,6 +1290,11 @@
+@@ -1068,6 +1291,11 @@
for (i = 0; i < this.j.size(); ++i) {
entity = (Entity) this.j.get(i);
@@ -352,7 +353,7 @@
try {
++entity.ticksLived;
-@@ -1116,8 +1343,10 @@
+@@ -1116,8 +1344,10 @@
CrashReportSystemDetails crashreportsystemdetails1;
CrashReport crashreport1;
@@ -365,7 +366,7 @@
Entity entity1 = entity.bB();
if (entity1 != null) {
-@@ -1150,7 +1379,7 @@
+@@ -1150,7 +1380,7 @@
this.getChunkAt(j, l).b(entity);
}
@@ -374,7 +375,7 @@
this.c(entity);
}
-@@ -1159,6 +1388,13 @@
+@@ -1159,6 +1389,13 @@
this.methodProfiler.c("blockEntities");
this.M = true;
@@ -388,7 +389,7 @@
Iterator iterator = this.tileEntityListTick.iterator();
while (iterator.hasNext()) {
-@@ -1169,7 +1405,7 @@
+@@ -1169,7 +1406,7 @@
if (this.isLoaded(blockposition) && this.N.a(blockposition)) {
try {
@@ -397,7 +398,7 @@
((ITickable) tileentity).F_();
this.methodProfiler.b();
} catch (Throwable throwable2) {
-@@ -1191,11 +1427,13 @@
+@@ -1191,11 +1428,13 @@
}
this.M = false;
@@ -411,7 +412,7 @@
this.methodProfiler.c("pendingBlockEntities");
if (!this.b.isEmpty()) {
-@@ -1203,9 +1441,11 @@
+@@ -1203,9 +1442,11 @@
TileEntity tileentity1 = (TileEntity) this.b.get(i1);
if (!tileentity1.y()) {
@@ -423,7 +424,7 @@
if (this.isLoaded(tileentity1.getPosition())) {
Chunk chunk = this.getChunkAtWorldCoords(tileentity1.getPosition());
-@@ -1213,6 +1453,12 @@
+@@ -1213,6 +1454,12 @@
chunk.a(tileentity1.getPosition(), tileentity1);
this.notify(tileentity1.getPosition(), iblockdata, iblockdata, 3);
@@ -436,7 +437,7 @@
}
}
}
-@@ -1267,7 +1513,10 @@
+@@ -1267,7 +1514,10 @@
int j = MathHelper.floor(entity.locZ);
boolean flag1 = true;
@@ -448,7 +449,7 @@
entity.M = entity.locX;
entity.N = entity.locY;
entity.O = entity.locZ;
-@@ -1571,11 +1820,18 @@
+@@ -1571,11 +1821,18 @@
}
}
@@ -467,7 +468,7 @@
TileEntity tileentity = null;
if (this.M) {
-@@ -1610,6 +1866,14 @@
+@@ -1610,6 +1867,14 @@
public void setTileEntity(BlockPosition blockposition, @Nullable TileEntity tileentity) {
if (!this.E(blockposition)) {
if (tileentity != null && !tileentity.y()) {
@@ -482,7 +483,7 @@
if (this.M) {
tileentity.setPosition(blockposition);
Iterator iterator = this.b.iterator();
-@@ -1769,6 +2033,14 @@
+@@ -1769,6 +2034,14 @@
}
this.o = MathHelper.a(this.o, 0.0F, 1.0F);
@@ -497,7 +498,7 @@
}
}
}
-@@ -1900,7 +2172,10 @@
+@@ -1900,7 +2173,10 @@
}
public boolean c(EnumSkyBlock enumskyblock, BlockPosition blockposition) {
@@ -509,7 +510,7 @@
return false;
} else {
int i = 0;
-@@ -2067,7 +2342,7 @@
+@@ -2067,7 +2343,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -518,7 +519,7 @@
arraylist.add(entity);
}
}
-@@ -2082,7 +2357,7 @@
+@@ -2082,7 +2358,7 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -527,7 +528,7 @@
arraylist.add(entity);
}
}
-@@ -2131,7 +2406,7 @@
+@@ -2131,7 +2407,7 @@
}
}
@@ -536,7 +537,7 @@
}
@Nullable
-@@ -2152,8 +2427,17 @@
+@@ -2152,8 +2428,17 @@
while (iterator.hasNext()) {
Entity entity = (Entity) iterator.next();
@@ -556,7 +557,7 @@
++i;
}
}
-@@ -2162,12 +2446,18 @@
+@@ -2162,12 +2447,18 @@
}
public void a(Collection<Entity> collection) {
@@ -576,7 +577,7 @@
this.b(entity);
}
-@@ -2181,7 +2471,13 @@
+@@ -2181,7 +2472,13 @@
IBlockData iblockdata = this.getType(blockposition);
AxisAlignedBB axisalignedbb = flag ? null : block.getBlockData().c(this, blockposition);
@@ -591,7 +592,7 @@
}
public int K() {
-@@ -2291,6 +2587,11 @@
+@@ -2291,6 +2588,11 @@
for (int i = 0; i < this.players.size(); ++i) {
EntityHuman entityhuman1 = (EntityHuman) this.players.get(i);
@@ -603,7 +604,7 @@
if (predicate.apply(entityhuman1)) {
double d5 = entityhuman1.d(d0, d1, d2);
-@@ -2459,6 +2760,16 @@
+@@ -2459,6 +2761,16 @@
public void everyoneSleeping() {}
@@ -620,7 +621,7 @@
public float h(float f) {
return (this.p + (this.q - this.p) * f) * this.j(f);
}
-@@ -2676,7 +2987,7 @@
+@@ -2676,7 +2988,7 @@
int l = j * 16 + 8 - blockposition.getZ();
boolean flag = true;