@Override public boolean onBlockActivated( World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn, EnumFacing side, float hitX, float hitY, float hitZ) { if (playerIn.getCurrentEquippedItem() != null) { Item item = playerIn.getCurrentEquippedItem().getItem(); if (item == Items.flint_and_steel || item == Items.fire_charge) { this.explode(worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true)), playerIn); worldIn.setBlockToAir(pos); if (item == Items.flint_and_steel) { playerIn.getCurrentEquippedItem().damageItem(1, playerIn); } else if (!playerIn.capabilities.isCreativeMode) { --playerIn.getCurrentEquippedItem().stackSize; } return true; } } return super.onBlockActivated(worldIn, pos, state, playerIn, side, hitX, hitY, hitZ); }
@Override public void onNeighborBlockChange( World worldIn, BlockPos pos, IBlockState state, Block neighborBlock) { if (worldIn.isBlockPowered(pos)) { this.onBlockDestroyedByPlayer( worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true))); worldIn.setBlockToAir(pos); } }
@Override public void onBlockAdded(World worldIn, BlockPos pos, IBlockState state) { super.onBlockAdded(worldIn, pos, state); if (worldIn.isBlockPowered(pos)) { this.onBlockDestroyedByPlayer( worldIn, pos, state.withProperty(EXPLODE, Boolean.valueOf(true))); worldIn.setBlockToAir(pos); } }