Skip to content

Commit

Permalink
Fixed #2403
Browse files Browse the repository at this point in the history
- Added the onRemove method to the Wireless Transmitter
  • Loading branch information
PocketSizedWeeb committed Apr 19, 2024
1 parent ba04e8a commit a681f80
Showing 1 changed file with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -44,4 +45,18 @@ public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level world, Block
protected void createBlockStateDefinition(StateDefinition.Builder<Block, BlockState> 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);
}
}
}

0 comments on commit a681f80

Please sign in to comment.