Files
TinkersConstruct/src/main/java/tconstruct/armor/items/DiamondApple.java
T

80 lines
2.6 KiB
Java
Raw Normal View History

2014-06-04 21:44:48 -08:00
package tconstruct.armor.items;
2014-09-09 18:30:15 +10:00
import cpw.mods.fml.relauncher.*;
2013-12-31 11:26:08 -05:00
import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.entity.player.EntityPlayer;
2014-09-09 18:30:15 +10:00
import net.minecraft.item.*;
import net.minecraft.potion.*;
2013-12-31 11:26:08 -05:00
import net.minecraft.util.IIcon;
import net.minecraft.world.World;
public class DiamondApple extends ItemFood
{
2013-12-31 11:26:08 -05:00
public IIcon[] icons;
2013-09-08 19:23:22 -07:00
public String[] textureNames = new String[] { "food/apple_diamond" };
public String[] itemNames = new String[] { "apple.diamond" };
2013-12-31 11:26:08 -05:00
public DiamondApple()
{
2013-12-31 11:26:08 -05:00
super(4, 2.0F, false);
setHasSubtypes(true);
setMaxDamage(0);
this.setAlwaysEdible();
}
2014-02-17 00:31:43 -05:00
@Override
protected void onFoodEaten (ItemStack stack, World world, EntityPlayer player)
{
if (!world.isRemote)
{
int duration = 0;
PotionEffect potion;
2013-07-28 19:56:01 -07:00
potion = player.getActivePotionEffect(Potion.resistance);
if (potion != null)
2014-01-05 10:52:01 -05:00
duration = potion.getDuration();
2013-07-28 19:56:01 -07:00
player.addPotionEffect(new PotionEffect(Potion.field_76444_x.id, duration + 60 * 40, 4));
potion = player.getActivePotionEffect(Potion.resistance);
if (potion != null)
2014-01-05 10:52:01 -05:00
duration = potion.getDuration();
player.addPotionEffect(new PotionEffect(Potion.resistance.id, duration + 60 * 20, 0));
potion = player.getActivePotionEffect(Potion.digSpeed);
if (potion != null)
2014-01-05 10:52:01 -05:00
duration = potion.getDuration();
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, duration + 60 * 20, 0));
potion = player.getActivePotionEffect(Potion.damageBoost);
if (potion != null)
2014-01-05 10:52:01 -05:00
duration = potion.getDuration();
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, duration + 60 * 20, 0));
}
}
@SideOnly(Side.CLIENT)
@Override
2013-12-31 11:26:08 -05:00
public IIcon getIconFromDamage (int meta)
{
return icons[meta];
}
@SideOnly(Side.CLIENT)
@Override
2013-12-31 11:26:08 -05:00
public void registerIcons (IIconRegister iconRegister)
{
2013-12-31 11:26:08 -05:00
this.icons = new IIcon[textureNames.length];
for (int i = 0; i < this.icons.length; ++i)
{
this.icons[i] = iconRegister.registerIcon("tinker:" + textureNames[i]);
}
}
/* Name override */
@Override
public String getUnlocalizedName (ItemStack itemstack)
{
return (new StringBuilder()).append("item.food.").append(itemNames[(itemstack.getItemDamage()>=itemNames.length||itemstack.getItemDamage()<0)?(0):(itemstack.getItemDamage())]).toString();
}
}