SpongePowered / Sponge

The SpongeAPI implementation targeting vanilla Minecraft and 3rd party platforms.
MIT License
383 stars 211 forks source link

ItemStackComparators.IGNORE_SIZE not working #3991

Closed tyhdefu closed 2 months ago

tyhdefu commented 5 months ago

Affected Product(s)

SpongeVanilla

Version

1.16.5-8.2.0-SNAPSHOT

Operating System

Windows

Java Version

17

Plugins/Mods

Just the affected plugin.

Describe the bug

I would expect that this method always returns the same as the sponge implementation, but it seems to always return -1.

public static Predicate<ItemStack> ignoreSizeFilter(ItemStack item) {
    ItemStack item1 = item.copy();
    item1.setQuantity(1);
    return i -> {
        ItemStack iCopy = i.copy();
        iCopy.setQuantity(1);
        boolean ourResult = iCopy.equalTo(item1);
        boolean theirResult = ItemStackComparators.IGNORE_SIZE.get().compare(item, i) == 0;
        System.out.println("Our result: " + ourResult + ", theirResult: " + theirResult);
        System.out.println("Compare self: " + ItemStackComparators.IGNORE_SIZE.get().compare(i, i));
        return ourResult;
    };
}

Causes output like:

Our result: true, theirResult: false
Compare self: -1

The fact that comparing two identical objects do not give 0 suggests that it is definitely broken.

Link to logs

No response

tyhdefu commented 5 months ago

Same bug appears in API11:

Minecraft: 1.20
    SpongeAPI: 11.0.0-SNAPSHOT
    Sponge: 1.20-11.0.0-SNAPSHOT
    SpongeVanilla: 1.20-11.0.0-RC1348
    JVM: 17.0.8.1/64-bit (Amazon.com Inc.)
    OS: Windows 10/10.0 (amd64)