-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathMapItemStackNBTIngredient.java
More file actions
75 lines (62 loc) · 2.2 KB
/
MapItemStackNBTIngredient.java
File metadata and controls
75 lines (62 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package gregtech.api.recipes.map;
import gregtech.api.recipes.ingredients.GTRecipeInput;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class MapItemStackNBTIngredient extends MapItemStackIngredient {
protected GTRecipeInput gtRecipeInput = null;
public MapItemStackNBTIngredient(ItemStack stack, int meta, NBTTagCompound tag) {
super(stack, meta, tag);
}
public MapItemStackNBTIngredient(ItemStack s, GTRecipeInput gtRecipeInput) {
super(s, s.getMetadata(), null);
this.gtRecipeInput = gtRecipeInput;
}
@NotNull
public static List<AbstractMapIngredient> from(@NotNull GTRecipeInput r) {
ObjectArrayList<AbstractMapIngredient> list = new ObjectArrayList<>();
for (ItemStack s : r.getInputStacks()) {
list.add(new MapItemStackNBTIngredient(s, r));
}
return list;
}
@Override
protected int hash() {
int hash = stack.getItem().hashCode() * 31;
hash += 31 * meta;
return hash;
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof MapItemStackNBTIngredient) {
MapItemStackNBTIngredient other = (MapItemStackNBTIngredient) obj;
if (this.stack.getItem() != other.stack.getItem()) {
return false;
}
if (this.meta != other.meta) {
return false;
}
if (this.gtRecipeInput != null) {
if (other.gtRecipeInput != null) {
return gtRecipeInput.equalIgnoreAmount(other.gtRecipeInput);
}
} else if (other.gtRecipeInput != null) {
return other.gtRecipeInput.acceptsStack(this.stack);
}
}
return false;
}
@Override
public String toString() {
return "MapItemStackNBTIngredient{" + "item=" + stack.getItem().getRegistryName() + "}" + "{meta=" + meta + "}";
}
@Override
public boolean isSpecialIngredient() {
return true;
}
}