PrettyPipes/src/main/java/de/ellpeck/prettypipes/misc/EquatableItemStack.java

31 lines
862 B
Java
Raw Normal View History

2020-05-07 18:30:40 +02:00
package de.ellpeck.prettypipes.misc;
import net.minecraft.item.ItemStack;
import java.util.Arrays;
2020-05-07 18:30:40 +02:00
import java.util.Objects;
public class EquatableItemStack {
public final ItemStack stack;
2021-03-03 01:56:19 +01:00
public final ItemEquality[] equalityTypes;
2020-05-07 18:30:40 +02:00
2021-03-03 01:56:19 +01:00
public EquatableItemStack(ItemStack stack, ItemEquality... equalityTypes) {
2020-05-07 18:30:40 +02:00
this.stack = stack;
this.equalityTypes = equalityTypes;
2020-05-07 18:30:40 +02:00
}
public boolean equals(Object o) {
if (o instanceof EquatableItemStack) {
EquatableItemStack other = (EquatableItemStack) o;
2021-03-03 01:56:19 +01:00
return Arrays.equals(this.equalityTypes, other.equalityTypes) && ItemEquality.compareItems(this.stack, other.stack, this.equalityTypes);
2020-05-07 18:30:40 +02:00
}
return false;
}
@Override
public int hashCode() {
return Objects.hash(this.stack.getItem(), this.stack.getTag());
}
}