From 8779eab5e5e11a781dd04e558744aff3f9228bb1 Mon Sep 17 00:00:00 2001 From: onebeastchris Date: Tue, 10 Dec 2024 20:44:29 +0800 Subject: [PATCH] Revert a change, ensure that gathering all components works and doesn't throw due to duplicate keys --- .../entity/type/living/animal/tameable/WolfEntity.java | 6 +----- .../main/java/org/geysermc/geyser/item/type/Item.java | 10 +++------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java index ff2d57aef..1b06f3860 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/living/animal/tameable/WolfEntity.java @@ -128,11 +128,7 @@ public class WolfEntity extends TameableEntity { 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 diff --git a/core/src/main/java/org/geysermc/geyser/item/type/Item.java b/core/src/main/java/org/geysermc/geyser/item/type/Item.java index 51750e7b1..c5dff3ad0 100644 --- a/core/src/main/java/org/geysermc/geyser/item/type/Item.java +++ b/core/src/main/java/org/geysermc/geyser/item/type/Item.java @@ -49,7 +49,6 @@ import org.geysermc.geyser.text.MinecraftLocale; 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; @@ -111,12 +110,9 @@ public class Item { return baseComponents; } - //noinspection UnstableApiUsage - var builder = ImmutableMap., 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