Ejemplo n.º 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);
  }
Ejemplo n.º 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);
   }
 }
Ejemplo n.º 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);
    }
  }
Ejemplo n.º 4
0
 public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter) {
   if (!worldIn.isRemote) {
     if (((Boolean) state.getValue(EXPLODE)).booleanValue()) {
       // float power = 2F + (((5000) / 10369F) * 18F);
       // ProcessHandler.addProcess(new NuclearExplosion(worldIn, pos.getX(), pos.getY(),
       // pos.getZ(), power));
       EntityNukePrimed entitytntprimed =
           new EntityNukePrimed(
               worldIn, pos.getX() + 0.5F, pos.getY() + 0.5F, pos.getZ() + 0.5F, igniter);
       worldIn.spawnEntityInWorld(entitytntprimed);
       worldIn.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
     }
   }
 }
 @Override
 public int getMetaFromState(IBlockState state) {
   return state.getValue(FACING).getIndex();
 }
Ejemplo n.º 6
0
 @Override
 public int getMetaFromState(IBlockState state) {
   return ((Boolean) state.getValue(EXPLODE)).booleanValue() ? 1 : 0;
 }