[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
|
Attachments: |
![]() ![]() ![]() |
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). 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. |