Skip to content

Commit 40787e5

Browse files
committed
chestk block patches
1 parent e1fc907 commit 40787e5

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

patches/net/minecraft/world/level/block/ChestBlock.java.patch

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,45 @@
11
--- a/net/minecraft/world/level/block/ChestBlock.java
22
+++ b/net/minecraft/world/level/block/ChestBlock.java
3+
@@ -90,10 +_,27 @@
4+
return Optional.empty();
5+
}
6+
};
7+
- public static final DoubleBlockCombiner.Combiner<ChestBlockEntity, Optional<MenuProvider>> MENU_PROVIDER_COMBINER = new DoubleBlockCombiner.Combiner<ChestBlockEntity, Optional<MenuProvider>>() {
8+
+ public static final DoubleBlockCombiner.Combiner<ChestBlockEntity, Optional<MenuProvider>> MENU_PROVIDER_COMBINER = new DoubleChestCombiner();
9+
+
10+
+ public static class DoubleChestCombiner implements DoubleBlockCombiner.Combiner<ChestBlockEntity, Optional<MenuProvider>> {
11+
public Optional<MenuProvider> acceptDouble(ChestBlockEntity first, ChestBlockEntity second) {
12+
- final Container container = new CompoundContainer(first, second);
13+
- return Optional.of(new MenuProvider() {
14+
+ final CompoundContainer container = new CompoundContainer(first, second);
15+
+ return Optional.of(new Dummy.DoubleInventory(first, second, container));
16+
+ }
17+
+
18+
+ public static class Dummy {
19+
+ public static class DoubleInventory implements MenuProvider {
20+
+
21+
+ private final ChestBlockEntity first;
22+
+ private final ChestBlockEntity second;
23+
+ public final CompoundContainer container;
24+
+
25+
+ public DoubleInventory(ChestBlockEntity first, ChestBlockEntity second, CompoundContainer container) {
26+
+ this.first = first;
27+
+ this.second = second;
28+
+ this.container = container;
29+
+ }
30+
+ // CraftBukkit end
31+
@Override
32+
public @Nullable AbstractContainerMenu createMenu(int containerId, Inventory inventory, Player player) {
33+
if (first.canOpen(player) && second.canOpen(player)) {
34+
@@ -117,7 +_,7 @@
35+
return second.hasCustomName() ? second.getDisplayName() : Component.translatable("container.chestDouble");
36+
}
37+
}
38+
- });
39+
+ };
40+
}
41+
42+
public Optional<MenuProvider> acceptSingle(ChestBlockEntity single) {
343
@@ -364,7 +_,8 @@
444

545
@Override

0 commit comments

Comments
 (0)