Guest User

ItemMagnesiumAndSteel

a guest
Mar 14th, 2015
271
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. package com.smith.mod.items;
  2.  
  3. import net.minecraft.block.BlockTNT;
  4. import net.minecraft.block.state.IBlockState;
  5. import net.minecraft.entity.EntityLivingBase;
  6. import net.minecraft.entity.player.EntityPlayer;
  7. import net.minecraft.init.Blocks;
  8. import net.minecraft.item.Item;
  9. import net.minecraft.item.ItemStack;
  10. import net.minecraft.util.BlockPos;
  11. import net.minecraft.util.EnumFacing;
  12. import net.minecraft.world.World;
  13.  
  14. public class ItemMagnesiumAndSteel extends Item
  15. {
  16.  
  17. public ItemMagnesiumAndSteel()
  18. {
  19. this.maxStackSize = 1;
  20. this.setMaxDamage(192);
  21. }
  22.  
  23.  
  24. public BlockTNT tnt;
  25. public IBlockState state;
  26.  
  27. /**
  28. * Called when a Block is right-clicked with this Item
  29. *
  30. * @param pos The block being right-clicked
  31. * @param side The side being right-clicked
  32. */
  33. public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
  34. {
  35. pos = pos.offset(side);
  36.  
  37. if (!playerIn.canPlayerEdit(pos, side, stack))
  38. {
  39. return false;
  40. }
  41. else
  42. {
  43. if (worldIn.isAirBlock(pos))
  44. {
  45. worldIn.playSoundEffect((double)pos.getX() + 0.5D, (double)pos.getY() + 0.5D, (double)pos.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
  46. worldIn.setBlockState(pos, Blocks.fire.getDefaultState());
  47. }
  48.  
  49. if (worldIn.getBlockState(pos) instanceof BlockTNT)
  50. {
  51. tnt.explode(worldIn, pos, state, playerIn);
  52. worldIn.setBlockToAir(pos);
  53. }
  54.  
  55. stack.damageItem(1, playerIn);
  56. return true;
  57. }
  58. }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment