Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.smith.mod.items;
- import net.minecraft.block.BlockTNT;
- import net.minecraft.block.state.IBlockState;
- import net.minecraft.entity.EntityLivingBase;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.init.Blocks;
- import net.minecraft.item.Item;
- import net.minecraft.item.ItemStack;
- import net.minecraft.util.BlockPos;
- import net.minecraft.util.EnumFacing;
- import net.minecraft.world.World;
- public class ItemMagnesiumAndSteel extends Item
- {
- public ItemMagnesiumAndSteel()
- {
- this.maxStackSize = 1;
- this.setMaxDamage(192);
- }
- public BlockTNT tnt;
- public IBlockState state;
- /**
- * Called when a Block is right-clicked with this Item
- *
- * @param pos The block being right-clicked
- * @param side The side being right-clicked
- */
- public boolean onItemUse(ItemStack stack, EntityPlayer playerIn, World worldIn, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ)
- {
- pos = pos.offset(side);
- if (!playerIn.canPlayerEdit(pos, side, stack))
- {
- return false;
- }
- else
- {
- if (worldIn.isAirBlock(pos))
- {
- 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);
- worldIn.setBlockState(pos, Blocks.fire.getDefaultState());
- }
- if (worldIn.getBlockState(pos) instanceof BlockTNT)
- {
- tnt.explode(worldIn, pos, state, playerIn);
- worldIn.setBlockToAir(pos);
- }
- stack.damageItem(1, playerIn);
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment