Advertisement
TechMage66

firecharm

Jul 25th, 2015
184
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.21 KB | None | 0 0
  1. package Morpheus420.StormMastery;
  2.  
  3. import net.minecraft.entity.Entity;
  4. import net.minecraft.entity.player.EntityPlayer;
  5. import net.minecraft.item.Item;
  6. import net.minecraft.item.ItemStack;
  7. import net.minecraft.potion.Potion;
  8. import net.minecraft.potion.PotionEffect;
  9. import net.minecraft.world.World;
  10.  
  11. public class firecharm extends Item
  12. {
  13.  
  14.     public firecharm()
  15.     {
  16.         super();
  17.     }
  18.  
  19.     private boolean applyFireResistance = false;
  20.  
  21.     @Override
  22.     public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer player)
  23.     {
  24.         if (!world.isRemote)
  25.         {
  26.  
  27.             if (!applyFireResistance)
  28.                 applyFireResistance = true;
  29.             else
  30.                 applyFireResistance = false;
  31.         }
  32.  
  33.         return itemStack;
  34.     }
  35.  
  36.     @Override
  37.     public void onUpdate(ItemStack itemStack, World world, Entity entity, int par4, boolean par5)
  38.     {
  39.         if (!world.isRemote)
  40.         {
  41.             if (applyFireResistance)
  42.             {
  43.                 if (entity instanceof EntityPlayer)
  44.                     ((EntityPlayer) entity).addPotionEffect(new PotionEffect(Potion.fireResistance.id, 1));
  45.             }
  46.         }
  47.     }
  48.    
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement