mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-08 00:11:34 +01:00
Merge pull request #141 from MrBretze/master
Fixed somme read for NBT Tag to ItemStack
This commit is contained in:
commit
60385c0887
@ -1,6 +1,5 @@
|
||||
package net.minestom.server.item.metadata;
|
||||
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.entity.Player;
|
||||
import net.minestom.server.entity.PlayerSkin;
|
||||
import net.minestom.server.utils.Utils;
|
||||
@ -118,7 +117,6 @@ public class PlayerHeadMeta extends ItemMeta {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -135,7 +133,9 @@ public class PlayerHeadMeta extends ItemMeta {
|
||||
}
|
||||
|
||||
NBTList<NBTCompound> textures = new NBTList<>(NBTTypes.TAG_Compound);
|
||||
textures.add(new NBTCompound().setString("Value", this.playerSkin.getTextures()).setString("Signature", this.playerSkin.getSignature()));
|
||||
String value = this.playerSkin.getTextures() == null ? "" : this.playerSkin.getTextures();
|
||||
String signature = this.playerSkin.getSignature() == null ? "" : this.playerSkin.getSignature();
|
||||
textures.add(new NBTCompound().setString("Value", value).setString("Signature", signature));
|
||||
skullOwnerCompound.set("Properties", new NBTCompound().set("textures", textures));
|
||||
|
||||
compound.set("SkullOwner", skullOwnerCompound);
|
||||
|
@ -5,6 +5,7 @@ import net.minestom.server.potion.CustomPotionEffect;
|
||||
import net.minestom.server.potion.PotionType;
|
||||
import net.minestom.server.registry.Registries;
|
||||
import net.minestom.server.utils.clone.CloneUtils;
|
||||
import net.minestom.server.utils.time.TimeUnit;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
@ -109,10 +110,10 @@ public class PotionMeta extends ItemMeta {
|
||||
for (NBTCompound potionCompound : customEffectList) {
|
||||
final byte id = potionCompound.getAsByte("Id");
|
||||
final byte amplifier = potionCompound.getAsByte("Amplifier");
|
||||
final int duration = potionCompound.getAsInt("Duration");
|
||||
final boolean ambient = potionCompound.getAsByte("Ambient") == 1;
|
||||
final boolean showParticles = potionCompound.getAsByte("ShowParticles") == 1;
|
||||
final boolean showIcon = potionCompound.getAsByte("ShowIcon") == 1;
|
||||
final int duration = potionCompound.containsKey("Duration") ? potionCompound.getNumber("Duration").intValue() : (int) TimeUnit.SECOND.toMilliseconds(30);
|
||||
final boolean ambient = potionCompound.containsKey("Ambient") ? potionCompound.getAsByte("Ambient") == 1 : false;
|
||||
final boolean showParticles = potionCompound.containsKey("ShowParticles") ? potionCompound.getAsByte("ShowParticles") == 1 : true;
|
||||
final boolean showIcon = potionCompound.containsKey("ShowIcon") ? potionCompound.getAsByte("ShowIcon") == 1 : true;
|
||||
|
||||
this.customPotionEffects.add(
|
||||
new CustomPotionEffect(id, amplifier, duration, ambient, showParticles, showIcon));
|
||||
|
@ -126,7 +126,7 @@ public final class NBTUtils {
|
||||
|
||||
public static void loadDataIntoItem(@NotNull ItemStack item, @NotNull NBTCompound nbt) {
|
||||
if (nbt.containsKey("Damage")) item.setDamage(nbt.getInt("Damage"));
|
||||
if (nbt.containsKey("Unbreakable")) item.setUnbreakable(nbt.getInt("Unbreakable") == 1);
|
||||
if (nbt.containsKey("Unbreakable")) item.setUnbreakable(nbt.getAsByte("Unbreakable") == 1);
|
||||
if (nbt.containsKey("HideFlags")) item.setHideFlag(nbt.getInt("HideFlags"));
|
||||
if (nbt.containsKey("display")) {
|
||||
final NBTCompound display = nbt.getCompound("display");
|
||||
@ -159,10 +159,11 @@ public final class NBTUtils {
|
||||
final int[] uuidArray = attributeNBT.getIntArray("UUID");
|
||||
uuid = Utils.intArrayToUuid(uuidArray);
|
||||
}
|
||||
final double value = attributeNBT.getDouble("Amount");
|
||||
final String slot = attributeNBT.getString("Slot");
|
||||
|
||||
final double value = attributeNBT.getAsDouble("Amount");
|
||||
final String slot = attributeNBT.containsKey("Slot") ? attributeNBT.getString("Slot") : "MAINHAND";
|
||||
final String attributeName = attributeNBT.getString("AttributeName");
|
||||
final int operation = attributeNBT.getInt("Operation");
|
||||
final int operation = attributeNBT.getAsInt("Operation");
|
||||
final String name = attributeNBT.getString("Name");
|
||||
|
||||
final Attribute attribute = Attribute.fromKey(attributeName);
|
||||
@ -174,11 +175,12 @@ public final class NBTUtils {
|
||||
if (attributeOperation == null) {
|
||||
break;
|
||||
}
|
||||
final AttributeSlot attributeSlot = AttributeSlot.valueOf(slot.toUpperCase());
|
||||
|
||||
AttributeSlot attributeSlot = AttributeSlot.valueOf(slot.toUpperCase());
|
||||
// Wrong attribute slot, stop here
|
||||
if (attributeSlot == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (attributeSlot == null)
|
||||
attributeSlot = AttributeSlot.MAINHAND;
|
||||
|
||||
// Add attribute
|
||||
final ItemAttribute itemAttribute =
|
||||
|
Loading…
Reference in New Issue
Block a user