[SPIGOT-7314]  ItemStack.isSimilar on Skull with NBT and ItemMeta causing NPE Created: 24/Mar/23  Updated: 25/Dec/24  Resolved: 29/Mar/23

Status: Closed
Project: Spigot
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Bug Priority: Minor
Reporter: RandomHashTags Assignee: Unassigned
Resolution: Won't Fix Votes: 0
Labels: 1.19.2, 1.19.4, NPE, error, spigot
Environment:

Java

openjdk 18.0.1.1 2022-04-22

OpenJDK Runtime Environment (build 18.0.1.1+2-6)

OpenJDK 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)

Language-level: 11

MacOS 13.2.1

Minecraft 1.19.4 Vanilla Client (no mods)

6 plugins on Server

  • PlugMan (2.2.2)
  • Factions (1.6.9.5-U0.5.21-b249)
  • mcMMO (2.1.115)
  • Vault (1.7.2-b107)
  • Essentials (2.17.1.61)
  • RandomPackage (18.0.0)

Attachments: PNG File Screenshot 2023-03-24 at 10.52.23.png     Text File error.txt     Text File item_with_nbt_tags.txt    
Version: CraftBukkit version 3697-Spigot-6ad4b93-9381350 (MC: 1.19.4) (Implementing API version 1.19.4-R0.1-SNAPSHOT)
Plugin: RandomPackage v18.0.0.16
Guidelines Read: Yes

 Description   

I get an NPE (Cannot invoke "net.minecraft.nbt.NBTTagCompound.equals(Object)" because "this.serializedProfile" is null) when I try to compare two ItemStacks where one of them is a Skull with custom NBT tags, custom display name and lore. The actual item and custom NBT tags is attached (raw text from using /data get entity @s SelectedItem).

Referenced RandomPackage line

I cannot replicate the error using a default skull (player, dragon, creeper, skeleton, wither skeleton, or zombie head)

Tested on 1.19.2 and 1.19.4.



 Comments   
Comment by RandomHashTags [ 24/Mar/23 ]

@Jake Potrebic 

That was the problem. Not sure what the exact NBTTagCompound should look like for the `serializedProfile` but modifying it fixed the NPE, thanks! (the exact code on how I create the Skull with a custom texture can be found here, using reflection)

This can be marked as resolved.

 

 

Comment by Jake Potrebic [ 24/Mar/23 ]

How are you creating the ItemStack with the custom skull texture? This can happen if you aren't using the existing API for changing the owner profile on the SkullMeta and instead using reflection to set the `profile` field. If you are using reflection, you need to set both the `profile` and the `serializedProfile` field as the server expects them both to be either null, or both not null.

Generated at Fri Apr 11 15:19:22 UTC 2025 using Jira 10.3.3#10030003-sha1:d220e3fefc8dfc6d47f522d3b9a20c1455e12b7b.