diff --git a/src/main/java/cr0s/warpdrive/data/ChunkData.java b/src/main/java/cr0s/warpdrive/data/ChunkData.java index 0e4fb8ec..ab9284de 100644 --- a/src/main/java/cr0s/warpdrive/data/ChunkData.java +++ b/src/main/java/cr0s/warpdrive/data/ChunkData.java @@ -235,7 +235,11 @@ public class ChunkData { public void unload() { // check consistency - assert(!isLoaded); + if (!isLoaded) { + WarpDrive.logger.warn(String.format("Chunk is already unloaded at (%d %d %d)", + getChunkPosition().chunkPosX, getChunkPosition().chunkPosY, getChunkPosition().chunkPosZ)); + return; + } // detects fast unloading final long time = System.currentTimeMillis(); diff --git a/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java b/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java index 5c1154c5..8b994a41 100644 --- a/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java +++ b/src/main/java/cr0s/warpdrive/data/EnumForceFieldUpgrade.java @@ -29,7 +29,7 @@ import net.minecraft.world.World; public enum EnumForceFieldUpgrade implements IForceFieldUpgrade, IForceFieldUpgradeEffector { // Upgrade - Compatibility - ----- Value ----- -- Scan speed -- -- Place speed -- --------- Energy costs --------- comment // name projector relay incr. cap minimum maximum minimum maximum startup scan place entity - NONE ("none" , 0, 0, 0.0F, 0.0F, 0.000F, 0.000F, 0.000F, 0.000F, 0.0F, 0.000F, 0.000F, 0.0F, ""), + NONE ("none" , 0, 0, 0.0F, 0.0F, 0.000F, 0.000F, 0.000F, 0.000F, 0.0F, 0.000F, 0.000F, 0.0F, "n/a"), ATTRACTION ("attraction" , 0, 1, 1.0F, 4.0F, 0.000F, 0.000F, 0.000F, 0.000F, 50.0F, 0.150F, 0.000F, 8.0F, "value is acceleration"), BREAKING ("breaking" , 0, 1, 1.0F, 25.0F, 0.400F, 0.500F, 0.020F, 0.150F, 700.0F, 0.080F, 4.000F, 0.0F, "value is hardness level"), CAMOUFLAGE ("camouflage" , 0, 1, 1.0F, 3.0F, 0.600F, 0.850F, 0.700F, 0.950F, 1000.0F, 3.000F, 7.000F, 0.0F, "value is boolean"), diff --git a/src/main/java/cr0s/warpdrive/event/ChunkHandler.java b/src/main/java/cr0s/warpdrive/event/ChunkHandler.java index 464d84e4..f6621409 100644 --- a/src/main/java/cr0s/warpdrive/event/ChunkHandler.java +++ b/src/main/java/cr0s/warpdrive/event/ChunkHandler.java @@ -26,7 +26,8 @@ import net.minecraftforge.event.world.WorldEvent; public class ChunkHandler { // persistent properties - private static final Map> registry = new ConcurrentHashMap<>(32); + private static final Map> registryClient = new ConcurrentHashMap<>(32); + private static final Map> registryServer = new ConcurrentHashMap<>(32); // computed properties public static long delayLogging = 0; @@ -57,7 +58,7 @@ public class ChunkHandler { event.getChunk().getChunkCoordIntPair())); } - final ChunkData chunkData = getChunkData(event.world.provider.dimensionId, event.getChunk().xPosition, event.getChunk().zPosition); + final ChunkData chunkData = getChunkData(event.world.isRemote, event.world.provider.dimensionId, event.getChunk().xPosition, event.getChunk().zPosition); chunkData.load(event.getData()); } @@ -71,7 +72,7 @@ public class ChunkHandler { event.getChunk().getChunkCoordIntPair())); } - final ChunkData chunkData = getChunkData(event.world.provider.dimensionId, event.getChunk().xPosition, event.getChunk().zPosition); + final ChunkData chunkData = getChunkData(event.world.isRemote, event.world.provider.dimensionId, event.getChunk().xPosition, event.getChunk().zPosition); chunkData.load(new NBTTagCompound()); } } @@ -96,7 +97,7 @@ public class ChunkHandler { event.world.provider.getDimensionName(), event.getChunk().getChunkCoordIntPair())); } - final ChunkData chunkData = getChunkData(event.world.provider.dimensionId, event.getChunk().xPosition, event.getChunk().zPosition); + final ChunkData chunkData = getChunkData(event.world.isRemote, event.world.provider.dimensionId, event.getChunk().xPosition, event.getChunk().zPosition); chunkData.save(event.getData()); } @@ -126,6 +127,7 @@ public class ChunkHandler { } // get dimension data + final Map> registry = event.world.isRemote ? registryClient : registryServer; final Map mapRegistryItems = registry.get(event.world.provider.dimensionId); if (mapRegistryItems != null) { // unload chunks during shutdown @@ -153,7 +155,7 @@ public class ChunkHandler { event.getChunk().getChunkCoordIntPair())); } - getChunkData(event.world.provider.dimensionId, event.getChunk().xPosition, event.getChunk().zPosition).unload(); + getChunkData(event.world.isRemote, event.world.provider.dimensionId, event.getChunk().xPosition, event.getChunk().zPosition).unload(); } // (not called when closing SSP game) @@ -183,16 +185,17 @@ public class ChunkHandler { /* internal access */ public static ChunkData getChunkData(final World world, final int x, final int y, final int z) { - return getChunkData(world.provider.dimensionId, x, y, z); + return getChunkData(world.isRemote, world.provider.dimensionId, x, y, z); } - private static ChunkData getChunkData(final int dimensionId, final int x, final int y, final int z) { + private static ChunkData getChunkData(final boolean isRemote, final int dimensionId, final int x, final int y, final int z) { assert (y >= 0 && y <= 255); - return getChunkData(dimensionId, x >> 4, z >> 4); + return getChunkData(isRemote, dimensionId, x >> 4, z >> 4); } - private static ChunkData getChunkData(final int dimensionId, final int xChunk, final int zChunk) { + private static ChunkData getChunkData(final boolean isRemote, final int dimensionId, final int xChunk, final int zChunk) { // get dimension data + final Map> registry = isRemote ? registryClient : registryServer; Map mapRegistryItems = registry.get(dimensionId); // (lambda expressions are forcing synchronisation, so we don't use them here) if (mapRegistryItems == null) { @@ -229,6 +232,7 @@ public class ChunkHandler { public static void updateTick(final World world) { // get dimension data + final Map> registry = world.isRemote ? registryClient : registryServer; Map mapRegistryItems = registry.get(world.provider.dimensionId); if (mapRegistryItems == null) { return;