Skip to content

Commit

Permalink
Revert a change, ensure that gathering all components works and doesn…
Browse files Browse the repository at this point in the history
…'t throw due to duplicate keys
  • Loading branch information
onebeastchris committed Dec 10, 2024
1 parent 06a9b28 commit 8779eab
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,7 @@ protected Tag<Item> getFoodTag() {
public void setBody(ItemStack stack) {
super.setBody(stack);
isCurseOfBinding = ItemUtils.hasEffect(session, stack, EnchantmentComponent.PREVENT_ARMOR_CHANGE);
if (stack != null && stack.getDataComponents() != null) {
repairableItems = stack.getDataComponents().get(DataComponentType.REPAIRABLE);
} else {
repairableItems = null;
}
repairableItems = GeyserItemStack.from(stack).getComponent(DataComponentType.REPAIRABLE);
}

@Override
Expand Down
10 changes: 3 additions & 7 deletions core/src/main/java/org/geysermc/geyser/item/type/Item.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
import org.geysermc.geyser.translator.item.BedrockItemBuilder;
import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.geyser.util.MinecraftKey;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponent;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DyedItemColor;
Expand Down Expand Up @@ -111,12 +110,9 @@ public DataComponents gatherComponents(DataComponents others) {
return baseComponents;
}

//noinspection UnstableApiUsage
var builder = ImmutableMap.<DataComponentType<?>, DataComponent<?, ?>>builderWithExpectedSize(
baseComponents.getDataComponents().size() + others.getDataComponents().size());
builder.putAll(baseComponents.getDataComponents());
builder.putAll(others.getDataComponents());
return new DataComponents(builder.build());
DataComponents components = baseComponents.clone();
components.getDataComponents().putAll(others.getDataComponents());
return new DataComponents(ImmutableMap.copyOf(components.getDataComponents()));
}

@Nullable
Expand Down

0 comments on commit 8779eab

Please sign in to comment.