22 lines
816 B
Java
22 lines
816 B
Java
package net.minecraft.world.item;
|
|
|
|
import it.unimi.dsi.fastutil.Hash.Strategy;
|
|
import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenCustomHashSet;
|
|
import java.util.Set;
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
public class ItemStackLinkedSet {
|
|
private static final Strategy<? super ItemStack> TYPE_AND_TAG = new Strategy<ItemStack>() {
|
|
public int hashCode(@Nullable ItemStack stack) {
|
|
return ItemStack.hashItemAndComponents(stack);
|
|
}
|
|
|
|
public boolean equals(@Nullable ItemStack first, @Nullable ItemStack second) {
|
|
return first == second || first != null && second != null && first.isEmpty() == second.isEmpty() && ItemStack.isSameItemSameComponents(first, second);
|
|
}
|
|
};
|
|
|
|
public static Set<ItemStack> createTypeAndComponentsSet() {
|
|
return new ObjectLinkedOpenCustomHashSet<>(TYPE_AND_TAG);
|
|
}
|
|
}
|