2013-07-26 21:18:53 -07:00
|
|
|
package tconstruct.items;
|
|
|
|
|
|
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;
|
|
|
|
|
import net.minecraft.item.ItemFood;
|
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
|
import net.minecraft.potion.Potion;
|
|
|
|
|
import net.minecraft.potion.PotionEffect;
|
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;
|
|
|
|
|
import cpw.mods.fml.relauncher.Side;
|
|
|
|
|
import cpw.mods.fml.relauncher.SideOnly;
|
|
|
|
|
|
|
|
|
|
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" };
|
2013-07-26 21:18:53 -07:00
|
|
|
public String[] itemNames = new String[] { "apple.diamond" };
|
|
|
|
|
|
2013-12-31 11:26:08 -05:00
|
|
|
public DiamondApple()
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
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
|
2013-07-26 21:18:53 -07:00
|
|
|
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));
|
|
|
|
|
|
2013-07-26 21:18:53 -07:00
|
|
|
potion = player.getActivePotionEffect(Potion.resistance);
|
|
|
|
|
if (potion != null)
|
2014-01-05 10:52:01 -05:00
|
|
|
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);
|
|
|
|
|
if (potion != null)
|
2014-01-05 10:52:01 -05:00
|
|
|
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);
|
|
|
|
|
if (potion != null)
|
2014-01-05 10:52:01 -05:00
|
|
|
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
|
2013-12-31 11:26:08 -05:00
|
|
|
public IIcon getIconFromDamage (int meta)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
|
|
|
|
return icons[meta];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SideOnly(Side.CLIENT)
|
|
|
|
|
@Override
|
2013-12-31 11:26:08 -05:00
|
|
|
public void registerIcons (IIconRegister iconRegister)
|
2013-07-26 21:18:53 -07:00
|
|
|
{
|
2013-12-31 11:26:08 -05:00
|
|
|
this.icons = new IIcon[textureNames.length];
|
2013-07-26 21:18:53 -07:00
|
|
|
|
|
|
|
|
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()]).toString();
|
|
|
|
|
}
|
|
|
|
|
}
|