private void checkForHarden(World world, int i, int j, int k) {
   Material material = blockMaterial;
   Material material1 = Material.water;
   if (material == Material.water) {
     material1 = Material.lava;
   }
   boolean flag = false;
   if (flag || world.getBlockMaterial(i, j, k - 1) == material1) {
     flag = true;
   }
   if (flag || world.getBlockMaterial(i, j, k + 1) == material1) {
     flag = true;
   }
   if (flag || world.getBlockMaterial(i - 1, j, k) == material1) {
     flag = true;
   }
   if (flag || world.getBlockMaterial(i + 1, j, k) == material1) {
     flag = true;
   }
   if (flag || world.getBlockMaterial(i, j + 1, k) == material1) {
     flag = true;
   }
   if (flag) {
     if (material == Material.lava) {
       world.setBlockWithNotify(i, j, k, Block.obsidian.blockID);
     } else {
       world.setBlockWithNotify(i, j, k, Block.cobblestone.blockID);
     }
   }
 }
  @Override
  public boolean generate(World par1World, Random par2Random, int par3, int par4, int par5) {
    if (par1World.getBlockMaterial(par3, par4, par5) != Material.water) return false;
    else {
      int var6 = par2Random.nextInt(radius - 2) + 2;
      byte var7 = 2;

      for (int var8 = par3 - var6; var8 <= par3 + var6; ++var8) {
        for (int var9 = par5 - var6; var9 <= par5 + var6; ++var9) {
          int var10 = var8 - par3;
          int var11 = var9 - par5;

          if (var10 * var10 + var11 * var11 <= var6 * var6) {
            for (int var12 = par4 - var7; var12 <= par4 + var7; ++var12) {
              int var13 = par1World.getBlockId(var8, var12, var9);

              if (var13 == Block.sand.blockID) {
                par1World.setBlock(var8, var12, var9, sandID);
              }
            }
          }
        }
      }

      return true;
    }
  }
 /** Returns true if the block at the coordinates can be displaced by the liquid. */
 private boolean liquidCanDisplaceBlock(
     final World par1World, final int par2, final int par3, final int par4) {
   final Material var5 = par1World.getBlockMaterial(par2, par3, par4);
   return var5 == this.blockMaterial
       ? false
       : (var5 == Material.lava ? false : !this.blockBlocksFlow(par1World, par2, par3, par4));
 }
  /**
   * calculateFlowCost(World world, int x, int y, int z, int accumulatedCost, int
   * previousDirectionOfFlow) - Used to determine the path of least resistance, this method returns
   * the lowest possible flow cost for the direction of flow indicated. Each necessary horizontal
   * flow adds to the flow cost.
   */
  private int calculateFlowCost(
      final World par1World,
      final int par2,
      final int par3,
      final int par4,
      final int par5,
      final int par6) {
    int var7 = 1000;

    for (int var8 = 0; var8 < 4; ++var8) {
      if (((var8 != 0) || (par6 != 1))
          && ((var8 != 1) || (par6 != 0))
          && ((var8 != 2) || (par6 != 3))
          && ((var8 != 3) || (par6 != 2))) {
        int var9 = par2;
        int var11 = par4;

        if (var8 == 0) {
          var9 = par2 - 1;
        }

        if (var8 == 1) {
          ++var9;
        }

        if (var8 == 2) {
          var11 = par4 - 1;
        }

        if (var8 == 3) {
          ++var11;
        }

        if (!this.blockBlocksFlow(par1World, var9, par3, var11)
            && ((par1World.getBlockMaterial(var9, par3, var11) != this.blockMaterial)
                || (par1World.getBlockMetadata(var9, par3, var11) != 0))) {
          if (!this.blockBlocksFlow(par1World, var9, par3 - 1, var11)) {
            return par5;
          }

          if (par5 < 4) {
            final int var12 = this.calculateFlowCost(par1World, var9, par3, var11, par5 + 1, var8);

            if (var12 < var7) {
              var7 = var12;
            }
          }
        }
      }
    }

    return var7;
  }
Beispiel #5
0
  private int getBlockColor(World world, int x, int y, int z) {
    int color24 = 0;

    try {
      if (MinimapConfig.getInstance().isColor() && !MinimapConfig.getInstance().isCavemap()) {
        if (x == (int) map.getPlayerX() && z == (int) map.getPlayerZ()) return 0xff0000;
        if ((world.getBlockMaterial(x, y + 1, z) == Material.ice)
            || (world.getBlockMaterial(x, y + 1, z) == Material.snow)) {
          color24 = 0xffffff;
        } else {
          BlockColor col =
              BlockColor.getBlockColor(world.getBlockId(x, y, z), world.getBlockMetadata(x, y, z));
          color24 = col.color;
        }
      }
    } catch (Exception e) {
      return 0;
    }

    return color24;
  }
  /**
   * Returns a boolean array indicating which flow directions are optimal based on each direction's
   * calculated flow cost. Each array index corresponds to one of the four cardinal directions. A
   * value of true indicates the direction is optimal.
   */
  private boolean[] getOptimalFlowDirections(
      final World par1World, final int par2, final int par3, final int par4) {
    int var5;
    int var6;

    for (var5 = 0; var5 < 4; ++var5) {
      this.flowCost[var5] = 1000;
      var6 = par2;
      int var8 = par4;

      if (var5 == 0) {
        var6 = par2 - 1;
      }

      if (var5 == 1) {
        ++var6;
      }

      if (var5 == 2) {
        var8 = par4 - 1;
      }

      if (var5 == 3) {
        ++var8;
      }

      if (!this.blockBlocksFlow(par1World, var6, par3, var8)
          && ((par1World.getBlockMaterial(var6, par3, var8) != this.blockMaterial)
              || (par1World.getBlockMetadata(var6, par3, var8) != 0))) {
        if (this.blockBlocksFlow(par1World, var6, par3 - 1, var8)) {
          this.flowCost[var5] = this.calculateFlowCost(par1World, var6, par3, var8, 1, var5);
        } else {
          this.flowCost[var5] = 0;
        }
      }
    }

    var5 = this.flowCost[0];

    for (var6 = 1; var6 < 4; ++var6) {
      if (this.flowCost[var6] < var5) {
        var5 = this.flowCost[var6];
      }
    }

    for (var6 = 0; var6 < 4; ++var6) {
      this.isOptimalFlowDirection[var6] = this.flowCost[var6] == var5;
    }

    return this.isOptimalFlowDirection;
  }
  /** Ticks the block if it's been scheduled */
  @Override
  public void updateTick(
      final World par1World,
      final int par2,
      final int par3,
      final int par4,
      final 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 var10;

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

      if ((var10 >= 8) || (var12 < 0)) {
        var10 = -1;
      }

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

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

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

      if ((this.blockMaterial == Material.lava)
          && (var6 < 8)
          && (var10 < 8)
          && (var10 > var6)
          && (par5Random.nextInt(4) != 0)) {
        var10 = var6;
        var8 = false;
      }

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

        if (var10 < 0) {
          par1World.setBlockWithNotify(par2, par3, par4, 0);
        } else {
          par1World.setBlockMetadataWithNotify(par2, par3, par4, var10);
          par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID, this.tickRate());
          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.setBlockWithNotify(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))) {
      final boolean[] var13 = this.getOptimalFlowDirections(par1World, par2, par3, par4);
      var10 = var6 + var7;

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

      if (var10 >= 8) {
        return;
      }

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

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

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

      if (var13[3]) {
        this.flowIntoBlock(par1World, par2, par3, par4 + 1, var10);
      }
    }
  }
  public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
    float var4 = 1.0F;
    double var5 = player.prevPosX + (player.posX - player.prevPosX) * (double) var4;
    double var7 =
        player.prevPosY
            + (player.posY - player.prevPosY) * (double) var4
            + 1.62D
            - (double) player.yOffset;
    double var9 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) var4;
    boolean var11 = this.isFull == 0;
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, var11);

    if (mop == null) {
      return itemstack;
    }
    if (mop.typeOfHit == EnumMovingObjectType.TILE) {
      int x = mop.blockX;
      int y = mop.blockY;
      int z = mop.blockZ;
      if (!world.canMineBlock(player, x, y, z)) {
        return itemstack;
      }
      if (isFull == 0) {
        int bID = world.getBlockId(x, y, z);
        if ((bID == Block.waterMoving.blockID || bID == Block.waterStill.blockID)
            && world.getBlockMetadata(x, y, z) == 0) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketWater);
        }
        if ((bID == Block.lavaMoving.blockID || bID == Block.lavaStill.blockID)
            && world.getBlockMetadata(x, y, z) == 0) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketLava);
        }
        if (bID == Block.sand.blockID) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketSand);
        }
        if (bID == Block.gravel.blockID) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketGravel);
        }
      } else {
        if (isFull < 0) {
          return new ItemStack(mod_InfiTools.goldBucketEmpty);
        }
        if (mop.sideHit == 0) {
          y--;
        }
        if (mop.sideHit == 1) {
          y++;
        }
        if (mop.sideHit == 2) {
          z--;
        }
        if (mop.sideHit == 3) {
          z++;
        }
        if (mop.sideHit == 4) {
          x--;
        }
        if (mop.sideHit == 5) {
          x++;
        }
        if (world.isAirBlock(x, y, z) || !world.getBlockMaterial(x, y, z).isSolid()) {
          if (world.worldProvider.isHellWorld && isFull == Block.waterMoving.blockID) {
            world.playSoundEffect(
                x + 0.5D,
                y + 0.5D,
                z + 0.5D,
                "random.fizz",
                0.5F,
                2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
            for (int l = 0; l < 8; l++) {
              world.spawnParticle(
                  "largesmoke",
                  (double) x + Math.random(),
                  (double) y + Math.random(),
                  (double) z + Math.random(),
                  0.0D,
                  0.0D,
                  0.0D);
            }
          } else {
            world.setBlockAndMetadataWithNotify(x, y, z, isFull, 0);
          }
          return new ItemStack(mod_InfiTools.goldBucketEmpty);
        }
      }
    } else if (isFull == 0 && (mop.entityHit instanceof EntityCow)) {
      return new ItemStack(mod_InfiTools.goldBucketMilk);
    }
    return itemstack;
  }