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) {
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

View file

@ -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.<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