@Override
  public void harvestBlock(World world, EntityPlayer entityplayer, int i, int j, int k, int l) {
    // we need to make sure the player has the correct tool out
    boolean isAxeorSaw = false;
    boolean isHammer = false;
    ItemStack equip = entityplayer.getCurrentEquippedItem();
    if (!world.isRemote) {
      if (equip != null) {
        for (int cnt = 0; cnt < Recipes.Axes.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Axes[cnt]) {
            isAxeorSaw = true;
            if (cnt < 4) isStone = true;
          }
        }
        //				for(int cnt = 0; cnt < Recipes.Saws.length && !isAxeorSaw; cnt++)
        //				{
        //					if(equip.getItem() == Recipes.Saws[cnt])
        //					{
        //						isAxeorSaw = true;
        //					}
        //				}
        for (int cnt = 0; cnt < Recipes.Hammers.length && !isAxeorSaw; cnt++) {
          if (equip.getItem() == Recipes.Hammers[cnt]) {
            isHammer = true;
          }
        }
      }
      if (isAxeorSaw) {
        damage = -1;
        ProcessTree(world, i, j, k, l, equip);

        if (damage + equip.getItemDamage() > equip.getMaxDamage()) {
          int ind = entityplayer.inventory.currentItem;
          entityplayer.inventory.setInventorySlotContents(ind, null);
          world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
        } else {
          equip.damageItem(damage, entityplayer);
        }
      } else if (isHammer) {
        EntityItem item =
            new EntityItem(
                world,
                i + 0.5,
                j + 0.5,
                k + 0.5,
                new ItemStack(Item.stick, 1 + world.rand.nextInt(3)));
        world.spawnEntityInWorld(item);
      } else {
        world.setBlockAndMetadataWithNotify(i, j, k, blockID, l, 3);
      }
    }
  }
 @Override
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (j < 253) {
     if (world.getBlockId(i, j + 1, k) == 0) {
       world.setBlockAndMetadataWithNotify(i, j + 1, k, blockID, world.getBlockMetadata(i, j, k));
       world.scheduleBlockUpdate(i, j + 1, k, blockID, 5);
     }
   } else if (world.getBlockMetadata(i, j, k) == 1) {
     world.setBlockMetadata(i, j, k, 0);
     world.setBlockAndMetadataWithNotify(i, j + 1, k, TooManyPlants.objs.blockpod.blockID, 1);
     world.setBlockWithNotify(i, j + 2, k, TooManyPlants.objs.blockpod.blockID);
   }
 }
  /** Checks if the dragon egg can fall down, and if so, makes it fall. */
  private void fallIfPossible(World par1World, int par2, int par3, int par4) {
    if (BlockSand.canFallBelow(par1World, par2, par3 - 1, par4) && par3 >= 0) {
      byte b0 = 32;

      if (!BlockSand.fallInstantly
          && par1World.checkChunksExist(
              par2 - b0, par3 - b0, par4 - b0, par2 + b0, par3 + b0, par4 + b0)) {
        EntityFallingSand entityfallingsand =
            new EntityFallingSand(
                par1World,
                (double) ((float) par2 + 0.5F),
                (double) ((float) par3 + 0.5F),
                (double) ((float) par4 + 0.5F),
                this.blockID);
        par1World.spawnEntityInWorld(entityfallingsand);
      } else {
        par1World.func_94571_i(par2, par3, par4);

        while (BlockSand.canFallBelow(par1World, par2, par3 - 1, par4) && par3 > 0) {
          --par3;
        }

        if (par3 > 0) {
          par1World.setBlockAndMetadataWithNotify(par2, par3, par4, this.blockID, 0, 2);
        }
      }
    }
  }
  @Override
  public boolean doPlant(ItemStack germling, World world, int x, int y, int z) {
    int blockid = world.getBlockId(x, y, z);

    // Target block needs to be empty
    if (blockid != 0) return false;

    // Can only plant on tilled fields
    int below = world.getBlockId(x, y - 1, z);
    if (below != Block.tilledField.blockID) return false;

    if (germling.itemID == Item.pumpkinSeeds.itemID) {
      world.setBlockAndMetadataWithNotify(x, y, z, Block.pumpkinStem.blockID, 0);
    } else {
      world.setBlockAndMetadataWithNotify(x, y, z, Block.melonStem.blockID, 0);
    }
    return true;
  }
 /** Ticks the block if it's been scheduled */
 public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
   if (!par1World.isRemote
       && this.powered
       && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
     int m = par1World.getBlockMetadata(par2, par3, par4);
     par1World.setBlockAndMetadataWithNotify(
         par2, par3, par4, MinecraftPlusBase.holidaylights_1Idle.blockID, m);
   }
 }
 /** 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.isRemote) {
     if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
       par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
     } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
       int m = par1World.getBlockMetadata(par2, par3, par4);
       par1World.setBlockAndMetadataWithNotify(
           par2, par3, par4, MinecraftPlusBase.holidaylights_1Active.blockID, m);
     }
   }
 }
  private void flowIntoBlock(World world, int x, int y, int z, int meta, int tex) {
    if (liquidCanDisplaceBlock(world, x, y, z)) {
      int bID = world.getBlockId(x, y, z);
      if (bID > 0) {
        Block.blocksList[bID].dropBlockAsItem(world, x, y, z, world.getBlockMetadata(x, y, z), 0);
      }
      world.setBlockAndMetadataWithNotify(x, y, z, blockID, meta);

      ((LiquidTextureLogic) world.getBlockTileEntity(x, y, z)).setTexturePos(tex);
    }
  }
  /**
   * Called when the block is placed in the world. <Cojo> so for all "flowing" blocks i would set
   * the metadata to current metadata | 0x2
   */
  public void onBlockPlacedBy(
      World par1World, int par2, int par3, int par4, EntityLiving par5EntityLiving) {
    int var6 =
        MathHelper.floor_double((double) (par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;

    byte meta = 0x0;

    if (var6 == 0) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, 0x0);
      meta = 0x0;
    }

    if (var6 == 1) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, 0x1);
      meta = 0x1;
    }

    if (var6 == 2) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, 0x0);
      meta = 0x0;
    }

    if (var6 == 3) {
      par1World.setBlockMetadataWithNotify(par2, par3, par4, 0x1);
      meta = 0x1;
    }

    int y = 1;

    boolean shouldGenFountain = false;

    while (par1World.isAirBlock(par2, par3 - y, par4)) {

      int id = par1World.getBlockId(par2, par3 - y - 1, par4);

      if (!par1World.isAirBlock(par2, par3 - y - 1, par4)
          && (id == TropicraftMod.waterMovingTropics.blockID
              || id == TropicraftMod.waterStillTropics.blockID)) {
        shouldGenFountain = true;
      }

      y++;
    }

    y = 1;

    if (shouldGenFountain) {
      while (par1World.isAirBlock(par2, par3 - y, par4)) {
        par1World.setBlockAndMetadataWithNotify(par2, par3 - y, par4, blockID, meta | 0x2);

        y++;
      }
    }
  }
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    for (int l = 0; l < 10; ++l) {
      int i1 = par3 + par2Random.nextInt(8) - par2Random.nextInt(8);
      int j1 = par4 + par2Random.nextInt(4) - par2Random.nextInt(4);
      int k1 = par5 + par2Random.nextInt(8) - par2Random.nextInt(8);

      if (par1World.isAirBlock(i1, j1, k1)
          && Block.waterlily.canPlaceBlockAt(par1World, i1, j1, k1)) {
        par1World.setBlockAndMetadataWithNotify(i1, j1, k1, Block.waterlily.blockID, 0, 2);
      }
    }

    return true;
  }
  /**
   * flowIntoBlock(World world, int x, int y, int z, int newFlowDecay) - Flows into the block at the
   * coordinates and changes the block type to the liquid.
   */
  private void flowIntoBlock(World par1World, int par2, int par3, int par4, int par5) {
    if (this.liquidCanDisplaceBlock(par1World, par2, par3, par4)) {
      int var6 = par1World.getBlockId(par2, par3, par4);

      if (var6 > 0) {
        if (this.blockMaterial == Material.lava) {
          this.triggerLavaMixEffects(par1World, par2, par3, par4);
        } else {
          Block.blocksList[var6].dropBlockAsItem(
              par1World, par2, par3, par4, par1World.getBlockMetadata(par2, par3, par4), 0);
        }
      }

      par1World.setBlockAndMetadataWithNotify(par2, par3, par4, this.blockID, par5);
    }
  }
  @Override
  public boolean doPlant(ItemStack germling, World world, int x, int y, int z) {
    int blockid = world.getBlockId(x, y, z);

    // Target block needs to be empty
    if (blockid != 0) return false;

    // Can only plant on soulsand
    int below = world.getBlockId(x, y - 1, z);
    int meta = world.getBlockMetadata(x, y - 1, z);
    if (below != ForestryBlock.soil.blockID || (meta & 0x03) != 0) return false;

    world.setBlockAndMetadataWithNotify(
        x, y, z, ForestryBlock.sapling.blockID, germling.getItemDamage());
    return true;
  }
  /** Teleports the dragon egg somewhere else in a 31x19x31 area centered on the egg. */
  private void teleportNearby(World par1World, int par2, int par3, int par4) {
    if (par1World.getBlockId(par2, par3, par4) == this.blockID) {
      for (int l = 0; l < 1000; ++l) {
        int i1 = par2 + par1World.rand.nextInt(16) - par1World.rand.nextInt(16);
        int j1 = par3 + par1World.rand.nextInt(8) - par1World.rand.nextInt(8);
        int k1 = par4 + par1World.rand.nextInt(16) - par1World.rand.nextInt(16);

        if (par1World.getBlockId(i1, j1, k1) == 0) {
          if (!par1World.isRemote) {
            par1World.setBlockAndMetadataWithNotify(
                i1, j1, k1, this.blockID, par1World.getBlockMetadata(par2, par3, par4), 2);
            par1World.func_94571_i(par2, par3, par4);
          } else {
            short short1 = 128;

            for (int l1 = 0; l1 < short1; ++l1) {
              double d0 = par1World.rand.nextDouble();
              float f = (par1World.rand.nextFloat() - 0.5F) * 0.2F;
              float f1 = (par1World.rand.nextFloat() - 0.5F) * 0.2F;
              float f2 = (par1World.rand.nextFloat() - 0.5F) * 0.2F;
              double d1 =
                  (double) i1
                      + (double) (par2 - i1) * d0
                      + (par1World.rand.nextDouble() - 0.5D) * 1.0D
                      + 0.5D;
              double d2 =
                  (double) j1
                      + (double) (par3 - j1) * d0
                      + par1World.rand.nextDouble() * 1.0D
                      - 0.5D;
              double d3 =
                  (double) k1
                      + (double) (par4 - k1) * d0
                      + (par1World.rand.nextDouble() - 0.5D) * 1.0D
                      + 0.5D;
              par1World.spawnParticle("portal", d1, d2, d3, (double) f, (double) f1, (double) f2);
            }
          }

          return;
        }
      }
    }
  }
Beispiel #13
0
  public boolean onItemUse(
      ItemStack item,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float par8,
      float par9,
      float par10) {
    if (world.isRemote) {
      return true;
    } else if (side != 1) {
      // not the top of a block
      return false;
    } else {
      y++;

      Block blockToPlace = mod_jaffas.blockSink;
      int direction =
          MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
      direction = (direction + 3) % 4;

      if (player.canPlayerEdit(x, y, z, side, item)
          && player.canPlayerEdit(x, y + 1, z, side, item)) {
        if (world.isAirBlock(x, y, z) && world.isAirBlock(x, y + 1, z)) {
          world.setBlockAndMetadataWithNotify(x, y, z, blockToPlace.blockID, direction);

          --item.stackSize;
          return true;
        } else {
          return false;
        }
      } else {
        return false;
      }
    }
  }
  private void tryToCatchBlockOnFire(
      World par1World, int par2, int par3, int par4, int par5, Random par6Random, int par7) {
    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.setBlockAndMetadataWithNotify(par2, par3, par4, blockID, j);
      } else {
        par1World.setBlockWithNotify(par2, par3, par4, 0);
      }

      if (flag) {
        Block.tnt.onBlockDestroyedByPlayer(par1World, par2, par3, par4, 1);
      }
    }
  }
  /**
   * 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) {
      if (this.powered && !par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
        par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, 4);
      } else if (!this.powered && par1World.isBlockIndirectlyGettingPowered(par2, par3, par4)) {
        int m = par1World.getBlockMetadata(par2, par3, par4);
        par1World.setBlockAndMetadataWithNotify(
            par2, par3, par4, MinecraftPlusBase.holidaylights_1Active.blockID, m);
      }
    }
    int var6 = par1World.getBlockMetadata(par2, par3, par4);
    boolean var7 = false;

    if (var6 == 2 && par1World.isBlockSolidOnSide(par2, par3, par4 + 1, NORTH)) {
      var7 = true;
    }

    if (var6 == 3 && par1World.isBlockSolidOnSide(par2, par3, par4 - 1, SOUTH)) {
      var7 = true;
    }

    if (var6 == 4 && par1World.isBlockSolidOnSide(par2 + 1, par3, par4, WEST)) {
      var7 = true;
    }

    if (var6 == 5 && par1World.isBlockSolidOnSide(par2 - 1, par3, par4, EAST)) {
      var7 = true;
    }

    if (!var7) {
      this.dropBlockAsItem(par1World, par2, par3, par4, var6, 0);
      par1World.setBlockWithNotify(par2, par3, par4, 0);
    }

    super.onNeighborBlockChange(par1World, par2, par3, par4, par5);
  }
  private boolean moveToBlock(World world, int x, int y, int z, int x2, int y2, int z2) {
    int blockID2 = world.getBlockId(x2, y2, z2);
    int originMeta = world.getBlockMetadata(x, y, z);
    int destMeta = world.getBlockMetadata(x2, y2, z2);
    if (blockID2 == this.blockID) {
      if (destMeta > originMeta || y > y2) {
        if (originMeta < 7 && destMeta > 0) {
          world.setBlockMetadata(x, y, z, originMeta + 1);
          world.markBlockForUpdate(x, y, z);
          world.setBlockMetadata(x2, y2, z2, destMeta - 1);
          world.markBlockForUpdate(x2, y2, z2);
          return true;
        } else if (destMeta > 0) {
          world.setBlockWithNotify(x, y, z, 0);
          world.markBlockForUpdate(x, y, z);
          world.setBlockMetadata(x2, y2, z2, destMeta - 1);
          world.markBlockForUpdate(x2, y2, z2);
          return true;
        } else {
          return false;
        }
      } else {
        return false;
      }
    } else if (liquidCanDisplaceBlock(world, x2, y2, z2)) {
      if (blockID2 > 0) {
        if (this.blockMaterial == Material.lava) {
          this.triggerLavaMixEffects(world, x2, y2, z2);
        } else if (blockID2 == Block.waterMoving.blockID || blockID2 == Block.waterStill.blockID) {
          if (originMeta < 7) {
            world.setBlockMetadataWithNotify(x, y, z, originMeta + 1);
            world.markBlockForUpdate(x, y, z);
            return true;
          } else {
            world.setBlockWithNotify(x, y, z, 0);
            world.markBlockForUpdate(x, y, z);
            return true;
          }
        } else {
          Block.blocksList[blockID2].dropBlockAsItem(
              world, x2, y2, z2, world.getBlockMetadata(x2, y2, z2), 0);
        }
      }

      if (y2 < y) {
        world.setBlockWithNotify(x, y, z, 0);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, originMeta);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      }
      if (originMeta < 7) {
        world.setBlockMetadataWithNotify(x, y, z, originMeta + 1);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, 7);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      } else if (world.getBlockId(x - 1, y, z) != this.blockID
          && world.getBlockId(x + 1, y, z) != this.blockID
          && world.getBlockId(x, y + 1, z) != this.blockID
          && world.getBlockId(x, y, z - 1) != this.blockID
          && world.getBlockId(x, y, z + 1) != this.blockID) {
        world.setBlockWithNotify(x, y, z, 0);
        return true;
      } else {
        world.setBlockWithNotify(x, y, z, 0);
        world.markBlockForUpdate(x, y, z);
        world.setBlockAndMetadataWithNotify(x2, y2, z2, blockID, 7);
        world.markBlockForUpdate(x2, y2, z2);
        return true;
      }
    } else {
      return false;
    }
  }
Beispiel #17
0
  /**
   * Callback for item usage. If the item does something special on right clicking, he will have one
   * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS
   */
  public boolean onItemUse(
      ItemStack par1ItemStack,
      EntityPlayer par2EntityPlayer,
      World par3World,
      int par4,
      int par5,
      int par6,
      int par7,
      float par8,
      float par9,
      float par10) {
    int i1 = par3World.getBlockId(par4, par5, par6);
    int j1 = par3World.getBlockMetadata(par4, par5, par6);

    if (par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)
        && i1 == Block.endPortalFrame.blockID
        && !BlockEndPortalFrame.isEnderEyeInserted(j1)) {
      if (par3World.isRemote) {
        return true;
      } else {
        par3World.setBlockMetadataWithNotify(par4, par5, par6, j1 + 4, 2);
        --par1ItemStack.stackSize;
        int k1;

        for (k1 = 0; k1 < 16; ++k1) {
          double d0 = (double) ((float) par4 + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F);
          double d1 = (double) ((float) par5 + 0.8125F);
          double d2 = (double) ((float) par6 + (5.0F + itemRand.nextFloat() * 6.0F) / 16.0F);
          double d3 = 0.0D;
          double d4 = 0.0D;
          double d5 = 0.0D;
          par3World.spawnParticle("smoke", d0, d1, d2, d3, d4, d5);
        }

        k1 = j1 & 3;
        int l1 = 0;
        int i2 = 0;
        boolean flag = false;
        boolean flag1 = true;
        int j2 = Direction.enderEyeMetaToDirection[k1];
        int k2;
        int l2;
        int i3;
        int j3;
        int k3;

        for (k2 = -2; k2 <= 2; ++k2) {
          j3 = par4 + Direction.offsetX[j2] * k2;
          l2 = par6 + Direction.offsetZ[j2] * k2;
          k3 = par3World.getBlockId(j3, par5, l2);

          if (k3 == Block.endPortalFrame.blockID) {
            i3 = par3World.getBlockMetadata(j3, par5, l2);

            if (!BlockEndPortalFrame.isEnderEyeInserted(i3)) {
              flag1 = false;
              break;
            }

            i2 = k2;

            if (!flag) {
              l1 = k2;
              flag = true;
            }
          }
        }

        if (flag1 && i2 == l1 + 2) {
          for (k2 = l1; k2 <= i2; ++k2) {
            j3 = par4 + Direction.offsetX[j2] * k2;
            l2 = par6 + Direction.offsetZ[j2] * k2;
            j3 += Direction.offsetX[k1] * 4;
            l2 += Direction.offsetZ[k1] * 4;
            k3 = par3World.getBlockId(j3, par5, l2);
            i3 = par3World.getBlockMetadata(j3, par5, l2);

            if (k3 != Block.endPortalFrame.blockID || !BlockEndPortalFrame.isEnderEyeInserted(i3)) {
              flag1 = false;
              break;
            }
          }

          for (k2 = l1 - 1; k2 <= i2 + 1; k2 += 4) {
            for (j3 = 1; j3 <= 3; ++j3) {
              l2 = par4 + Direction.offsetX[j2] * k2;
              k3 = par6 + Direction.offsetZ[j2] * k2;
              l2 += Direction.offsetX[k1] * j3;
              k3 += Direction.offsetZ[k1] * j3;
              i3 = par3World.getBlockId(l2, par5, k3);
              int l3 = par3World.getBlockMetadata(l2, par5, k3);

              if (i3 != Block.endPortalFrame.blockID
                  || !BlockEndPortalFrame.isEnderEyeInserted(l3)) {
                flag1 = false;
                break;
              }
            }
          }

          if (flag1) {
            for (k2 = l1; k2 <= i2; ++k2) {
              for (j3 = 1; j3 <= 3; ++j3) {
                l2 = par4 + Direction.offsetX[j2] * k2;
                k3 = par6 + Direction.offsetZ[j2] * k2;
                l2 += Direction.offsetX[k1] * j3;
                k3 += Direction.offsetZ[k1] * j3;
                par3World.setBlockAndMetadataWithNotify(
                    l2, par5, k3, Block.endPortal.blockID, 0, 2);
              }
            }
          }
        }

        return true;
      }
    } else {
      return false;
    }
  }
 @Override
 public void updateTick(World world, int x, int y, int z, Random random) {
   // System.out.println("x: "+x+", y: "+y+", z: "+z);
   int tex = ((LiquidTextureLogic) world.getBlockTileEntity(x, y, z)).getLiquidType();
   int l = getFlowDecay(world, x, y, z);
   byte byte0 = 1;
   boolean flag = true;
   if (l > 0) {
     int i1 = -100;
     i1 = getSmallestFlowDecay(world, x - 1, y, z, i1);
     i1 = getSmallestFlowDecay(world, x + 1, y, z, i1);
     i1 = getSmallestFlowDecay(world, x, y, z - 1, i1);
     i1 = getSmallestFlowDecay(world, x, y, z + 1, i1);
     int j1 = i1 + byte0;
     if (j1 >= 8 || i1 < 0) {
       j1 = -1;
     }
     if (getFlowDecay(world, x, y + 1, z) >= 0) {
       int l1 = getFlowDecay(world, x, y + 1, z);
       if (l1 >= 8) {
         j1 = l1;
       } else {
         j1 = l1 + 8;
       }
     }
     if (j1 != l) {
       l = j1;
       if (l < 0) {
         world.setBlockWithNotify(x, y, z, 0);
       } else {
         world.setBlockMetadataWithNotify(x, y, z, l);
         world.scheduleBlockUpdate(x, y, z, blockID, tickRate());
         world.notifyBlocksOfNeighborChange(x, y, z, blockID);
       }
     } else if (flag) {
       updateFlow(world, x, y, z);
     }
   } else {
     updateFlow(world, x, y, z);
   }
   if (liquidCanDisplaceBlock(world, x, y - 1, z)) {
     if (l >= 8) {
       world.setBlockAndMetadataWithNotify(x, y - 1, z, blockID, l);
     } else {
       world.setBlockAndMetadataWithNotify(x, y - 1, z, blockID, l + 8);
     }
     ((LiquidTextureLogic) world.getBlockTileEntity(x, y - 1, z)).setTexturePos(tex);
   } else if (l >= 0 && (l == 0 || blockBlocksFlow(world, x, y - 1, z))) {
     boolean aflag[] = getOptimalFlowDirections(world, x, y, z);
     int k1 = l + byte0;
     if (l >= 8) {
       k1 = 1;
     }
     if (k1 >= 8) return;
     if (aflag[0]) {
       flowIntoBlock(world, x - 1, y, z, k1, tex);
     }
     if (aflag[1]) {
       flowIntoBlock(world, x + 1, y, z, k1, tex);
     }
     if (aflag[2]) {
       flowIntoBlock(world, x, y, z - 1, k1, tex);
     }
     if (aflag[3]) {
       flowIntoBlock(world, x, y, z + 1, k1, tex);
     }
   }
 }
  /** Ticks the block if it's been scheduled */
  @Override
  public void updateTick(World par1World, int par2, int par3, int par4, Random par5Random) {
    boolean flag = par1World.getBlockId(par2, par3 - 1, par4) == Block.netherrack.blockID;

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

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

    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.setBlockWithNotify(par2, par3, par4, 0);
      return;
    }

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

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

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

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

      return;
    }

    if (!flag
        && !canBlockCatchFire(par1World, par2, par3 - 1, par4)
        && i == 15
        && par5Random.nextInt(4) == 0) {
      par1World.setBlockWithNotify(par2, par3, par4, 0);
      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) / (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.setBlockAndMetadataWithNotify(j, l, k, blockID, l1);
        }
      }
    }
  }