-
Notifications
You must be signed in to change notification settings - Fork 754
/
SpecialFood.java
78 lines (67 loc) · 2.06 KB
/
SpecialFood.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
package tconstruct.world.items;
import java.util.List;
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.util.IIcon;
import net.minecraft.util.MathHelper;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public class SpecialFood extends ItemFood
{
protected int[] hunger;
protected float[] saturation;
protected String[] unlocalizedNames;
protected String[] iconNames;
protected IIcon[] icons;
public SpecialFood(int[] hunger, float[] saturation, String[] textureNames, String[] iconNames)
{
super(0, 0, false);
this.hunger = hunger;
this.saturation = saturation;
this.unlocalizedNames = textureNames;
this.iconNames = iconNames;
}
@Override
public int func_150905_g(ItemStack stack)
{
return hunger[stack.getItemDamage()];
}
@Override
public float func_150906_h(ItemStack stack)
{
return saturation[stack.getItemDamage()];
}
@Override
@SideOnly(Side.CLIENT)
public IIcon getIconFromDamage (int meta)
{
if (meta >= icons.length)
return icons[0];
return icons[meta];
}
@SideOnly(Side.CLIENT)
@Override
public void registerIcons (IIconRegister iconRegister)
{
this.icons = new IIcon[iconNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + iconNames[i]);
}
}
@Override
public String getUnlocalizedName (ItemStack stack)
{
int arr = MathHelper.clamp_int(stack.getItemDamage(), 0, unlocalizedNames.length);
return getUnlocalizedName() + "." + unlocalizedNames[arr];
}
@Override
public void getSubItems (Item b, CreativeTabs tab, List list)
{
for (int i = 0; i < unlocalizedNames.length; i++)
list.add(new ItemStack(b, 1, i));
}
}