-
Notifications
You must be signed in to change notification settings - Fork 754
/
ToolRecipe.java
131 lines (115 loc) · 3.46 KB
/
ToolRecipe.java
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package tconstruct.library.crafting;
import java.util.LinkedList;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import tconstruct.library.TConstructRegistry;
import tconstruct.library.tools.ToolCore;
/*
* Small class for checking if a particular tool combination is this one
*/
public class ToolRecipe
{
protected LinkedList<Item> headList = new LinkedList<Item>();
protected LinkedList<Item> handleList = new LinkedList<Item>();
protected LinkedList<Item> accessoryList = new LinkedList<Item>();
protected LinkedList<Item> extraList = new LinkedList<Item>();
protected ToolCore result;
protected Item toolRod = TConstructRegistry.getItem("toolRod");
/*
* public ToolRecipe(Item head, ToolCore tool) { this(head,
* TContent.toolRod, null, null, tool); }
*/
public ToolRecipe(Item head, Item handle, ToolCore tool)
{
this(head, handle, null, null, tool);
}
public ToolRecipe(Item head, Item handle, Item accessory, ToolCore tool)
{
this(head, handle, accessory, null, tool);
}
public ToolRecipe(Item head, Item handle, Item accessory, Item extra, ToolCore tool)
{
this.headList.add(head);
this.handleList.add(handle);
if (accessory != null)
this.accessoryList.add(accessory);
if (extra != null)
this.extraList.add(extra);
result = tool;
}
public void addHeadItem (ItemStack head)
{
this.headList.add(head.getItem());
}
public void addHandleItem (ItemStack handle)
{
this.handleList.add(handle.getItem());
}
public void addAccessoryItem (ItemStack accessory)
{
this.accessoryList.add(accessory.getItem());
}
public void addExtraItem (ItemStack extra)
{
this.extraList.add(extra.getItem());
}
public boolean validHead (ItemStack input)
{
for (Item part : headList)
{
if (part == input.getItem())
return true;
}
return false;
}
public boolean validHandle (ItemStack input)
{
for (Item part : handleList)
{
if (part == input.getItem())
return true;
if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone))
return true;
}
return false;
}
public boolean validAccessory (ItemStack input)
{
if (input == null)
{
if (accessoryList.size() < 1)
return true;
return false;
}
for (Item part : accessoryList)
{
if (part == input.getItem())
return true;
if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone))
return true;
}
return false;
}
public boolean validExtra (ItemStack input)
{
if (input == null)
{
if (extraList.size() < 1)
return true;
return false;
}
for (Item part : extraList)
{
if (part == input.getItem())
return true;
if (toolRod != null && part == toolRod && (input.getItem() == Items.stick || input.getItem() == Items.bone))
return true;
}
return false;
}
public ToolCore getType ()
{
return result;
}
}