Skip to content

Commit 53a0ed5

Browse files
committed
Don't try to modify an immutable map
1 parent 26a3261 commit 53a0ed5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

core/src/main/java/org/geysermc/geyser/registry/populator/CustomItemRegistryPopulator.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,14 @@ private static void setupBasicItemInfo(CustomItemDefinition definition, DataComp
464464
// This can be missing if a non-vanilla item didn't specify a max stack size, or if a component patch removed the component. In that case vanilla Minecraft defaults to 1
465465
int stackSize = components.getOrDefault(DataComponentTypes.MAX_STACK_SIZE, 1);
466466

467+
// Hack for v1 compat: Allow e.g. carved pumpkins to continue working as a base
468+
if (stackSize > 1 && definition instanceof GeyserCustomItemDefinition customItemDefinition && customItemDefinition.isOldConvertedItem()) {
469+
Equippable equippable = components.get(DataComponentTypes.EQUIPPABLE);
470+
if (equippable != null) {
471+
stackSize = 1;
472+
}
473+
}
474+
467475
itemProperties.putInt("max_stack_size", stackSize);
468476

469477
// Ignore durability if the item's predicates requires that it be unbreakable

core/src/main/java/org/geysermc/geyser/registry/populator/custom/CustomItemContext.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,8 @@ private static DataComponents checkComponents(CustomItemDefinition definition, I
101101
int maxDamage = components.getOrDefault(DataComponentTypes.MAX_DAMAGE, 0);
102102

103103
if (components.get(DataComponentTypes.EQUIPPABLE) != null && stackSize > 1) {
104-
// V1 compat: forcibly set max stack size to one
105-
if (definition instanceof GeyserCustomItemDefinition geyserCustomItemDefinition && geyserCustomItemDefinition.isOldConvertedItem()) {
106-
components.put(DataComponentTypes.MAX_STACK_SIZE, 1);
107-
} else {
104+
// V1 compat: Allow old items to function; we'll patch in stack size to one later
105+
if (!(definition instanceof GeyserCustomItemDefinition)) {
108106
throw new InvalidItemComponentsException("Bedrock doesn't support equippable items with a stack size above 1");
109107
}
110108
} else if (stackSize > 1 && maxDamage > 0) {

0 commit comments

Comments
 (0)