[SPIGOT-7654] ItemStack#isSimilar does not work with empty BlockStateMeta Created: 02/May/24  Updated: 25/Dec/24  Resolved: 02/May/24

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

Type: Bug Priority: Minor
Reporter: David Lüdtke Assignee: Unassigned
Resolution: Fixed Votes: 0
Labels: None
Environment:

doesn't matter


Attachments: PNG File image-2024-05-02-03-26-53-933.png    
Version: 1.20.6
Plugin: https://pastebin.com/juP2u7Wd
Guidelines Read: Yes

 Description   

Some calls to ItemStack#isSimilar returning false, although the item should be the same.

I've only tested this scenario, where a ItemStack#isSimilar compares two items from clicking inside an inventory. After checking what's causing this, it looks like the CraftMetaBlockState is checking the blockEntityTag of both metas and they are different. Not sure, what's exactly the cause of this issue, but I belive it's not wanted, as the code worked in 1.20.4.

 

Code: https://pastebin.com/juP2u7Wd

Me, trying to figure out, what's wrong:

 

Expected Behaviour: The two items should be the same (isSimilar = true, console output = true)

Observed Beahviour (1.20.6): The two items appear to be not the same (isSimilar = false, console output = false)


Generated at Sat Dec 13 13:35:58 UTC 2025 using Jira 10.3.13#10030013-sha1:56dd970ae30ebfeda3a697d25be1f6388b68a422.