|
5 | 5 | import generations.gg.generations.core.generationscore.common.world.level.block.entities.CookingPotBlockEntity; |
6 | 6 | import generations.gg.generations.core.generationscore.common.world.level.block.entities.GenerationsBlockEntities; |
7 | 7 | import generations.gg.generations.core.generationscore.common.world.level.block.entities.GenerationsBlockEntityModels; |
| 8 | +import generations.gg.generations.core.generationscore.common.world.level.block.entities.RksMachineBlockEntity; |
8 | 9 | import generations.gg.generations.core.generationscore.common.world.level.block.generic.GenericRotatableModelBlock; |
9 | 10 | import net.minecraft.core.BlockPos; |
10 | 11 | import net.minecraft.core.Direction; |
| 12 | +import net.minecraft.core.NonNullList; |
11 | 13 | import net.minecraft.server.level.ServerPlayer; |
| 14 | +import net.minecraft.world.Containers; |
12 | 15 | import net.minecraft.world.InteractionHand; |
13 | 16 | import net.minecraft.world.InteractionResult; |
14 | 17 | import net.minecraft.world.entity.player.Player; |
| 18 | +import net.minecraft.world.item.ItemStack; |
15 | 19 | import net.minecraft.world.level.BlockGetter; |
16 | 20 | import net.minecraft.world.level.Level; |
17 | 21 | import net.minecraft.world.level.block.BaseEntityBlock; |
@@ -63,6 +67,21 @@ public CookingPotBlock(Properties materialIn) { |
63 | 67 | return InteractionResult.SUCCESS; |
64 | 68 | } |
65 | 69 |
|
| 70 | + @Override |
| 71 | + public void onRemove(BlockState oldState, Level worldIn, BlockPos pos, BlockState newState, boolean isMoving) { |
| 72 | + if (!oldState.is(newState.getBlock())) { |
| 73 | + BlockEntity tileEntity = worldIn.getBlockEntity(pos); |
| 74 | + if (tileEntity instanceof CookingPotBlockEntity machine) { |
| 75 | + final NonNullList<ItemStack> inventory = machine.getContainer().getItems(); |
| 76 | + Containers.dropContents(worldIn, pos, inventory); |
| 77 | + |
| 78 | + worldIn.updateNeighbourForOutputSignal(pos, this); |
| 79 | + } |
| 80 | + } |
| 81 | + super.onRemove(oldState, worldIn, pos, newState, isMoving); |
| 82 | + } |
| 83 | + |
| 84 | + |
66 | 85 | @Nullable |
67 | 86 | @Override |
68 | 87 | public <T extends BlockEntity> BlockEntityTicker<T> getTicker(Level level, @NotNull BlockState state, @NotNull BlockEntityType<T> blockEntityType) { |
|
0 commit comments