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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

72 lines
2.5 KiB
Java
Raw Normal View History

2014-06-04 21:44:48 -08:00
package tconstruct.armor.items;
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;
2014-09-09 18:30:15 +10:00
import cpw.mods.fml.relauncher.*;
public class DiamondApple extends ItemFood {
2013-12-31 11:26:08 -05:00
public IIcon[] icons;
public String[] textureNames = new String[] { "food/apple_diamond" };
public String[] itemNames = new String[] { "apple.diamond" };
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) 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) duration = potion.getDuration();
player.addPotionEffect(new PotionEffect(Potion.resistance.id, duration + 60 * 20, 0));
potion = player.getActivePotionEffect(Potion.digSpeed);
if (potion != null) duration = potion.getDuration();
player.addPotionEffect(new PotionEffect(Potion.digSpeed.id, duration + 60 * 20, 0));
potion = player.getActivePotionEffect(Potion.damageBoost);
if (potion != null) duration = potion.getDuration();
player.addPotionEffect(new PotionEffect(Potion.damageBoost.id, duration + 60 * 20, 0));
}
}
@SideOnly(Side.CLIENT)
@Override
public IIcon getIconFromDamage(int meta) {
return icons[meta];
}
@SideOnly(Side.CLIENT)
@Override
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) {
2023-01-26 00:55:34 +01:00
return "item.food."
+ itemNames[(itemstack.getItemDamage() >= itemNames.length || itemstack.getItemDamage() < 0) ? (0)
: (itemstack.getItemDamage())];
}
}