So, I went down the rabbit hole a bit (not deep enough to fix the most important issue though, as I don’t have enough time for that, but maybe just enough for someone from Sponge dev team to pick it up):
The issue with different stack sizes being compared as equal (despite using bySize
comparator) is a one line fix in SpongeItemStackComparatorFactory
in bySize
line 73:
replace return new SpongeItemStackComparatorFactory(this.comparator == null ? comparator : this.comparator.thenComparing(this.comparator));
with return new SpongeItemStackComparatorFactory(this.comparator == null ? comparator : this.comparator.thenComparing(comparator));
The other issue (of items not being compared as the same) is more complicated. Any comparator that uses either byData
or byDurability
(which are also weird btw, as they are exactly the same) is affected, because the values used for comparison probably have wrong hashCode/equals implementation (they compare as different despite being the same):
valueFromValues (hashcode == 336891284) = ImmutableSpongeValue{key=SpongeKey{key=sponge:display_name, elementType=interface net.kyori.adventure.text.Component}, element=TranslatableComponentImpl{key="chat.square_brackets", args=[TextComponentImpl{content="", style=StyleImpl{color=null, obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[TranslatableComponentImpl{key="block.minecraft.dirt", args=[], style=StyleImpl{color=null, obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}]}], style=StyleImpl{color=NamedTextColor{name="white", value="#ffffff"}, obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, clickEvent=null, hoverEvent=HoverEvent{action=show_item, value=ShowItem{item=ResourceLocation{namespace="minecraft", value="dirt"}, count=1, nbt=null}}, insertion=null, font=null}, children=[]}}
value (hashcode == 277145678) = ImmutableSpongeValue{key=SpongeKey{key=sponge:display_name, elementType=interface net.kyori.adventure.text.Component}, element=TranslatableComponentImpl{key="chat.square_brackets", args=[TextComponentImpl{content="", style=StyleImpl{color=null, obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[TranslatableComponentImpl{key="block.minecraft.dirt", args=[], style=StyleImpl{color=null, obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, clickEvent=null, hoverEvent=null, insertion=null, font=null}, children=[]}]}], style=StyleImpl{color=NamedTextColor{name="white", value="#ffffff"}, obfuscated=not_set, bold=not_set, strikethrough=not_set, underlined=not_set, italic=not_set, clickEvent=null, hoverEvent=HoverEvent{action=show_item, value=ShowItem{item=ResourceLocation{namespace="minecraft", value="dirt"}, count=1, nbt=null}}, insertion=null, font=null}, children=[]}}
value.equals(valueFromValues) = false
value.equals(value) = true
valueFromValues.equals(valueFromValues) = true