Revert a change, ensure that gathering all components works and doesn't throw due to duplicate keys

This commit is contained in:
onebeastchris 2024-12-10 20:44:29 +08:00
parent 06a9b2866e
commit 8779eab5e5
2 changed files with 4 additions and 12 deletions

View file

@ -128,11 +128,7 @@ public class WolfEntity extends TameableEntity {
public void setBody(ItemStack stack) { public void setBody(ItemStack stack) {
super.setBody(stack); super.setBody(stack);
isCurseOfBinding = ItemUtils.hasEffect(session, stack, EnchantmentComponent.PREVENT_ARMOR_CHANGE); isCurseOfBinding = ItemUtils.hasEffect(session, stack, EnchantmentComponent.PREVENT_ARMOR_CHANGE);
if (stack != null && stack.getDataComponents() != null) { repairableItems = GeyserItemStack.from(stack).getComponent(DataComponentType.REPAIRABLE);
repairableItems = stack.getDataComponents().get(DataComponentType.REPAIRABLE);
} else {
repairableItems = null;
}
} }
@Override @Override

View file

@ -49,7 +49,6 @@ import org.geysermc.geyser.text.MinecraftLocale;
import org.geysermc.geyser.translator.item.BedrockItemBuilder; import org.geysermc.geyser.translator.item.BedrockItemBuilder;
import org.geysermc.geyser.translator.text.MessageTranslator; import org.geysermc.geyser.translator.text.MessageTranslator;
import org.geysermc.geyser.util.MinecraftKey; 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.DataComponentType;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DataComponents;
import org.geysermc.mcprotocollib.protocol.data.game.item.component.DyedItemColor; import org.geysermc.mcprotocollib.protocol.data.game.item.component.DyedItemColor;
@ -111,12 +110,9 @@ public class Item {
return baseComponents; return baseComponents;
} }
//noinspection UnstableApiUsage DataComponents components = baseComponents.clone();
var builder = ImmutableMap.<DataComponentType<?>, DataComponent<?, ?>>builderWithExpectedSize( components.getDataComponents().putAll(others.getDataComponents());
baseComponents.getDataComponents().size() + others.getDataComponents().size()); return new DataComponents(ImmutableMap.copyOf(components.getDataComponents()));
builder.putAll(baseComponents.getDataComponents());
builder.putAll(others.getDataComponents());
return new DataComponents(builder.build());
} }
@Nullable @Nullable