mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-01 17:01:56 +01:00
Fix a vanilla bug thats likely causing the mob spawn issues
This commit is contained in:
parent
2a2540e76c
commit
73c44798c5
1 changed files with 30 additions and 3 deletions
|
@ -13,20 +13,27 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
}
|
}
|
||||||
|
|
||||||
+ // Paper start - Try to catch plugins doing indecent things
|
+ // Paper start - Try to catch plugins doing indecent things
|
||||||
|
+ boolean ignoreAdd = false;
|
||||||
+ if (entity.aa) {
|
+ if (entity.aa) {
|
||||||
+ boolean thisChunk = entity.getChunkX() == this.locX && entity.getChunkY() == k && entity.getChunkZ() == this.locZ;
|
+ boolean thisChunk = entity.getChunkX() == this.locX && entity.getChunkY() == k && entity.getChunkZ() == this.locZ;
|
||||||
+ String chunkName = entity.getWorld().getWorld().getName() + ":" + entity.getChunkX() + "," + entity.getChunkY() + "," + entity.getChunkZ();
|
+ String chunkName = entity.getWorld().getWorld().getName() + ":" + entity.getChunkX() + "," + entity.getChunkY() + "," + entity.getChunkZ();
|
||||||
+ if (!thisChunk) {
|
+ if (!thisChunk) {
|
||||||
+ throw new IllegalStateException("Entity Already in another chunk: " + chunkName);
|
+ throw new IllegalStateException("Entity Already in another chunk: " + chunkName);
|
||||||
+ } else if (this.entitySlices[k].contains(entity)) {
|
+ } else if (this.entitySlices[k].contains(entity)) {
|
||||||
+ throw new IllegalStateException("Double Chunk Add to: " + chunkName);
|
+ new Throwable("Double Chunk Add to: " + chunkName).printStackTrace();
|
||||||
|
+ ignoreAdd = true;
|
||||||
+ } else {
|
+ } else {
|
||||||
|
+ boolean found = false;
|
||||||
+ for (int i1 = 0; i1 < this.entitySlices.length; i1++) {
|
+ for (int i1 = 0; i1 < this.entitySlices.length; i1++) {
|
||||||
+ if (this.entitySlices[i1].contains(entity)) {
|
+ if (this.entitySlices[i1].contains(entity)) {
|
||||||
+ throw new IllegalStateException("Entity was found in another slice of this chunk, tried: " + k + ", was in: " + chunkName);
|
+ new Throwable("Entity was found in another slice of this chunk, tried: " + k + ", was in: " + chunkName).printStackTrace();
|
||||||
|
+ found = true;
|
||||||
|
+ ignoreAdd = true;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ new Throwable("Improperly detected double chunk add. Was not actually in this chunk.").printStackTrace();
|
+ if (!found) {
|
||||||
|
+ new Throwable("Improperly detected double chunk add. Was not actually in this chunk.").printStackTrace();
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Paper end
|
+ // Paper end
|
||||||
|
@ -34,6 +41,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
entity.aa = true;
|
entity.aa = true;
|
||||||
entity.ab = this.locX;
|
entity.ab = this.locX;
|
||||||
entity.ac = k;
|
entity.ac = k;
|
||||||
|
entity.ad = this.locZ;
|
||||||
|
this.entitySlices[k].add(entity);
|
||||||
|
// Paper start - update count
|
||||||
|
+ if (ignoreAdd) return;
|
||||||
|
if (entity instanceof EntityItem) {
|
||||||
|
itemCounts[k]++;
|
||||||
|
} else if (entity instanceof IInventory) {
|
||||||
@@ -0,0 +0,0 @@ public class Chunk {
|
@@ -0,0 +0,0 @@ public class Chunk {
|
||||||
} else if (entity instanceof IInventory) {
|
} else if (entity instanceof IInventory) {
|
||||||
inventoryEntityCounts[i]--;
|
inventoryEntityCounts[i]--;
|
||||||
|
@ -42,4 +56,17 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||||
// Paper end
|
// Paper end
|
||||||
// Spigot start - decrement creature type count
|
// Spigot start - decrement creature type count
|
||||||
// Keep this synced up with World.a(Class)
|
// Keep this synced up with World.a(Class)
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/World.java b/src/main/java/net/minecraft/server/World.java
|
||||||
|
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/World.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/World.java
|
||||||
|
@@ -0,0 +0,0 @@ public abstract class World implements IBlockAccess {
|
||||||
|
}
|
||||||
|
|
||||||
|
int k = MathHelper.floor(entity.locX / 16.0D);
|
||||||
|
- int l = MathHelper.floor(entity.locY / 16.0D);
|
||||||
|
+ int l = Math.min(15, Math.max(0, MathHelper.floor(entity.locY / 16.0D))); // Paper - stay consistent with chunk add/remove behavior
|
||||||
|
int i1 = MathHelper.floor(entity.locZ / 16.0D);
|
||||||
|
|
||||||
|
if (!entity.aa || entity.ab != k || entity.ac != l || entity.ad != i1) {
|
||||||
--
|
--
|
Loading…
Reference in a new issue