예제 #1
0
  private void tryToCatchBlockOnFire(
      World par1World, int par2, int par3, int par4, int par5, Random par6Random, int par7) {
    if (oldFire) {
      tryToCatchBlockOnFire_old(par1World, par2, par3, par4, par5, par6Random);
      return;
    }
    int i = abilityToCatchFire[par1World.getBlockId(par2, par3, par4)];

    if (par6Random.nextInt(par5) < i) {
      boolean flag = par1World.getBlockId(par2, par3, par4) == Block.tnt.blockID;

      if (par6Random.nextInt(par7 + 10) < 5 && !par1World.canLightningStrikeAt(par2, par3, par4)) {
        int j = par7 + par6Random.nextInt(5) / 4;

        if (j > 15) {
          j = 15;
        }

        par1World.setBlock(par2, par3, par4, blockID, j, 3);
      } else {
        par1World.setBlockToAir(par2, par3, par4);
      }

      if (flag) {
        Block.tnt.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
      }
    }
  }
예제 #2
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);
  }
예제 #3
0
 @Override
 public void onNeighborBlockChange(
     World world, BlockPos pos, IBlockState state, Block neighborBlock) {
   if (world.isAirBlock(pos.up())) {
     this.dropBlockAsItem(world, pos, state, 0);
     world.setBlockToAir(pos);
   }
 }
예제 #4
0
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    super.onBlockAdded(par1World, par2, par3, par4);

    if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
      this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
      par1World.setBlockToAir(par2, par3, par4);
    }
  }
예제 #5
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);
   }
 }
예제 #6
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);
    }
  }
  @Override
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, Block block) {
    ChunkCoordinates coord =
        getBase(par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4));
    if (par1World.getBlock(coord.posX, coord.posY, coord.posZ) != NailedBlocks.portalCrystal) {
      this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
      par1World.setBlockToAir(par2, par3, par4);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, block);
  }
예제 #8
0
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor blockID
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
    if (!par1World.isRemote) {
      boolean var6 = this.canPlaceBlockAt(par1World, par2, par3, par4);

      if (var6) {
        this.updateAndPropagateCurrentStrength(par1World, par2, par3, par4);
      } else {
        this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
        par1World.setBlockToAir(par2, par3, par4);
      }

      super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
    }
  }
예제 #9
0
 private void tryToCatchBlockOnFire_old(World world, int i, int j, int k, int l, Random random) {
   int i1 = abilityToCatchFire[world.getBlockId(i, j, k)];
   if (random.nextInt(l) < i1) {
     boolean flag = world.getBlockId(i, j, k) == Block.tnt.blockID;
     if (random.nextInt(2) == 0 && !world.canLightningStrikeAt(i, j, k)) {
       world.setBlock(i, j, k, blockID);
     } else {
       world.setBlockToAir(i, j, k);
     }
     if (flag) {
       Block.tnt.onBlockDestroyedByPlayer(world, i, j, k, 0);
     }
   }
 }
예제 #10
0
 /**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor blockID
  */
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   if (!this.canBlockStay(par1World, par2, par3, par4)) {
     this.dropBlockAsItem(
         par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
     par1World.setBlockToAir(par2, par3, par4);
     par1World.notifyBlocksOfNeighborChange(par2 + 1, par3, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2 - 1, par3, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3, par4 + 1, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3, par4 - 1, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3 - 1, par4, this.blockID);
     par1World.notifyBlocksOfNeighborChange(par2, par3 + 1, par4, this.blockID);
   } else {
     this.func_94479_f(par1World, par2, par3, par4, par5);
   }
 }
예제 #11
0
  /** ejects contained items into the world, and notifies neighbours of an update, as appropriate */
  public void breakBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
    super.breakBlock(par1World, par2, par3, par4, par5, par6);
    int var7 = Facing.faceToSide[getDirectionMeta(par6)];
    par2 += Facing.offsetsXForSide[var7];
    par3 += Facing.offsetsYForSide[var7];
    par4 += Facing.offsetsZForSide[var7];
    int var8 = par1World.getBlockId(par2, par3, par4);

    if (var8 == Block.pistonBase.blockID || var8 == Block.pistonStickyBase.blockID) {
      par6 = par1World.getBlockMetadata(par2, par3, par4);

      if (BlockPistonBase.isExtended(par6)) {
        Block.blocksList[var8].dropBlockAsItem(par1World, par2, par3, par4, par6, 0);
        par1World.setBlockToAir(par2, par3, par4);
      }
    }
  }
예제 #12
0
  /** Called whenever the block is added into the world. Args: world, x, y, z */
  public void onBlockAdded(World par1World, int par2, int par3, int par4) {
    if (par1World.provider.dimensionId <= 0
        && par1World.getBlockId(par2, par3 - 1, par4) == Block.obsidian.blockID
        && Block.portal.tryToCreatePortal(par1World, par2, par3, par4)) {
      return;
    }

    if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
        && !canNeighborBurn(par1World, par2, par3, par4)) {
      par1World.setBlockToAir(par2, par3, par4);
      return;
    } else {
      par1World.scheduleBlockUpdate(
          par2, par3, par4, blockID, tickRate(par1World) + par1World.rand.nextInt(10));
      return;
    }
  }
예제 #13
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);
      }
    }
  }
예제 #14
0
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor blockID
   */
  public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
    int var6 = getDirectionMeta(par1World.getBlockMetadata(par2, par3, par4));
    int var7 =
        par1World.getBlockId(
            par2 - Facing.offsetsXForSide[var6],
            par3 - Facing.offsetsYForSide[var6],
            par4 - Facing.offsetsZForSide[var6]);

    if (var7 != Block.pistonBase.blockID && var7 != Block.pistonStickyBase.blockID) {
      par1World.setBlockToAir(par2, par3, par4);
    } else {
      Block.blocksList[var7].onNeighborBlockChange(
          par1World,
          par2 - Facing.offsetsXForSide[var6],
          par3 - Facing.offsetsYForSide[var6],
          par4 - Facing.offsetsZForSide[var6],
          par5);
    }
  }
예제 #15
0
  /**
   * Triggered whenever an entity collides with this block (enters into the block). Args: world, x,
   * y, z, entity
   */
  public void onEntityCollidedWithBlock(
      World par1World, int par2, int par3, int par4, Entity par5Entity) {
    if (par5Entity instanceof EntityArrow && !par1World.isRemote) {
      EntityArrow var6 = (EntityArrow) par5Entity;

      if (var6.isBurning()) {
        this.func_94391_a(
            par1World,
            par2,
            par3,
            par4,
            1,
            var6.shootingEntity instanceof EntityLiving
                ? (EntityLiving) var6.shootingEntity
                : null);
        par1World.setBlockToAir(par2, par3, par4);
      }
    }
  }
예제 #16
0
 /** Called upon block activation (right click on the block.) */
 public boolean onBlockActivated(
     World par1World,
     int par2,
     int par3,
     int par4,
     EntityPlayer par5EntityPlayer,
     int par6,
     float par7,
     float par8,
     float par9) {
   if (par5EntityPlayer.getCurrentEquippedItem() != null
       && par5EntityPlayer.getCurrentEquippedItem().itemID == Item.flintAndSteel.itemID) {
     this.func_94391_a(par1World, par2, par3, par4, 1, par5EntityPlayer);
     par1World.setBlockToAir(par2, par3, par4);
     return true;
   } else {
     return super.onBlockActivated(
         par1World, par2, par3, par4, par5EntityPlayer, par6, par7, par8, par9);
   }
 }
예제 #17
0
  /**
   * Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on
   * to the tile entity at this location. Args: world, x, y, z, blockID, EventID, event parameter
   */
  public boolean onBlockEventReceived(
      World par1World, int par2, int par3, int par4, int par5, int par6) {
    if (!par1World.isRemote) {
      boolean var7 = this.isIndirectlyPowered(par1World, par2, par3, par4, par6);

      if (var7 && par5 == 1) {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, par6 | 8, 2);
        return false;
      }

      if (!var7 && par5 == 0) {
        return false;
      }
    }

    if (par5 == 0) {
      if (!this.tryExtend(par1World, par2, par3, par4, par6)) {
        return false;
      }

      par1World.setBlockMetadataWithNotify(par2, par3, par4, par6 | 8, 2);
      par1World.playSoundEffect(
          (double) par2 + 0.5D,
          (double) par3 + 0.5D,
          (double) par4 + 0.5D,
          "tile.piston.out",
          0.5F,
          par1World.rand.nextFloat() * 0.25F + 0.6F);
    } else if (par5 == 1) {
      TileEntity var16 =
          par1World.getBlockTileEntity(
              par2 + Facing.offsetsXForSide[par6],
              par3 + Facing.offsetsYForSide[par6],
              par4 + Facing.offsetsZForSide[par6]);

      if (var16 instanceof TileEntityPiston) {
        ((TileEntityPiston) var16).clearPistonTileEntity();
      }

      par1World.setBlock(par2, par3, par4, Block.pistonMoving.blockID, par6, 3);
      par1World.setBlockTileEntity(
          par2, par3, par4, BlockPistonMoving.getTileEntity(this.blockID, par6, par6, false, true));

      if (this.isSticky) {
        int var8 = par2 + Facing.offsetsXForSide[par6] * 2;
        int var9 = par3 + Facing.offsetsYForSide[par6] * 2;
        int var10 = par4 + Facing.offsetsZForSide[par6] * 2;
        int var11 = par1World.getBlockId(var8, var9, var10);
        int var12 = par1World.getBlockMetadata(var8, var9, var10);
        boolean var13 = false;

        if (var11 == Block.pistonMoving.blockID) {
          TileEntity var14 = par1World.getBlockTileEntity(var8, var9, var10);

          if (var14 instanceof TileEntityPiston) {
            TileEntityPiston var15 = (TileEntityPiston) var14;

            if (var15.getPistonOrientation() == par6 && var15.isExtending()) {
              var15.clearPistonTileEntity();
              var11 = var15.getStoredBlockID();
              var12 = var15.getBlockMetadata();
              var13 = true;
            }
          }
        }

        if (!var13
            && var11 > 0
            && canPushBlock(var11, par1World, var8, var9, var10, false)
            && (Block.blocksList[var11].getMobilityFlag() == 0
                || var11 == Block.pistonBase.blockID
                || var11 == Block.pistonStickyBase.blockID)) {
          par2 += Facing.offsetsXForSide[par6];
          par3 += Facing.offsetsYForSide[par6];
          par4 += Facing.offsetsZForSide[par6];
          par1World.setBlock(par2, par3, par4, Block.pistonMoving.blockID, var12, 3);
          par1World.setBlockTileEntity(
              par2, par3, par4, BlockPistonMoving.getTileEntity(var11, var12, par6, false, false));
          par1World.setBlockToAir(var8, var9, var10);
        } else if (!var13) {
          par1World.setBlockToAir(
              par2 + Facing.offsetsXForSide[par6],
              par3 + Facing.offsetsYForSide[par6],
              par4 + Facing.offsetsZForSide[par6]);
        }
      } else {
        par1World.setBlockToAir(
            par2 + Facing.offsetsXForSide[par6],
            par3 + Facing.offsetsYForSide[par6],
            par4 + Facing.offsetsZForSide[par6]);
      }

      par1World.playSoundEffect(
          (double) par2 + 0.5D,
          (double) par3 + 0.5D,
          (double) par4 + 0.5D,
          "tile.piston.in",
          0.5F,
          par1World.rand.nextFloat() * 0.15F + 0.6F);
    }

    return true;
  }
예제 #18
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    int var6 = this.getFlowDecay(par1World, par2, par3, par4);
    byte var7 = 1;

    if (this.blockMaterial == Material.lava && !par1World.provider.isHellWorld) {
      var7 = 2;
    }

    boolean var8 = true;
    int var9 = this.tickRate(par1World);
    int var11;

    if (var6 > 0) {
      byte var10 = -100;
      this.numAdjacentSources = 0;
      int var13 = this.getSmallestFlowDecay(par1World, par2 - 1, par3, par4, var10);
      var13 = this.getSmallestFlowDecay(par1World, par2 + 1, par3, par4, var13);
      var13 = this.getSmallestFlowDecay(par1World, par2, par3, par4 - 1, var13);
      var13 = this.getSmallestFlowDecay(par1World, par2, par3, par4 + 1, var13);
      var11 = var13 + var7;

      if (var11 >= 8 || var13 < 0) {
        var11 = -1;
      }

      if (this.getFlowDecay(par1World, par2, par3 + 1, par4) >= 0) {
        int var12 = this.getFlowDecay(par1World, par2, par3 + 1, par4);

        if (var12 >= 8) {
          var11 = var12;
        } else {
          var11 = var12 + 8;
        }
      }

      if (this.numAdjacentSources >= 2 && this.blockMaterial == Material.water) {
        if (par1World.getBlockMaterial(par2, par3 - 1, par4).isSolid()) {
          var11 = 0;
        } else if (par1World.getBlockMaterial(par2, par3 - 1, par4) == this.blockMaterial
            && par1World.getBlockMetadata(par2, par3 - 1, par4) == 0) {
          var11 = 0;
        }
      }

      if (this.blockMaterial == Material.lava
          && var6 < 8
          && var11 < 8
          && var11 > var6
          && par5Random.nextInt(4) != 0) {
        var9 *= 4;
      }

      if (var11 == var6) {
        if (var8) {
          this.updateFlow(par1World, par2, par3, par4);
        }
      } else {
        var6 = var11;

        if (var11 < 0) {
          par1World.setBlockToAir(par2, par3, par4);
        } else {
          par1World.setBlockMetadata(par2, par3, par4, var11, 2);
          par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, var9);
          par1World.notifyBlocksOfNeighborChange(par2, par3, par4, this.blockID);
        }
      }
    } else {
      this.updateFlow(par1World, par2, par3, par4);
    }

    if (this.liquidCanDisplaceBlock(par1World, par2, par3 - 1, par4)) {
      if (this.blockMaterial == Material.lava
          && par1World.getBlockMaterial(par2, par3 - 1, par4) == Material.water) {
        par1World.setBlock(par2, par3 - 1, par4, Block.stone.blockID);
        this.triggerLavaMixEffects(par1World, par2, par3 - 1, par4);
        return;
      }

      if (var6 >= 8) {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6);
      } else {
        this.flowIntoBlock(par1World, par2, par3 - 1, par4, var6 + 8);
      }
    } else if (var6 >= 0 && (var6 == 0 || this.blockBlocksFlow(par1World, par2, par3 - 1, par4))) {
      boolean[] var14 = this.getOptimalFlowDirections(par1World, par2, par3, par4);
      var11 = var6 + var7;

      if (var6 >= 8) {
        var11 = 1;
      }

      if (var11 >= 8) {
        return;
      }

      if (var14[0]) {
        this.flowIntoBlock(par1World, par2 - 1, par3, par4, var11);
      }

      if (var14[1]) {
        this.flowIntoBlock(par1World, par2 + 1, par3, par4, var11);
      }

      if (var14[2]) {
        this.flowIntoBlock(par1World, par2, par3, par4 - 1, var11);
      }

      if (var14[3]) {
        this.flowIntoBlock(par1World, par2, par3, par4 + 1, var11);
      }
    }
  }
예제 #19
0
  /**
   * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack,
   * world, entityPlayer
   */
  public ItemStack onItemRightClick(
      ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
    float var4 = 1.0F;
    double var5 =
        par3EntityPlayer.prevPosX
            + (par3EntityPlayer.posX - par3EntityPlayer.prevPosX) * (double) var4;
    double var7 =
        par3EntityPlayer.prevPosY
            + (par3EntityPlayer.posY - par3EntityPlayer.prevPosY) * (double) var4
            + 1.62D
            - (double) par3EntityPlayer.yOffset;
    double var9 =
        par3EntityPlayer.prevPosZ
            + (par3EntityPlayer.posZ - par3EntityPlayer.prevPosZ) * (double) var4;
    boolean var11 = this.isFull == 0;
    MovingObjectPosition var12 =
        this.getMovingObjectPositionFromPlayer(par2World, par3EntityPlayer, var11);

    if (var12 == null) {
      return par1ItemStack;
    } else {
      if (var12.typeOfHit == EnumMovingObjectType.TILE) {
        int var13 = var12.blockX;
        int var14 = var12.blockY;
        int var15 = var12.blockZ;

        if (!par2World.canMineBlock(par3EntityPlayer, var13, var14, var15)) {
          return par1ItemStack;
        }

        if (this.isFull == 0) {
          if (!par3EntityPlayer.canPlayerEdit(var13, var14, var15, var12.sideHit, par1ItemStack)) {
            return par1ItemStack;
          }

          if (par2World.getBlockMaterial(var13, var14, var15) == Material.water
              && par2World.getBlockMetadata(var13, var14, var15) == 0) {
            par2World.setBlockToAir(var13, var14, var15);

            if (par3EntityPlayer.capabilities.isCreativeMode) {
              return par1ItemStack;
            }

            if (--par1ItemStack.stackSize <= 0) {
              return new ItemStack(Item.bucketWater);
            }

            if (!par3EntityPlayer.inventory.addItemStackToInventory(
                new ItemStack(Item.bucketWater))) {
              par3EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketWater.itemID, 1, 0));
            }

            return par1ItemStack;
          }

          if (par2World.getBlockMaterial(var13, var14, var15) == Material.lava
              && par2World.getBlockMetadata(var13, var14, var15) == 0) {
            par2World.setBlockToAir(var13, var14, var15);

            if (par3EntityPlayer.capabilities.isCreativeMode) {
              return par1ItemStack;
            }

            if (--par1ItemStack.stackSize <= 0) {
              return new ItemStack(Item.bucketLava);
            }

            if (!par3EntityPlayer.inventory.addItemStackToInventory(
                new ItemStack(Item.bucketLava))) {
              par3EntityPlayer.dropPlayerItem(new ItemStack(Item.bucketLava.itemID, 1, 0));
            }

            return par1ItemStack;
          }
        } else {
          if (this.isFull < 0) {
            return new ItemStack(Item.bucketEmpty);
          }

          if (var12.sideHit == 0) {
            --var14;
          }

          if (var12.sideHit == 1) {
            ++var14;
          }

          if (var12.sideHit == 2) {
            --var15;
          }

          if (var12.sideHit == 3) {
            ++var15;
          }

          if (var12.sideHit == 4) {
            --var13;
          }

          if (var12.sideHit == 5) {
            ++var13;
          }

          if (!par3EntityPlayer.canPlayerEdit(var13, var14, var15, var12.sideHit, par1ItemStack)) {
            return par1ItemStack;
          }

          if (this.tryPlaceContainedLiquid(par2World, var5, var7, var9, var13, var14, var15)
              && !par3EntityPlayer.capabilities.isCreativeMode) {
            return new ItemStack(Item.bucketEmpty);
          }
        }
      } else if (this.isFull == 0 && var12.entityHit instanceof EntityCow) {
        return new ItemStack(Item.bucketMilk);
      }

      return par1ItemStack;
    }
  }
예제 #20
0
 public void updateTickOld(World world, int i, int j, int k, Random random) {
   boolean flag = world.getBlockId(i, j - 1, k) == Block.netherrack.blockID;
   if (!flag
       && world.isRaining()
       && (world.canLightningStrikeAt(i, j, k)
           || world.canLightningStrikeAt(i - 1, j, k)
           || world.canLightningStrikeAt(i + 1, j, k)
           || world.canLightningStrikeAt(i, j, k - 1)
           || world.canLightningStrikeAt(i, j, k + 1))) {
     world.setBlockToAir(i, j, k);
     return;
   }
   int l = world.getBlockMetadata(i, j, k);
   if (l < 15) {
     world.setBlockMetadataWithNotify(i, j, k, l + 1, 3);
     world.scheduleBlockUpdate(i, j, k, blockID, tickRate(world));
   }
   if (!flag && !canNeighborBurn(world, i, j, k)) {
     if (!world.isBlockOpaqueCube(i, j - 1, k) || l > 3) {
       world.setBlockToAir(i, j, k);
     }
     return;
   }
   if (!flag && !canBlockCatchFire(world, i, j - 1, k) && l == 15 && random.nextInt(4) == 0) {
     world.setBlockToAir(i, j, k);
     return;
   }
   if (l % 2 == 0 && l > 2) {
     tryToCatchBlockOnFire_old(world, i + 1, j, k, 300, random);
     tryToCatchBlockOnFire_old(world, i - 1, j, k, 300, random);
     tryToCatchBlockOnFire_old(world, i, j - 1, k, 250, random);
     tryToCatchBlockOnFire_old(world, i, j + 1, k, 250, random);
     tryToCatchBlockOnFire_old(world, i, j, k - 1, 300, random);
     tryToCatchBlockOnFire_old(world, i, j, k + 1, 300, random);
     for (int i1 = i - 1; i1 <= i + 1; i1++) {
       for (int j1 = k - 1; j1 <= k + 1; j1++) {
         for (int k1 = j - 1; k1 <= j + 4; k1++) {
           if (i1 == i && k1 == j && j1 == k) {
             continue;
           }
           int l1 = 100;
           if (k1 > j + 1) {
             l1 += (k1 - (j + 1)) * 100;
           }
           int i2 = getChanceOfNeighborsEncouragingFire(world, i1, k1, j1);
           if (i2 > 0
               && random.nextInt(l1) <= i2
               && (!world.isRaining() || !world.canLightningStrikeAt(i1, k1, j1))
               && !world.canLightningStrikeAt(i1 - 1, k1, k)
               && !world.canLightningStrikeAt(i1 + 1, k1, j1)
               && !world.canLightningStrikeAt(i1, k1, j1 - 1)
               && !world.canLightningStrikeAt(i1, k1, j1 + 1)) {
             world.setBlock(i1, k1, j1, blockID);
           }
         }
       }
     }
   }
   if (l == 15 && !infiniteBurn) {
     tryToCatchBlockOnFire_old(world, i + 1, j, k, 1, random);
     tryToCatchBlockOnFire_old(world, i - 1, j, k, 1, random);
     tryToCatchBlockOnFire_old(world, i, j - 1, k, 1, random);
     tryToCatchBlockOnFire_old(world, i, j + 1, k, 1, random);
     tryToCatchBlockOnFire_old(world, i, j, k - 1, 1, random);
     tryToCatchBlockOnFire_old(world, i, j, k + 1, 1, random);
   }
 }
예제 #21
0
 /**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor blockID
  */
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4)
       && !canNeighborBurn(par1World, par2, par3, par4)) {
     par1World.setBlockToAir(par2, par3, par4);
   }
 }
예제 #22
0
  /** attempts to extend the piston. returns false if impossible. */
  private boolean tryExtend(World par1World, int par2, int par3, int par4, int par5) {
    int var6 = par2 + Facing.offsetsXForSide[par5];
    int var7 = par3 + Facing.offsetsYForSide[par5];
    int var8 = par4 + Facing.offsetsZForSide[par5];
    int var9 = 0;

    while (true) {
      int var10;

      if (var9 < 13) {
        if (var7 <= 0 || var7 >= 255) {
          return false;
        }

        var10 = par1World.getBlockId(var6, var7, var8);

        if (var10 != 0) {
          if (!canPushBlock(var10, par1World, var6, var7, var8, true)) {
            return false;
          }

          if (Block.blocksList[var10].getMobilityFlag() != 1) {
            if (var9 == 12) {
              return false;
            }

            var6 += Facing.offsetsXForSide[par5];
            var7 += Facing.offsetsYForSide[par5];
            var8 += Facing.offsetsZForSide[par5];
            ++var9;
            continue;
          }

          Block.blocksList[var10].dropBlockAsItem(
              par1World, var6, var7, var8, par1World.getBlockMetadata(var6, var7, var8), 0);
          par1World.setBlockToAir(var6, var7, var8);
        }
      }

      var9 = var6;
      var10 = var7;
      int var11 = var8;
      int var12 = 0;
      int[] var13;
      int var14;
      int var15;
      int var16;

      for (var13 = new int[13]; var6 != par2 || var7 != par3 || var8 != par4; var8 = var16) {
        var14 = var6 - Facing.offsetsXForSide[par5];
        var15 = var7 - Facing.offsetsYForSide[par5];
        var16 = var8 - Facing.offsetsZForSide[par5];
        int var17 = par1World.getBlockId(var14, var15, var16);
        int var18 = par1World.getBlockMetadata(var14, var15, var16);

        if (var17 == this.blockID && var14 == par2 && var15 == par3 && var16 == par4) {
          par1World.setBlock(
              var6, var7, var8, Block.pistonMoving.blockID, par5 | (this.isSticky ? 8 : 0), 4);
          par1World.setBlockTileEntity(
              var6,
              var7,
              var8,
              BlockPistonMoving.getTileEntity(
                  Block.pistonExtension.blockID,
                  par5 | (this.isSticky ? 8 : 0),
                  par5,
                  true,
                  false));
        } else {
          par1World.setBlock(var6, var7, var8, Block.pistonMoving.blockID, var18, 4);
          par1World.setBlockTileEntity(
              var6, var7, var8, BlockPistonMoving.getTileEntity(var17, var18, par5, true, false));
        }

        var13[var12++] = var17;
        var6 = var14;
        var7 = var15;
      }

      var6 = var9;
      var7 = var10;
      var8 = var11;

      for (var12 = 0; var6 != par2 || var7 != par3 || var8 != par4; var8 = var16) {
        var14 = var6 - Facing.offsetsXForSide[par5];
        var15 = var7 - Facing.offsetsYForSide[par5];
        var16 = var8 - Facing.offsetsZForSide[par5];
        par1World.notifyBlocksOfNeighborChange(var14, var15, var16, var13[var12++]);
        var6 = var14;
        var7 = var15;
      }

      return true;
    }
  }
예제 #23
0
  /** Ticks the block if it's been scheduled */
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    if (!par1World.getGameRules().getGameRuleBooleanValue("doFireTick")) {
      return;
    }
    if (oldFire) {
      updateTickOld(par1World, par2, par3, par4, par5Random);
      return;
    }

    boolean flag = par1World.getBlockId(par2, par3 - 1, par4) == Block.netherrack.blockID;

    if ((par1World.provider instanceof WorldProviderEnd)
        && par1World.getBlockId(par2, par3 - 1, par4) == Block.bedrock.blockID) {
      flag = true;
    }

    if (!canPlaceBlockAt(par1World, par2, par3, par4)) {
      par1World.setBlockToAir(par2, par3, par4);
    }

    if (!flag
        && par1World.isRaining()
        && (par1World.canLightningStrikeAt(par2, par3, par4)
            || par1World.canLightningStrikeAt(par2 - 1, par3, par4)
            || par1World.canLightningStrikeAt(par2 + 1, par3, par4)
            || par1World.canLightningStrikeAt(par2, par3, par4 - 1)
            || par1World.canLightningStrikeAt(par2, par3, par4 + 1))) {
      par1World.setBlockToAir(par2, par3, par4);
      return;
    }

    int i = par1World.getBlockMetadata(par2, par3, par4);

    if (i < 15) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, i + par5Random.nextInt(3) / 2, 4);
    }

    par1World.scheduleBlockUpdate(
        par2, par3, par4, blockID, tickRate(par1World) + par5Random.nextInt(10));

    if (!flag && !canNeighborBurn(par1World, par2, par3, par4)) {
      if (!par1World.doesBlockHaveSolidTopSurface(par2, par3 - 1, par4) || i > 3) {
        par1World.setBlockToAir(par2, par3, par4);
      }

      return;
    }

    if (!flag
        && !canBlockCatchFire(par1World, par2, par3 - 1, par4)
        && i == 15
        && par5Random.nextInt(4) == 0) {
      par1World.setBlockToAir(par2, par3, par4);
      return;
    }

    boolean flag1 = par1World.isBlockHighHumidity(par2, par3, par4);
    byte byte0 = 0;

    if (flag1) {
      byte0 = -50;
    }

    tryToCatchBlockOnFire(par1World, par2 + 1, par3, par4, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2 - 1, par3, par4, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3 - 1, par4, 250 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3 + 1, par4, 250 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3, par4 - 1, 300 + byte0, par5Random, i);
    tryToCatchBlockOnFire(par1World, par2, par3, par4 + 1, 300 + byte0, par5Random, i);

    for (int j = par2 - 1; j <= par2 + 1; j++) {
      for (int k = par4 - 1; k <= par4 + 1; k++) {
        for (int l = par3 - 1; l <= par3 + 4; l++) {
          if (j == par2 && l == par3 && k == par4) {
            continue;
          }

          int i1 = 100;

          if (l > par3 + 1) {
            i1 += (l - (par3 + 1)) * 100;
          }

          int j1 = getChanceOfNeighborsEncouragingFire(par1World, j, l, k);

          if (j1 <= 0) {
            continue;
          }

          int k1 = (j1 + 40 + (fixedDamage ? 0 : par1World.difficultySetting * 7)) / (i + 30);

          if (flag1) {
            k1 /= 2;
          }

          if (k1 <= 0
              || par5Random.nextInt(i1) > k1
              || par1World.isRaining() && par1World.canLightningStrikeAt(j, l, k)
              || par1World.canLightningStrikeAt(j - 1, l, par4)
              || par1World.canLightningStrikeAt(j + 1, l, k)
              || par1World.canLightningStrikeAt(j, l, k - 1)
              || par1World.canLightningStrikeAt(j, l, k + 1)) {
            continue;
          }

          int l1 = i + par5Random.nextInt(5) / 4;

          if (l1 > 15) {
            l1 = 15;
          }

          par1World.setBlock(j, l, k, blockID, l1, 3);
        }
      }
    }
  }
예제 #24
0
 /**
  * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
  * (coordinates passed are their own) Args: x, y, z, neighbor blockID
  */
 public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5) {
   if (par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
     this.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
     par1World.setBlockToAir(par2, par3, par4);
   }
 }