Exemplo n.º 1
0
  /**
   * Do cauldron.
   *
   * @param pt
   * @param player
   * @param world
   */
  public boolean preCauldron(Player player, World world, BlockWorldVector pt) {

    double x = pt.getX();
    double y = pt.getY();
    double z = pt.getZ();

    int ix = pt.getBlockX();
    int iy = pt.getBlockY();
    int iz = pt.getBlockZ();

    double rootY = y;
    int below = world.getBlockTypeIdAt(ix, iy - 1, iz);
    int below2 = world.getBlockTypeIdAt(ix, iy - 2, iz);
    int s1 = world.getBlockTypeIdAt(ix + 1, iy, iz);
    int s3 = world.getBlockTypeIdAt(ix - 1, iy, iz);
    int s2 = world.getBlockTypeIdAt(ix, iy, iz + 1);
    int s4 = world.getBlockTypeIdAt(ix, iy, iz - 1);

    int blockID = plugin.getLocalConfiguration().cauldronSettings.cauldronBlock;

    // stop strange lava ids
    if (below == 11) below = 10;
    if (below2 == 11) below2 = 10;
    // Preliminary check so we don't waste CPU cycles
    if ((below == BlockID.LAVA || below2 == BlockID.LAVA)
        && (s1 == blockID || s2 == blockID || s3 == blockID || s4 == blockID)) {
      // Cauldron is 2 units deep
      if (below == BlockID.LAVA) {
        rootY++;
      }
      performCauldron(player, world, new BlockWorldVector(pt.getWorld(), x, rootY, z));
      return true;
    }
    return false;
  }
Exemplo n.º 2
0
  /**
   * Get the set of mechanics in a specified chunk.
   *
   * @param chunk
   * @return the set of mechanics in a specified chunk.
   */
  public Set<PersistentMechanic> getByChunk(BlockWorldVector2D chunk) {

    Set<PersistentMechanic> folks = new HashSet<PersistentMechanic>();
    int chunkX = chunk.getBlockX();
    int chunkZ = chunk.getBlockZ();
    for (Entry<BlockWorldVector, Set<PersistentMechanic>> entry : watchBlocks.entrySet()) {
      BlockWorldVector pos = entry.getKey();

      // Different world! Abort
      if (!pos.getWorld().equals(chunk.getWorld())) {
        continue;
      }

      int curChunkX = (int) Math.floor(pos.getBlockX() / 16.0);
      int curChunkZ = (int) Math.floor(pos.getBlockZ() / 16.0);
      // Not involved in this chunk!
      if (curChunkX != chunkX || curChunkZ != chunkZ) {
        continue;
      }

      folks.addAll(entry.getValue());
    }
    return folks;
  }
Exemplo n.º 3
0
  /**
   * Returns a new BlockWorldVector with i, j, and k added to pt's x, y and z.
   *
   * @param i
   * @param j
   * @param k
   * @param pt
   */
  private BlockWorldVector recurse(int i, int j, int k, BlockWorldVector pt) {

    return new BlockWorldVector(pt.getWorld(), pt.getX() + i, pt.getY() + j, pt.getZ() + k);
  }