verify block is still at location changing state

closes #3175
This commit is contained in:
payonel 2019-11-12 22:50:23 -08:00
parent e5370b5aec
commit fb1ba7472f

View File

@ -79,7 +79,13 @@ class Case(var tier: Int) extends traits.PowerAcceptor with traits.Computer with
override protected def onRunningChanged(): Unit = {
super.onRunningChanged()
getBlockType match {
case block: common.block.Case => getWorld.setBlockState(getPos, getWorld.getBlockState(getPos).withProperty(PropertyRunning.Running, Boolean.box(isRunning)))
case block: common.block.Case => {
val state = getWorld.getBlockState(getPos)
// race condition that the world no longer has this block at the position (e.g. it was broken)
if (block == state.getBlock) {
getWorld.setBlockState(getPos, state.withProperty(PropertyRunning.Running, Boolean.box(isRunning)))
}
}
case _ =>
}
}