Advertisement
TechMage66

ItemTalismanFire

Dec 10th, 2014
273
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.04 KB | None | 0 0
  1. package com.techmage.magetech.item;
  2.  
  3. import com.techmage.magetech.reference.Names;
  4. import com.techmage.magetech.reference.Textures;
  5. import com.techmage.magetech.utility.LogHelper;
  6. import cpw.mods.fml.relauncher.Side;
  7. import cpw.mods.fml.relauncher.SideOnly;
  8. import net.minecraft.client.renderer.texture.IIconRegister;
  9. import net.minecraft.entity.Entity;
  10. import net.minecraft.entity.player.EntityPlayer;
  11. import net.minecraft.entity.projectile.EntitySmallFireball;
  12. import net.minecraft.init.Blocks;
  13. import net.minecraft.item.ItemStack;
  14. import net.minecraft.potion.Potion;
  15. import net.minecraft.potion.PotionEffect;
  16. import net.minecraft.util.Vec3;
  17. import net.minecraft.world.World;
  18.  
  19. public class ItemTalismanFire extends ItemMageTech_Magic
  20. {
  21.  
  22.     public ItemTalismanFire()
  23.     {
  24.         super();
  25.         this.setUnlocalizedName(Names.Items.TALISMAN_FIRE);
  26.     }
  27.  
  28.     private boolean inPassiv = false;
  29.  
  30.     @Override
  31.     public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3Entity)
  32.     {
  33.         if (!par2World.isRemote)
  34.         {
  35.             if (par3Entity.isSneaking())
  36.             {
  37.                 if (inPassiv)
  38.                     inPassiv = false;
  39.                 else
  40.                     inPassiv = true;
  41.             }
  42.             else
  43.             {
  44.                 Vec3 look = par3Entity.getLookVec();
  45.                 EntitySmallFireball fireball = new EntitySmallFireball(par2World, par3Entity, 1, 1, 1);
  46.                 fireball.setPosition(par3Entity.posX + look.xCoord * 5, par3Entity.posY + 1 + look.yCoord * 5, par3Entity.posZ + look.zCoord * 5);
  47.                 fireball.accelerationX = look.xCoord * 0.1;
  48.                 fireball.accelerationY = look.yCoord * 0.1;
  49.                 fireball.accelerationZ = look.zCoord * 0.1;
  50.                 par2World.spawnEntityInWorld(fireball);
  51.             }
  52.         }
  53.         return par1ItemStack;
  54.     }
  55.  
  56.     public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
  57.     {
  58.         if (!par3World.isRemote)
  59.         {
  60.             if(par3World.getBlock(par4, par5 + 1, par6) == Blocks.air)
  61.                 par3World.setBlock(par4, par5 + 1, par6, Blocks.flowing_lava);
  62.         }
  63.  
  64.         return true;
  65.     }
  66.  
  67.     @Override
  68.     public void onUpdate(ItemStack par1ItemStack, World par2World, Entity par3Entity, int par4, boolean par5)
  69.     {
  70.         if (!par2World.isRemote)
  71.         {
  72.             if (inPassiv)
  73.             {
  74.                 if (par3Entity instanceof EntityPlayer)
  75.                 {
  76.                     EntityPlayer player = ((EntityPlayer) par3Entity);
  77.                     player.addPotionEffect(new PotionEffect(Potion.fireResistance.id, 20, 2));
  78.                 }
  79.             }
  80.         }
  81.     }
  82.  
  83.     @Override
  84.     @SideOnly(Side.CLIENT)
  85.     public void registerIcons(IIconRegister iconRegister)
  86.     {
  87.         itemIcon = iconRegister.registerIcon(Textures.RESOURCE_PREFIX + this.getUnlocalizedName());
  88.     }
  89.  
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement