diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt index f0da2a116..dd0cb5212 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/MatteryBlock.kt @@ -33,6 +33,7 @@ import ru.dbotthepony.mc.otm.core.math.BlockRotationFreedom import ru.dbotthepony.mc.otm.core.math.component1 import ru.dbotthepony.mc.otm.core.math.component2 import ru.dbotthepony.mc.otm.core.math.component3 +import ru.dbotthepony.mc.otm.once fun Block.getShapeForEachState(properties: List>, fn: (BlockState) -> VoxelShape): Map { val builder = ImmutableMap.Builder() @@ -174,13 +175,17 @@ abstract class MatteryBlock @JvmOverloads constructor( super.neighborChanged(state, level, pos, neighbour, neighbourPos, movedByPiston) if (this is EntityBlock && !level.isClientSide) { - val tile = level.getBlockEntity(pos) + val tile = level.getBlockEntity(pos) ?: return - if (tile is IRedstoneControlled) - tile.redstoneControl.redstoneSignal = level.getBestNeighborSignal(pos) + level.once { + if (!tile.isRemoved) { + if (tile is IRedstoneControlled) + tile.redstoneControl.redstoneSignal = level.getBestNeighborSignal(pos) - if (tile is MatteryBlockEntity && SERVER_IS_LIVE) - tile.neighborChanged(neighbour, neighbourPos, movedByPiston) + if (tile is MatteryBlockEntity && SERVER_IS_LIVE) + tile.neighborChanged(neighbour, neighbourPos, movedByPiston) + } + } } } diff --git a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt index 20294fce6..cc484d733 100644 --- a/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt +++ b/src/main/kotlin/ru/dbotthepony/mc/otm/block/entity/MatteryBlockEntity.kt @@ -238,10 +238,11 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc private fun updateTracked(capability: Capability<*>) { if (isRemoved || !SERVER_IS_LIVE) return val dir = blockRotation.side2Dir(side) + val targetPos = blockPos + dir.normal val chunk = level ?.chunkSource - ?.getChunkNow(SectionPos.blockToSectionCoord(blockPos.x), SectionPos.blockToSectionCoord(blockPos.z)) + ?.getChunkNow(SectionPos.blockToSectionCoord(targetPos.x), SectionPos.blockToSectionCoord(targetPos.z)) if (chunk == null) { subscriptions[capability]!!.unset() @@ -249,7 +250,7 @@ abstract class MatteryBlockEntity(p_155228_: BlockEntityType<*>, p_155229_: Bloc return } - val entity = chunk.getBlockEntity(blockPos + dir.normal) + val entity = chunk.getBlockEntity(targetPos) if (entity == null) { subscriptions[capability]!!.unset()