Improved mob spawn mechanics for PSPE w/ misc cleanup

This commit is contained in:
Sotr
2019-04-08 19:52:02 +08:00
parent f3a6ec65cc
commit 0deb4ca743
13 changed files with 356 additions and 11 deletions

View File

@@ -75,6 +75,7 @@ public class Chunk implements IChunkAccess {
private int D;
private final AtomicInteger E;
private final ChunkCoordIntPair F;
public final int[] creatureCounts = new int[EnumCreatureType.values().length]; // Akarin
// CraftBukkit start - Neighbor loaded cache for chunk lighting and entity ticking
private volatile int neighbors = 0x1 << 12; // Akarin - volatile
@@ -766,6 +767,12 @@ public class Chunk implements IChunkAccess {
itemCounts[k]++;
} else if (entity instanceof IInventory) {
inventoryEntityCounts[k]++;
// Akarin start
} else if (entity instanceof IAnimal) {
for (EnumCreatureType type : EnumCreatureType.values())
if (type.matches(entity))
creatureCounts[type.ordinal()]++;
// Akarin end
}
// Paper end
}
@@ -800,6 +807,14 @@ public class Chunk implements IChunkAccess {
itemCounts[i]--;
} else if (entity instanceof IInventory) {
inventoryEntityCounts[i]--;
// Akarin start
} else if (entity instanceof IAnimal) {
for (EnumCreatureType type : EnumCreatureType.values())
if (type.matches(entity)) {
int typeCount = creatureCounts[type.ordinal()];
creatureCounts[type.ordinal()] = typeCount > 1 ? --typeCount : 0;
}
// Akarin end
}
entityCounts.decrement(entity.getMinecraftKeyString());
// Paper end