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