From fb1ba7472fedd4bf8f4897d6922d0cffda202896 Mon Sep 17 00:00:00 2001 From: payonel Date: Tue, 12 Nov 2019 22:50:23 -0800 Subject: [PATCH] verify block is still at location changing state closes #3175 --- src/main/scala/li/cil/oc/common/tileentity/Case.scala | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/scala/li/cil/oc/common/tileentity/Case.scala b/src/main/scala/li/cil/oc/common/tileentity/Case.scala index e1cf118d2..20d423a0c 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Case.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Case.scala @@ -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 _ => } }