Async half entity spawning

This commit is contained in:
Sotr
2019-04-12 16:44:16 +08:00
parent 54c4441d22
commit 38e61c4f83
2 changed files with 64 additions and 30 deletions

View File

@@ -14,6 +14,7 @@ import com.google.common.collect.Sets;
import com.koloboke.collect.map.hash.HashObjObjMaps;
import io.akarin.server.core.AkarinAsyncExecutor;
import io.akarin.server.core.AkarinCreatureSpanwner;
import io.akarin.server.core.AkarinGlobalConfig;
import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
import it.unimi.dsi.fastutil.longs.LongSet;
@@ -76,7 +77,6 @@ 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
@@ -772,7 +772,7 @@ public class Chunk implements IChunkAccess {
} else if (entity instanceof IAnimal) {
for (EnumCreatureType type : EnumCreatureType.values())
if (type.matches(entity))
creatureCounts[type.ordinal()]++;
AkarinCreatureSpanwner.increment(this.getPos(), type);
// Akarin end
}
// Paper end
@@ -812,8 +812,7 @@ public class Chunk implements IChunkAccess {
} 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;
AkarinCreatureSpanwner.decrement(this.getPos(), type);
}
// Akarin end
}