Skip to content

Commit f7272c7

Browse files
committed
fix: support 1.20
1 parent c9599c5 commit f7272c7

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

src/main/java/pt/supercrafting/menu/MenuClickProcessor.java

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,40 @@ final class MenuClickProcessor {
2626
private static final IntList PLAYER_INVENTORY_SLOTS;
2727
private static final IntList REVERSED_PLAYER_INVENTORY_SLOTS;
2828

29-
private static final Set<InventoryAction> DEFAULT_BEHAVIORS = Set.of(
30-
InventoryAction.NOTHING,
31-
InventoryAction.PICKUP_ALL,
32-
InventoryAction.PICKUP_ALL_INTO_BUNDLE,
33-
InventoryAction.PICKUP_HALF,
34-
InventoryAction.PICKUP_ONE,
35-
InventoryAction.PICKUP_SOME,
36-
InventoryAction.PICKUP_SOME_INTO_BUNDLE,
37-
InventoryAction.PLACE_ALL,
38-
InventoryAction.PLACE_ALL_INTO_BUNDLE,
39-
InventoryAction.PLACE_ONE,
40-
InventoryAction.PLACE_SOME,
41-
InventoryAction.PLACE_SOME_INTO_BUNDLE,
42-
InventoryAction.HOTBAR_SWAP,
43-
InventoryAction.SWAP_WITH_CURSOR
44-
);
29+
private static final Set<InventoryAction> DEFAULT_BEHAVIORS;
4530

4631
static {
4732

33+
boolean hasBundleActions;
34+
try {
35+
InventoryAction.valueOf("PICKUP_ALL_INTO_BUNDLE");
36+
hasBundleActions = true;
37+
} catch (Exception e){
38+
hasBundleActions = false;
39+
}
40+
41+
Set<InventoryAction> defaultBehaviors = new HashSet<>(Arrays.asList(
42+
InventoryAction.NOTHING,
43+
InventoryAction.PICKUP_ALL,
44+
InventoryAction.PICKUP_HALF,
45+
InventoryAction.PICKUP_ONE,
46+
InventoryAction.PICKUP_SOME,
47+
InventoryAction.PLACE_ALL,
48+
InventoryAction.PLACE_ONE,
49+
InventoryAction.PLACE_SOME,
50+
InventoryAction.HOTBAR_SWAP,
51+
InventoryAction.SWAP_WITH_CURSOR
52+
));
53+
54+
if(hasBundleActions) {
55+
defaultBehaviors.add(InventoryAction.PICKUP_ALL_INTO_BUNDLE);
56+
defaultBehaviors.add(InventoryAction.PLACE_ALL_INTO_BUNDLE);
57+
defaultBehaviors.add(InventoryAction.PICKUP_SOME_INTO_BUNDLE);
58+
defaultBehaviors.add(InventoryAction.PLACE_SOME_INTO_BUNDLE);
59+
}
60+
61+
DEFAULT_BEHAVIORS = Collections.unmodifiableSet(defaultBehaviors);
62+
4863
IntList prioritySlots = new IntArrayList(9 * 4);
4964
// First 9 slots are the hotbar
5065
for (int i = 8; i >= 0; i--)

0 commit comments

Comments
 (0)