Merge pull request #2174 from Vexatos/no-crash-in-NBT

Fix robots duplicating with SpongeForge.
This commit is contained in:
Florian "Sangar" Nücke 2016-12-11 11:58:31 +01:00 committed by GitHub
commit 6e1270ef08

View File

@ -765,7 +765,11 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
})
override def save(nbt: NBTTagCompound): Unit = Machine.this.synchronized(state.synchronized {
assert(!isExecuting) // Lock on 'this' should guarantee this.
// The lock on 'this' should guarantee that this never happens regularly.
// If something other than regular saving tries to save while we are executing code,
// e.g. SpongeForge saving during robot.move due to block changes being captured,
// just don't save this at all. What could possibly go wrong?
if(isExecuting) return
if (SaveHandler.savingForClients) {
return
@ -1076,4 +1080,4 @@ object Machine extends MachineAPI {
}
private val threadPool = ThreadPoolFactory.create("Computer", Settings.get.threads)
}
}