fix #3591, possibly

This commit is contained in:
Adrian Siekierka 2023-05-07 09:54:24 +02:00
parent 25773cc5eb
commit f8cb77e441
2 changed files with 15 additions and 12 deletions

View File

@ -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

View File

@ -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) = {