Advertisement
The_Fireplace

ItemBlockCoalGun

Apr 16th, 2015
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. public class ItemBlockCoalGun extends ItemBlock {
  2.  
  3.     public ItemBlockCoalGun() {
  4.         super(UnLogicII.coal_gun);
  5.         setMaxStackSize(1);
  6.         setUnlocalizedName("coal_gun");
  7.     }
  8.     @Override
  9.     public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
  10.     {//shoots the coal type the user is currently on
  11.         if(ExtendedPlayer.get(playerIn).getAmmoType() == EnumAmmo.COAL){
  12.             worldIn.spawnEntityInWorld(new EntityCoal(worldIn, playerIn));
  13.         }
  14.         return itemStackIn;
  15.     }
  16.     @Override
  17.     public boolean hitEntity(ItemStack stack, EntityLivingBase target, EntityLivingBase attacker)
  18.     {
  19.         if(((EntityPlayer)attacker).capabilities.isCreativeMode || ((EntityPlayer)attacker).inventory.consumeInventoryItem(Items.gunpowder)){
  20.             if(((EntityPlayer)attacker).capabilities.isCreativeMode || ((EntityPlayer)attacker).inventory.consumeInventoryItem(Items.gunpowder)){
  21.                 target.worldObj.createExplosion(null, (attacker.posX + target.posX)/2, (attacker.posY + target.posY)/2, (attacker.posZ + target.posZ)/2, 2, false);
  22.                 return true;
  23.             }else{
  24.                 target.worldObj.createExplosion(null, (attacker.posX + target.posX)/2, (attacker.posY + target.posY)/2, (attacker.posZ + target.posZ)/2, 1, false);
  25.                 return true;
  26.             }
  27.         }
  28.         return false;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement