-
Notifications
You must be signed in to change notification settings - Fork 214
Expand file tree
/
Copy pathMapItemStackIngredient.java
More file actions
80 lines (68 loc) · 2.42 KB
/
MapItemStackIngredient.java
File metadata and controls
80 lines (68 loc) · 2.42 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
76
77
78
79
80
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;
import java.util.Objects;
public class MapItemStackIngredient extends AbstractMapIngredient {
protected ItemStack stack;
protected int meta;
protected NBTTagCompound tag;
protected GTRecipeInput gtRecipeInput = null;
public MapItemStackIngredient(ItemStack stack, int meta, NBTTagCompound tag) {
this.stack = stack;
this.meta = meta;
this.tag = tag;
}
public MapItemStackIngredient(ItemStack stack, GTRecipeInput gtRecipeInput) {
this.stack = stack;
this.meta = stack.getMetadata();
this.tag = stack.getTagCompound();
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 MapItemStackIngredient(s, r));
}
return list;
}
@Override
public boolean equals(Object o) {
if (super.equals(o)) {
MapItemStackIngredient other = (MapItemStackIngredient) o;
if (this.stack.getItem() != other.stack.getItem()) {
return false;
}
if (this.meta != other.meta) {
return false;
}
if (!Objects.equals(this.tag, other.tag)) {
return false;
}
if (this.gtRecipeInput == other.gtRecipeInput) {
return true;
} else if (this.gtRecipeInput == null) {
return other.gtRecipeInput.acceptsStack(this.stack);
} else {
return this.gtRecipeInput.acceptsStack(other.stack);
}
}
return false;
}
@Override
protected int hash() {
int hash = stack.getItem().hashCode() * 31;
hash += 31 * this.meta;
hash += 31 * (this.tag != null ? this.tag.hashCode() : 0);
return hash;
}
@Override
public String toString() {
return "MapItemStackIngredient{" + "item=" + stack.getItem().getRegistryName() + "} {meta=" + meta + "} {tag=" +
tag + "}";
}
}