tried to fix chunk unloading issue

This commit is contained in:
makeo committed 2015-11-09 20:49:28 +01:00
1 parent d40366dfdc
commit bfb1b8df84
1 file changed
+16
@@ -1,10 +1,14 @@
package makeo.gadomancy.common.utils.world;
import makeo.gadomancy.common.data.ModConfig;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.Vec3;
import net.minecraft.world.ChunkCoordIntPair;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.DimensionManager;
import org.apache.logging.log4j.LogManager;
import thaumcraft.common.lib.world.dim.Cell;
import thaumcraft.common.lib.world.dim.CellLoc;
@@ -64,6 +68,18 @@ class TCMazeSession {
}
final void startSession() {
WorldServer ws = DimensionManager.getWorld(ModConfig.dimOuterId);
int chunkCount = 0;
for(CellLoc loc : chunksAffected.keySet()) {
long k = ChunkCoordIntPair.chunkXZ2Int(loc.x, loc.z);
if(ws.theChunkProviderServer.loadedChunkHashMap.containsItem(k)) {
ws.theChunkProviderServer.loadedChunkHashMap.remove(k);
chunkCount++;
}
}
LogManager.getLogger().info("Removed " + chunkCount + " of " + chunksAffected.keySet().size() + " chunks from Eldritch dimension.");
if(portalCell == null) {
LogManager.getLogger().error("Thaumcraft didn't generate a portal! Stopping instance!", new IllegalStateException());
closeSession(false);