-
Notifications
You must be signed in to change notification settings - Fork 753
/
ToolRecipe.java
130 lines (114 loc) · 3.23 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
package tconstruct.library.crafting;
import java.util.LinkedList;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
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 (Item head)
{
this.headList.add(head);
}
public void addHandleItem (Item head)
{
this.handleList.add(head);
}
public void addAccessoryItem (Item head)
{
this.accessoryList.add(head);
}
public void addExtraItem (Item head)
{
this.extraList.add(head);
}
public boolean validHead (Item input)
{
for (Item part : headList)
{
if (part == input)
return true;
}
return false;
}
public boolean validHandle (Item input)
{
for (Item part : handleList)
{
if (part == input)
return true;
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
return true;
}
return false;
}
public boolean validAccessory (Item input)
{
if (input == null)
{
if (accessoryList.size() < 1)
return true;
return false;
}
for (Item part : accessoryList)
{
if (part == input)
return true;
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
return true;
}
return false;
}
public boolean validExtra (Item input)
{
if (input == null)
{
if (extraList.size() < 1)
return true;
return false;
}
for (Item part : extraList)
{
if (part == input)
return true;
if (toolRod != null && part == toolRod && (input == Items.stick || input == Items.bone))
return true;
}
return false;
}
public ToolCore getType ()
{
return result;
}
}