From a681f8088528607e6a6e9ef92eca395f6d7d2bb5 Mon Sep 17 00:00:00 2001 From: PocketSizedWeeb Date: Fri, 19 Apr 2024 11:22:27 -0700 Subject: [PATCH] Fixed #2403 - Added the onRemove method to the Wireless Transmitter --- .../wireless/redstone/BlockWirelessTransmit.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/BlockWirelessTransmit.java b/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/BlockWirelessTransmit.java index a4efee3b3..284b61aea 100644 --- a/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/BlockWirelessTransmit.java +++ b/src/main/java/com/lothrazar/cyclic/block/wireless/redstone/BlockWirelessTransmit.java @@ -5,6 +5,7 @@ import com.lothrazar.cyclic.registry.TileRegistry; import net.minecraft.client.gui.screens.MenuScreens; import net.minecraft.core.BlockPos; +import net.minecraft.world.Containers; import net.minecraft.world.level.Level; import net.minecraft.world.level.block.Block; import net.minecraft.world.level.block.entity.BlockEntity; @@ -44,4 +45,18 @@ public BlockEntityTicker getTicker(Level world, Block protected void createBlockStateDefinition(StateDefinition.Builder builder) { builder.add(POWERED); } + + @Override // was onReplaced + public void onRemove(BlockState state, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { + if (state.getBlock() != newState.getBlock()) { + TileWirelessTransmit tileentity = (TileWirelessTransmit) worldIn.getBlockEntity(pos); + if (tileentity != null) { + for (int i = 0; i < tileentity.inventory.getSlots(); ++i) { + // was InventoryHelper.spawnItemStack + Containers.dropItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), tileentity.inventory.getStackInSlot(i)); + } + } + super.onRemove(state, worldIn, pos, newState, isMoving); + } + } }