diff --git a/changelog.md b/changelog.md index 1e68cf837..cb7d7ea32 100644 --- a/changelog.md +++ b/changelog.md @@ -26,7 +26,8 @@ * forceNativeLibPathFirst allows choosing a directory to check for natives in, instead of always searching in the jar for one. This allows custom natives to be used without packing them into the mod jar first, which should be much easier for end users. * Changed: The game now crashes instead of reloading defaults if a config file is present but invalid. * Fixed: [#3588] Renaming over other files does not properly free space. -* Removed: Native Lua library support for x86 macOS. +* Fixed: [#3591] Memory leak with wrapped worlds from other mods. +* Removed: Native Lua library support for x86 (32-bit) macOS. * (1.7.10) Fixed: [#3239] Inconsistencies in Robot block clicking. ## OpenOS fixes/improvements diff --git a/src/main/scala/li/cil/oc/common/SaveHandler.scala b/src/main/scala/li/cil/oc/common/SaveHandler.scala index d966c64d2..4ed720a04 100644 --- a/src/main/scala/li/cil/oc/common/SaveHandler.scala +++ b/src/main/scala/li/cil/oc/common/SaveHandler.scala @@ -9,7 +9,6 @@ import java.util.concurrent.ConcurrentLinkedDeque import java.util.concurrent.Future import java.util.concurrent.TimeUnit import java.util.concurrent.TimeoutException - import cpw.mods.fml.common.eventhandler.EventPriority import cpw.mods.fml.common.eventhandler.SubscribeEvent import li.cil.oc.OpenComputers @@ -21,8 +20,7 @@ import li.cil.oc.util.SafeThreadPool import li.cil.oc.util.ThreadPoolFactory import net.minecraft.nbt.CompressedStreamTools import net.minecraft.nbt.NBTTagCompound -import net.minecraft.world.ChunkCoordIntPair -import net.minecraft.world.World +import net.minecraft.world.{ChunkCoordIntPair, World, WorldServer} import net.minecraftforge.common.DimensionManager import net.minecraftforge.event.world.WorldEvent import org.apache.commons.lang3.JavaVersion @@ -101,16 +99,20 @@ object SaveHandler { def scheduleSave(position: BlockPosition, nbt: NBTTagCompound, name: String, data: Array[Byte]) { val world = position.world.get - val dimension = world.provider.dimensionId - val chunk = new ChunkCoordIntPair(position.x >> 4, position.z >> 4) + + // Try to exclude wrapped/client-side worlds. + if (world.isInstanceOf[WorldServer]) { + val dimension = world.provider.dimensionId + val chunk = new ChunkCoordIntPair(position.x >> 4, position.z >> 4) - // We have to save the dimension and chunk coordinates, because they are - // not available on load / may have changed if the computer was moved. - nbt.setInteger("dimension", dimension) - nbt.setInteger("chunkX", chunk.chunkXPos) - nbt.setInteger("chunkZ", chunk.chunkZPos) + // We have to save the dimension and chunk coordinates, because they are + // not available on load / may have changed if the computer was moved. + nbt.setInteger("dimension", dimension) + nbt.setInteger("chunkX", chunk.chunkXPos) + nbt.setInteger("chunkZ", chunk.chunkZPos) - scheduleSave(dimension, chunk, name, data) + scheduleSave(dimension, chunk, name, data) + } } private def writeNBT(save: NBTTagCompound => Unit) = {