mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 01:17:47 +01:00
Fix item attributes not being read correctly (#1806)
This commit is contained in:
parent
ec8034750a
commit
9abb3079f6
@ -57,7 +57,7 @@ public final class ItemSerializers {
|
|||||||
final int operation = reader.getTag(OPERATION);
|
final int operation = reader.getTag(OPERATION);
|
||||||
final String name = reader.getTag(NAME);
|
final String name = reader.getTag(NAME);
|
||||||
|
|
||||||
final Attribute attribute = Attribute.fromKey(attributeName.toUpperCase(Locale.ROOT));
|
final Attribute attribute = Attribute.fromKey(attributeName.toLowerCase(Locale.ROOT));
|
||||||
// Wrong attribute name, stop here
|
// Wrong attribute name, stop here
|
||||||
if (attribute == null) return null;
|
if (attribute == null) return null;
|
||||||
final AttributeOperation attributeOperation = AttributeOperation.fromId(operation);
|
final AttributeOperation attributeOperation = AttributeOperation.fromId(operation);
|
||||||
|
@ -4,6 +4,10 @@ import net.minestom.server.attribute.Attribute;
|
|||||||
import net.minestom.server.attribute.AttributeOperation;
|
import net.minestom.server.attribute.AttributeOperation;
|
||||||
import net.minestom.server.item.attribute.AttributeSlot;
|
import net.minestom.server.item.attribute.AttributeSlot;
|
||||||
import net.minestom.server.item.attribute.ItemAttribute;
|
import net.minestom.server.item.attribute.ItemAttribute;
|
||||||
|
import net.minestom.server.tag.TagHandler;
|
||||||
|
import net.minestom.server.tag.TagWritable;
|
||||||
|
import org.jglrxavpok.hephaistos.nbt.NBT;
|
||||||
|
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -25,6 +29,19 @@ public class ItemAttributeTest {
|
|||||||
assertEquals(attributes, item.meta().getAttributes());
|
assertEquals(attributes, item.meta().getAttributes());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void attributeReader() {
|
||||||
|
var attributes = List.of(new ItemAttribute(
|
||||||
|
new UUID(0, 0), "generic.attack_damage", Attribute.ATTACK_DAMAGE,
|
||||||
|
AttributeOperation.ADDITION, 2, AttributeSlot.MAINHAND));
|
||||||
|
|
||||||
|
TagHandler handler = TagHandler.newHandler();
|
||||||
|
handler.setTag(ItemTags.ATTRIBUTES, attributes);
|
||||||
|
var item = ItemStack.fromNBT(Material.STICK, handler.asCompound());
|
||||||
|
|
||||||
|
assertEquals(attributes, item.meta().getAttributes());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void attributeNbt() {
|
public void attributeNbt() {
|
||||||
var item = ItemStack.builder(Material.STICK)
|
var item = ItemStack.builder(Material.STICK)
|
||||||
|
Loading…
Reference in New Issue
Block a user