From 2d3ac4538d9d2dedc20b6831ca7d7570bf1297a0 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Wed, 3 Mar 2021 19:16:51 -0500 Subject: [PATCH] Drop Terminal items on block break --- .../shadowfacts/phycon/block/terminal/TerminalBlock.kt | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalBlock.kt b/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalBlock.kt index 475cacb..4f8f1a5 100644 --- a/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalBlock.kt +++ b/src/main/kotlin/net/shadowfacts/phycon/block/terminal/TerminalBlock.kt @@ -46,6 +46,15 @@ class TerminalBlock: DeviceBlock( return ActionResult.SUCCESS } + override fun onStateReplaced(state: BlockState, world: World, pos: BlockPos, newState: BlockState, moved: Boolean) { + if (!state.isOf(newState.block)) { + val be = getBlockEntity(world, pos)!! + ItemScatterer.spawn(world, pos, be.internalBuffer) + + super.onStateReplaced(state, world, pos, newState, moved) + } + } + override fun addAllAttributes(world: World, pos: BlockPos, state: BlockState, to: AttributeList<*>) { to.offer(getBlockEntity(world, pos)) }