/
CraftingItem.java
63 lines (52 loc) · 1.66 KB
/
CraftingItem.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
package mantle.items.abstracts;
import java.util.List;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.MathHelper;
public class CraftingItem extends Item
{
public String modTexPrefix;
public String[] textureNames;
public String[] unlocalizedNames;
public String folder;
public CraftingItem(String[] names, String[] tex, String folder, String modTexturePrefix, CreativeTabs tab)
{
super();
this.modTexPrefix = modTexturePrefix;
if (tab != null)
{
this.setCreativeTab(tab);
}
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.textureNames = tex;
this.unlocalizedNames = names;
this.folder = folder;
}
public void updateData(String[] names, String[] tex, String folder, String modTexturePrefix)
{
this.modTexPrefix = modTexturePrefix;
this.textureNames = tex;
this.unlocalizedNames = names;
this.folder = folder;
}
@Override
public String getUnlocalizedName(ItemStack stack)
{
int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, this.unlocalizedNames.length);
return this.getUnlocalizedName() + "." + this.unlocalizedNames[arr];
}
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubItems(Item b, CreativeTabs tab, List list)
{
for (int i = 0; i < this.unlocalizedNames.length; i++)
{
if (!(this.textureNames[i].equals("")))
{
list.add(new ItemStack(b, 1, i));
}
}
}
}