EngineHub / CraftBook

🔧 Machines, ICs, PLCs, and more!
https://enginehub.org/craftbook/
GNU General Public License v3.0
301 stars 160 forks source link

Custom Heads from HeadDrops *sometimes* do not stack #1238

Closed tejashah88 closed 3 years ago

tejashah88 commented 3 years ago

Versions

CraftBook version: 3.10.2 Bukkit version: git-Paper-253 (MC: 1.16.3)

Describe the bug Sometimes the heads dropped from mobs do not stack. Initially it seemed random since I'd have a half stack of Enderman heads and another 3/4ths stack of the same mob that won't mix with each other.

image

However, when I took a closer look at the NBT data (wiki reference) on the heads, I noticed that after decoding the base64-encoded JSON value from the Value field, the only thing that makes the heads different from each other is the timestamp field, which is optional according to the wiki. Additionally, the Signature fields were also different.

For example, I chose two stacks at random and parsed through the NBT data and got the following two JSON values from the Value field: 1.

When looking at the timestamps, they translated to 2020-12-11 19:02:00 and 2020-10-22 05:19:12 respectively. It seems that the timestamp is generated based on "roughly" when a player kills a mob, but it's no more than a guess. My recommendation would be to delete the timestamp from the Value field and the Signature field since they are optional.

To Reproduce

  1. Kill a lot of mobs of the same type over a long period of time.
  2. Check the NBT data with /data get entity [playername] Inventory or a similar command

Expected behavior All mobs heads from a single mob should consistently stack.

me4502 commented 3 years ago

This is a bug in the way Spigot handles head items.

This is already resolved in CraftBook 5 by using the Paper API.