From Slot to Slotpos

Hello !

Here is my code :

if(slots.contains(slot.getInventoryProperty(SlotPos.class))) {								 
    Sponge.getServer().getBroadcastChannel().send(Text.of("YES"));
} else {
    Sponge.getServer().getBroadcastChannel().send(Text.of("NO"));
}

But it said no (Slot and SlotPos are exact i’m sure)
Are there an other way to get a SlotPos from a Slot ?

For Information slots is a arraylist from SlotPos

Thanks and bye.

I think the issue is your implementation. The SlotPos does not override .equals(Object obj) and a new SlotPos object is created when you request the slotPos of a slot. Try something like this.

List<SlotPos> slots;
SlotPos compare;
if(slots.stream().anyMatch(sp -> {
    int x = sp.getX();
    int y = sp.getY();
    return (x == compare.getX() && y == compare.getY());
})){
    //Slot pos found
}

I havent tested it and written from memory

Thanks i will try a soon as possible and give you an anwser if it’s working.