|
8 | 8 | import de.dafuqs.lootcrates.blocks.LootCrateBlockEntity;
|
9 | 9 | import de.dafuqs.lootcrates.blocks.LootCratesBlockEntityType;
|
10 | 10 | import net.minecraft.block.BarrelBlock;
|
11 |
| -import net.minecraft.block.Block; |
12 | 11 | import net.minecraft.block.BlockState;
|
13 |
| -import net.minecraft.block.entity.BarrelBlockEntity; |
14 | 12 | import net.minecraft.block.entity.BlockEntityType;
|
15 |
| -import net.minecraft.block.entity.ChestLidAnimator; |
16 |
| -import net.minecraft.block.entity.ChestStateManager; |
17 |
| -import net.minecraft.client.block.ChestAnimationProgress; |
| 13 | +import net.minecraft.block.entity.ViewerCountManager; |
18 | 14 | import net.minecraft.entity.player.PlayerEntity;
|
19 | 15 | import net.minecraft.entity.player.PlayerInventory;
|
20 | 16 | import net.minecraft.inventory.Inventory;
|
21 | 17 | import net.minecraft.item.ItemStack;
|
22 | 18 | import net.minecraft.screen.GenericContainerScreenHandler;
|
23 | 19 | import net.minecraft.screen.ScreenHandler;
|
24 | 20 | import net.minecraft.sound.SoundEvents;
|
25 |
| -import net.minecraft.text.Text; |
26 |
| -import net.minecraft.text.TranslatableText; |
27 | 21 | import net.minecraft.util.collection.DefaultedList;
|
28 | 22 | import net.minecraft.util.math.BlockPos;
|
29 | 23 | import net.minecraft.world.BlockView;
|
30 | 24 | import net.minecraft.world.World;
|
31 | 25 |
|
32 | 26 | public class LootBarrelBlockEntity extends LootCrateBlockEntity {
|
33 | 27 |
|
34 |
| - private final ChestStateManager stateManager; |
| 28 | + private final ViewerCountManager stateManager; |
35 | 29 |
|
36 | 30 | public LootBarrelBlockEntity(BlockEntityType<?> blockEntityType, BlockPos blockPos, BlockState blockState) {
|
37 | 31 | super(blockEntityType, blockPos, blockState);
|
38 | 32 |
|
39 | 33 | this.inventory = DefaultedList.ofSize(27, ItemStack.EMPTY);
|
40 |
| - this.stateManager = new ChestStateManager() { |
41 |
| - protected void onChestOpened(World world, BlockPos pos, BlockState state) { |
| 34 | + this.stateManager = new ViewerCountManager() { |
| 35 | + protected void onContainerOpen(World world, BlockPos pos, BlockState state) { |
42 | 36 | playSound(world, pos, state, SoundEvents.BLOCK_BARREL_OPEN);
|
43 | 37 | setOpen(state, true);
|
44 | 38 | }
|
45 | 39 |
|
46 |
| - protected void onChestClosed(World world, BlockPos pos, BlockState state) { |
| 40 | + protected void onContainerClose(World world, BlockPos pos, BlockState state) { |
47 | 41 | playSound(world, pos, state, SoundEvents.BLOCK_BARREL_CLOSE);
|
48 | 42 | setOpen(state, false);
|
49 | 43 | }
|
50 | 44 |
|
51 |
| - protected void onInteracted(World world, BlockPos pos, BlockState state, int oldViewerCount, int newViewerCount) { |
| 45 | + protected void onViewerCountUpdate(World world, BlockPos pos, BlockState state, int oldViewerCount, int newViewerCount) { |
52 | 46 | onInvOpenOrClose(world, pos, state, oldViewerCount, newViewerCount);
|
53 | 47 | }
|
54 | 48 |
|
@@ -94,14 +88,14 @@ protected ScreenHandler createScreenHandler(int syncId, PlayerInventory playerIn
|
94 | 88 | @Override
|
95 | 89 | public void onOpen(PlayerEntity player) {
|
96 | 90 | if (!this.removed && !player.isSpectator()) {
|
97 |
| - this.stateManager.openChest(player, this.getWorld(), this.getPos(), this.getCachedState()); |
| 91 | + this.stateManager.openContainer(player, this.getWorld(), this.getPos(), this.getCachedState()); |
98 | 92 | }
|
99 | 93 | }
|
100 | 94 |
|
101 | 95 | @Override
|
102 | 96 | public void onClose(PlayerEntity player) {
|
103 | 97 | if (!this.removed && !player.isSpectator()) {
|
104 |
| - this.stateManager.closeChest(player, this.getWorld(), this.getPos(), this.getCachedState()); |
| 98 | + this.stateManager.closeContainer(player, this.getWorld(), this.getPos(), this.getCachedState()); |
105 | 99 | }
|
106 | 100 | }
|
107 | 101 |
|
|
0 commit comments