|
1 | 1 | --- a/net/minecraft/world/level/block/ChestBlock.java |
2 | 2 | +++ b/net/minecraft/world/level/block/ChestBlock.java |
3 | | -@@ -50,8 +_,9 @@ |
| 3 | +@@ -2,11 +_,13 @@ |
| 4 | + |
| 5 | + import com.mojang.serialization.MapCodec; |
| 6 | + import it.unimi.dsi.fastutil.floats.Float2FloatFunction; |
| 7 | ++ |
| 8 | + import java.util.List; |
| 9 | + import java.util.Optional; |
| 10 | + import java.util.function.BiPredicate; |
| 11 | + import java.util.function.Supplier; |
| 12 | + import javax.annotation.Nullable; |
| 13 | ++ |
| 14 | + import net.minecraft.core.BlockPos; |
| 15 | + import net.minecraft.core.Direction; |
| 16 | + import net.minecraft.network.chat.Component; |
| 17 | +@@ -50,8 +_,11 @@ |
4 | 18 | import net.minecraft.world.phys.BlockHitResult; |
5 | 19 | import net.minecraft.world.phys.shapes.CollisionContext; |
6 | 20 | import net.minecraft.world.phys.shapes.VoxelShape; |
| 21 | ++import org.bukkit.inventory.PlayerInventory; |
7 | 22 | +import org.taiyitistmc.injection.world.level.block.InjectionChestBlock; |
| 23 | ++import org.taiyitistmc.injection.world.level.block.InjectionChestBlockDoubleInventory; |
8 | 24 |
|
9 | 25 | -public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock { |
10 | 26 | +public class ChestBlock extends AbstractChestBlock<ChestBlockEntity> implements SimpleWaterloggedBlock, InjectionChestBlock { |
11 | 27 | public static final MapCodec<ChestBlock> CODEC = simpleCodec(p_304364_ -> new ChestBlock(p_304364_, () -> BlockEntityType.CHEST)); |
12 | 28 | public static final DirectionProperty FACING = HorizontalDirectionalBlock.FACING; |
13 | 29 | public static final EnumProperty<ChestType> TYPE = BlockStateProperties.CHEST_TYPE; |
| 30 | +@@ -98,7 +_,7 @@ |
| 31 | + if (p_51604_.hasCustomName()) { |
| 32 | + return p_51604_.getDisplayName(); |
| 33 | + } else { |
| 34 | +- return (Component)(p_51605_.hasCustomName() ? p_51605_.getDisplayName() : Component.translatable("container.chestDouble")); |
| 35 | ++ return (Component) (p_51605_.hasCustomName() ? p_51605_.getDisplayName() : Component.translatable("container.chestDouble")); |
| 36 | + } |
| 37 | + } |
| 38 | + }); |
| 39 | +@@ -121,7 +_,7 @@ |
| 40 | + public ChestBlock(BlockBehaviour.Properties p_51490_, Supplier<BlockEntityType<? extends ChestBlockEntity>> p_51491_) { |
| 41 | + super(p_51490_, p_51491_); |
| 42 | + this.registerDefaultState( |
| 43 | +- this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(TYPE, ChestType.SINGLE).setValue(WATERLOGGED, Boolean.valueOf(false)) |
| 44 | ++ this.stateDefinition.any().setValue(FACING, Direction.NORTH).setValue(TYPE, ChestType.SINGLE).setValue(WATERLOGGED, Boolean.valueOf(false)) |
| 45 | + ); |
| 46 | + } |
| 47 | + |
| 48 | +@@ -148,9 +_,9 @@ |
| 49 | + if (p_51557_.is(this) && p_51556_.getAxis().isHorizontal()) { |
| 50 | + ChestType chesttype = p_51557_.getValue(TYPE); |
| 51 | + if (p_51555_.getValue(TYPE) == ChestType.SINGLE |
| 52 | +- && chesttype != ChestType.SINGLE |
| 53 | +- && p_51555_.getValue(FACING) == p_51557_.getValue(FACING) |
| 54 | +- && getConnectedDirection(p_51557_) == p_51556_.getOpposite()) { |
| 55 | ++ && chesttype != ChestType.SINGLE |
| 56 | ++ && p_51555_.getValue(FACING) == p_51557_.getValue(FACING) |
| 57 | ++ && getConnectedDirection(p_51557_) == p_51556_.getOpposite()) { |
| 58 | + return p_51555_.setValue(TYPE, chesttype.getOpposite()); |
| 59 | + } |
| 60 | + } else if (getConnectedDirection(p_51555_) == p_51556_) { |
| 61 | +@@ -208,9 +_,9 @@ |
| 62 | + } |
| 63 | + |
| 64 | + return this.defaultBlockState() |
| 65 | +- .setValue(FACING, direction) |
| 66 | +- .setValue(TYPE, chesttype) |
| 67 | +- .setValue(WATERLOGGED, Boolean.valueOf(fluidstate.getType() == Fluids.WATER)); |
| 68 | ++ .setValue(FACING, direction) |
| 69 | ++ .setValue(TYPE, chesttype) |
| 70 | ++ .setValue(WATERLOGGED, Boolean.valueOf(fluidstate.getType() == Fluids.WATER)); |
| 71 | + } |
| 72 | + |
| 73 | + @Override |
| 74 | +@@ -261,7 +_,7 @@ |
| 75 | + |
| 76 | + @Override |
| 77 | + public DoubleBlockCombiner.NeighborCombineResult<? extends ChestBlockEntity> combine( |
| 78 | +- BlockState p_51544_, Level p_51545_, BlockPos p_51546_, boolean p_51547_ |
| 79 | ++ BlockState p_51544_, Level p_51545_, BlockPos p_51546_, boolean p_51547_ |
| 80 | + ) { |
| 81 | + BiPredicate<LevelAccessor, BlockPos> bipredicate; |
| 82 | + if (p_51547_) { |
| 83 | +@@ -271,7 +_,7 @@ |
| 84 | + } |
| 85 | + |
| 86 | + return DoubleBlockCombiner.combineWithNeigbour( |
| 87 | +- this.blockEntityType.get(), ChestBlock::getBlockType, ChestBlock::getConnectedDirection, FACING, p_51544_, p_51545_, p_51546_, bipredicate |
| 88 | ++ this.blockEntityType.get(), ChestBlock::getBlockType, ChestBlock::getConnectedDirection, FACING, p_51544_, p_51545_, p_51546_, bipredicate |
| 89 | + ); |
| 90 | + } |
| 91 | + |
| 92 | +@@ -319,15 +_,15 @@ |
| 93 | + |
| 94 | + private static boolean isCatSittingOnChest(LevelAccessor p_51564_, BlockPos p_51565_) { |
| 95 | + List<Cat> list = p_51564_.getEntitiesOfClass( |
| 96 | +- Cat.class, |
| 97 | +- new AABB( |
| 98 | +- (double)p_51565_.getX(), |
| 99 | +- (double)(p_51565_.getY() + 1), |
| 100 | +- (double)p_51565_.getZ(), |
| 101 | +- (double)(p_51565_.getX() + 1), |
| 102 | +- (double)(p_51565_.getY() + 2), |
| 103 | +- (double)(p_51565_.getZ() + 1) |
| 104 | +- ) |
| 105 | ++ Cat.class, |
| 106 | ++ new AABB( |
| 107 | ++ (double) p_51565_.getX(), |
| 108 | ++ (double) (p_51565_.getY() + 1), |
| 109 | ++ (double) p_51565_.getZ(), |
| 110 | ++ (double) (p_51565_.getX() + 1), |
| 111 | ++ (double) (p_51565_.getY() + 2), |
| 112 | ++ (double) (p_51565_.getZ() + 1) |
| 113 | ++ ) |
| 114 | + ); |
| 115 | + if (!list.isEmpty()) { |
| 116 | + for (Cat cat : list) { |
14 | 117 | @@ -357,7 +_,8 @@ |
15 | 118 |
|
16 | 119 | @Override |
|
21 | 124 | } |
22 | 125 |
|
23 | 126 | @Override |
| 127 | +@@ -374,7 +_,26 @@ |
| 128 | + protected void tick(BlockState p_220958_, ServerLevel p_220959_, BlockPos p_220960_, RandomSource p_220961_) { |
| 129 | + BlockEntity blockentity = p_220959_.getBlockEntity(p_220960_); |
| 130 | + if (blockentity instanceof ChestBlockEntity) { |
| 131 | +- ((ChestBlockEntity)blockentity).recheckOpen(); |
| 132 | +- } |
| 133 | +- } |
| 134 | ++ ((ChestBlockEntity) blockentity).recheckOpen(); |
| 135 | ++ } |
| 136 | ++ } |
| 137 | ++ |
| 138 | ++ // CraftBukkit start |
| 139 | ++ public static class DoubleInventory implements MenuProvider, InjectionChestBlockDoubleInventory { |
| 140 | ++ |
| 141 | ++ private final ChestBlockEntity tileentitychest; |
| 142 | ++ |
| 143 | ++ private final ChestBlockEntity tileentitychest1; |
| 144 | ++ |
| 145 | ++ public final CompoundContainer inventorylargechest; |
| 146 | ++ |
| 147 | ++ public DoubleInventory(ChestBlockEntity tileentitychest, ChestBlockEntity tileentitychest1, CompoundContainer inventorylargechest) { |
| 148 | ++ this.tileentitychest = tileentitychest; |
| 149 | ++ this.tileentitychest1 = tileentitychest1; |
| 150 | ++ this.inventorylargechest = inventorylargechest; |
| 151 | ++ |
| 152 | ++ } |
| 153 | ++ |
| 154 | ++ } |
| 155 | ++ // CraftBukkit end |
| 156 | + } |
0 commit comments