Fix ATTRIBUTE_MODIFIERS item component

This commit is contained in:
basaigh 2024-06-14 21:24:50 +01:00
parent 138ab2cd1f
commit dcf9d02d3a
2 changed files with 5 additions and 8 deletions

View file

@ -2,10 +2,10 @@ package org.geysermc.mcprotocollib.protocol.data.game.item.component;
import lombok.AllArgsConstructor;
import lombok.Data;
import net.kyori.adventure.key.Key;
import org.geysermc.mcprotocollib.protocol.data.game.entity.attribute.ModifierOperation;
import java.util.List;
import java.util.UUID;
@Data
@AllArgsConstructor
@ -24,8 +24,7 @@ public class ItemAttributeModifiers {
@Data
@AllArgsConstructor
public static class AttributeModifier {
private final UUID id;
private final String name;
private final Key id;
private final double amount;
private final ModifierOperation operation;
}

View file

@ -174,11 +174,10 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
List<ItemAttributeModifiers.Entry> modifiers = this.readList(buf, (input) -> {
int attribute = this.readVarInt(input);
UUID id = this.readUUID(input);
String name = this.readString(input);
Key id = this.readResourceLocation(input);
double amount = input.readDouble();
ModifierOperation operation = ModifierOperation.from(this.readVarInt(input));
ItemAttributeModifiers.AttributeModifier modifier = new ItemAttributeModifiers.AttributeModifier(id, name, amount, operation);
ItemAttributeModifiers.AttributeModifier modifier = new ItemAttributeModifiers.AttributeModifier(id, amount, operation);
ItemAttributeModifiers.EquipmentSlotGroup slot = ItemAttributeModifiers.EquipmentSlotGroup.from(this.readVarInt(input));
return new ItemAttributeModifiers.Entry(attribute, modifier, slot);
@ -190,8 +189,7 @@ public class ItemCodecHelper extends MinecraftCodecHelper {
public void writeItemAttributeModifiers(ByteBuf buf, ItemAttributeModifiers modifiers) {
this.writeList(buf, modifiers.getModifiers(), (output, entry) -> {
this.writeVarInt(output, entry.getAttribute());
this.writeUUID(output, entry.getModifier().getId());
this.writeString(output, entry.getModifier().getName());
this.writeResourceLocation(output, entry.getModifier().getId());
output.writeDouble(entry.getModifier().getAmount());
this.writeVarInt(output, entry.getModifier().getOperation().ordinal());
this.writeVarInt(output, entry.getSlot().ordinal());