Example #1
0
  @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);
  }
Example #2
0
 @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);
   }
 }
Example #3
0
  @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);
    }
  }
Example #4
0
  @Override
  public void onEntityCollidedWithBlock(
      World worldIn, BlockPos pos, IBlockState state, Entity entityIn) {
    if (!worldIn.isRemote && entityIn instanceof EntityArrow) {
      EntityArrow entityarrow = (EntityArrow) entityIn;

      if (entityarrow.isBurning()) {
        this.explode(
            worldIn,
            pos,
            worldIn.getBlockState(pos).withProperty(EXPLODE, Boolean.valueOf(true)),
            entityarrow.shootingEntity instanceof EntityLivingBase
                ? (EntityLivingBase) entityarrow.shootingEntity
                : null);
        worldIn.setBlockToAir(pos);
      }
    }
  }