Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.smith.mod.items;
- import com.smith.mod.Debugger;
- import net.minecraft.block.Block;
- import net.minecraft.block.BlockTNT;
- import net.minecraft.block.state.IBlockState;
- 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);
- }
- /**
- * 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)
- {
- BlockPos posSide = pos.offset(side);
- if (!playerIn.canPlayerEdit(posSide, side, stack))
- {
- return false;
- }
- else
- {
- if (worldIn.getBlockState(pos).getBlock() instanceof BlockTNT)
- {
- ((BlockTNT) worldIn.getBlockState(pos).getBlock()).explode(worldIn, pos, worldIn.getBlockState(pos).withProperty(BlockTNT.EXPLODE, Boolean.valueOf(true)), playerIn);
- worldIn.setBlockToAir(pos);
- }
- else if (worldIn.isAirBlock(posSide) && worldIn.getBlockState(pos).getBlock() != Blocks.tnt)
- {
- worldIn.playSoundEffect((double)posSide.getX() + 0.5D, (double)posSide.getY() + 0.5D, (double)posSide.getZ() + 0.5D, "fire.ignite", 1.0F, itemRand.nextFloat() * 0.4F + 0.8F);
- worldIn.setBlockState(posSide, Blocks.fire.getDefaultState());
- }
- stack.damageItem(1, playerIn);
- return true;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement