-
Notifications
You must be signed in to change notification settings - Fork 755
/
CraftingItem.java
81 lines (67 loc) · 2.36 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
package tconstruct.items;
import tconstruct.common.TContent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import tconstruct.achievements.TAchievements;
import java.util.List;
import tconstruct.library.TConstructRegistry;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.Icon;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class CraftingItem extends Item
{
public String[] textureNames;
public String[] unlocalizedNames;
public String folder;
public Icon[] icons;
public CraftingItem(int id, String[] names, String[] tex, String folder)
{
super(id);
this.setCreativeTab(TConstructRegistry.materialTab);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.textureNames = tex;
this.unlocalizedNames = names;
this.folder = folder;
}
@SideOnly(Side.CLIENT)
public Icon getIconFromDamage (int meta)
{
int arr = MathHelper.clamp_int(meta, 0, unlocalizedNames.length);
return icons[arr];
}
@Override
@SideOnly(Side.CLIENT)
public void registerIcons (IconRegister iconRegister)
{
this.icons = new Icon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
if (!(textureNames[i].equals("")))
this.icons[i] = iconRegister.registerIcon("tinker:" + folder + textureNames[i]);
}
}
public String getUnlocalizedName (ItemStack stack)
{
int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, unlocalizedNames.length);
return getUnlocalizedName() + "." + unlocalizedNames[arr];
}
public void getSubItems (int id, CreativeTabs tab, List list)
{
for (int i = 0; i < unlocalizedNames.length; i++)
if (!(textureNames[i].equals("")))
list.add(new ItemStack(id, 1, i));
}
@Override
public void onCreated(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
if(par1ItemStack.itemID == TContent.blankPattern.itemID){
par3EntityPlayer.addStat(TAchievements.achievements.get("tconstruct.pattern"), 1);
}
}
}