From 7fc7b4329a57c8260be36ce9c2c240e665596553 Mon Sep 17 00:00:00 2001 From: ALS Date: Fri, 12 Mar 2021 02:01:06 +0100 Subject: [PATCH] Fixed write PlayerHead by a shift+click to get a player head with nbt --- .../server/item/metadata/PlayerHeadMeta.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/minestom/server/item/metadata/PlayerHeadMeta.java b/src/main/java/net/minestom/server/item/metadata/PlayerHeadMeta.java index bfa7e9486..18f1ae07e 100644 --- a/src/main/java/net/minestom/server/item/metadata/PlayerHeadMeta.java +++ b/src/main/java/net/minestom/server/item/metadata/PlayerHeadMeta.java @@ -126,17 +126,20 @@ public class PlayerHeadMeta extends ItemMeta { public void write(@NotNull NBTCompound compound) { NBTCompound skullOwnerCompound = new NBTCompound(); // Sets the identifier for the skull - skullOwnerCompound.setIntArray("Id", Utils.uuidToIntArray(this.skullOwner)); + if (this.skullOwner != null) + skullOwnerCompound.setIntArray("Id", Utils.uuidToIntArray(this.skullOwner)); - if (this.playerSkin == null) { + if (this.playerSkin == null && this.skullOwner != null) { this.playerSkin = PlayerSkin.fromUuid(this.skullOwner.toString()); } - NBTList textures = new NBTList<>(NBTTypes.TAG_Compound); - 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)); + if (this.playerSkin != null) { + NBTList textures = new NBTList<>(NBTTypes.TAG_Compound); + 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);