Drop Terminal items on block break

This commit is contained in:
Shadowfacts 2021-03-03 19:16:51 -05:00
parent 5b314120a7
commit 2d3ac4538d
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 9 additions and 0 deletions

View File

@ -46,6 +46,15 @@ class TerminalBlock: DeviceBlock<TerminalBlockEntity>(
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))
}