Package org.spout.api.geo.cuboid

Examples of org.spout.api.geo.cuboid.Block


   * Returns the amount of levels on the pyramid below this Beacon, this will only account for up to a 4-level pyramid.
   *
   * @return levels on pyramid
   */
  public int getLevels() {
    Block block = getBlock();
    for (int lvl = 1; lvl <= 4; lvl++) {
      for (int dx = -lvl; dx <= lvl; dx++) {
        for (int dz = -lvl; dz <= lvl; dz++) {
          if (!isPyramidMaterial(block.translate(dx, -lvl, dz).getMaterial())) {
            return lvl - 1;
          }
        }
      }
    }
View Full Code Here


   * Returns the amount of bookshelves within a 2 block radius for the X/Z coordinates and 1 block above this enchantment table for the Y coordinate
   *
   * @return Amount of bookshelves near this enchantment table
   */
  public int getNearbyBookshelves() {
    Block block = getBlock();

    // if there are any blocks right next to the enchantment table, bookshelves in that direction are nullified
    // Note: unlike Mojang's version, a block at (x+1,y+1,z) won't nullify a bookshelf at (x+2,y,z)
    int bookshelves = 0;
    for (int dx = -1; dx <= 1; dx++) {
      for (int dz = -1; dz <= 1; dz++) {
        if (dx == 0 && dz == 0) {
          continue; // Ignore the enchantment table itself
        }
        for (int dy = 0; dy <= 1; dy++) {
          if (!VanillaMaterials.AIR.equals(block.translate(dx, dy, dz).getMaterial())) {
            break;
          }
          if (VanillaMaterials.BOOKSHELF.equals(block.translate(2 * dx, dy, 2 * dz).getMaterial())) {
            ++bookshelves;
          }
          if (dx != 0 && dz != 0) {
            if (VanillaMaterials.BOOKSHELF.equals(block.translate(dx, dy, 2 * dz).getMaterial())) {
              ++bookshelves;
            }
            if (VanillaMaterials.BOOKSHELF.equals(block.translate(2 * dx, dy, dz).getMaterial())) {
              ++bookshelves;
            }
          }
        }
      }
View Full Code Here

  }

  @Override
  public void setOpened(Player player, boolean opened) {
    if (isDouble()) {
      Block block = getBlock();
      //MC will only play the chest open/close animation if you play it on the NE-most chest block in double chests
      if (block.translate(BlockFace.EAST).getMaterial() == VanillaMaterials.CHEST) {
        VanillaBlockMaterial.playBlockAction(block.translate(BlockFace.EAST), (byte) 1, opened ? (byte) 1 : (byte) 0);
      } else if (block.translate(BlockFace.NORTH).getMaterial() == VanillaMaterials.CHEST) {
        VanillaBlockMaterial.playBlockAction(block.translate(BlockFace.NORTH), (byte) 1, opened ? (byte) 1 : (byte) 0);
      }
    }
    super.setOpened(player, opened);
  }
View Full Code Here

  public ChestInventory getInventory() {
    return getData().get(CHEST_INVENTORY);
  }

  public ChestInventory getLargestInventory() {
    final Block block = getBlock();
    final Block otherHalf = VanillaMaterials.CHEST.getOtherHalf(block);
    ChestInventory inventory = getInventory();
    if (otherHalf != null) {
      if (block.translate(BlockFace.EAST).equals(otherHalf) || block.translate(BlockFace.NORTH).equals(otherHalf)) {
        inventory = new ChestInventory(otherHalf.get(Chest.class).getInventory(), inventory);
      } else {
        inventory = new ChestInventory(inventory, otherHalf.get(Chest.class).getInventory());
      }
    }
    return inventory;
  }
View Full Code Here

    }
  }

  public void placeObject(World w, int x, int y, int z, BlockFace direction, boolean active) {

    final Block bottomLeftBlock = w.getBlock(x, y, z);
    final Block bottomRightBlock = bottomLeftBlock.translate(direction, 3);
    final Block topLeftBlock = bottomLeftBlock.translate(BlockFace.TOP, 4);

    bottomLeftBlock.setMaterial(VanillaMaterials.OBSIDIAN);
    bottomRightBlock.setMaterial(VanillaMaterials.OBSIDIAN);
    topLeftBlock.setMaterial(VanillaMaterials.OBSIDIAN);
    topLeftBlock.translate(direction, 3).setMaterial(VanillaMaterials.OBSIDIAN);

    // Build vertical columns
    for (int dy = 0; dy < 4; dy++) {
      bottomLeftBlock.translate(BlockFace.TOP, dy).setMaterial(VanillaMaterials.OBSIDIAN);
      bottomRightBlock.translate(BlockFace.TOP, dy).setMaterial(VanillaMaterials.OBSIDIAN);
    }

    // Build horizontal columns
    for (int dw = 0; dw < 3; dw++) {
      bottomLeftBlock.translate(direction, dw).setMaterial(VanillaMaterials.OBSIDIAN);
      topLeftBlock.translate(direction, dw).setMaterial(VanillaMaterials.OBSIDIAN);
    }

    // Set the state of the portal
    setActive(w, x, y, z, active);
  }
View Full Code Here

      final EntityCollideBlockEvent collideBlockEvent = (EntityCollideBlockEvent) event;
      final Point point = new Point(collideBlockEvent.getContactInfo().getNormal(), getOwner().getWorld());
      final int x = point.getBlockX();
      final int y = point.getBlockX();
      final int z = point.getBlockX();
      final Block translated = getOwner().getWorld().getBlock(x, y, z).translate(BlockFace.TOP);
      final BlockMaterial material = translated.getMaterial();
      if (material.isPlacementObstacle()) {
        Item.dropNaturally(point, new ItemStack(getMaterial(), 1));
      } else {
        translated.setMaterial(getMaterial(), getMaterial().toCause(point));
      }
      getOwner().remove();
    }
  }
View Full Code Here

    this(null);
  }

  @Override
  public boolean canPlaceObject(World w, int x, int y, int z) {
    final Block block = w.getBlock(x, y, z);
    return block.isMaterial(VanillaMaterials.AIR)
        && block.translate(BlockFace.TOP).isMaterial(attachTo);
  }
View Full Code Here

    }
    args.assertCompletelyParsed();

    PlayerInteract hit = ((Player) source).get(PlayerInteract.class);
    if (hit != null) {
      final Block hitting = hit.getTargetBlock();
      if (hitting != null && !hitting.getMaterial().equals(VanillaMaterials.AIR)) {
        client.getScheduler().safeRun(VanillaPlugin.getInstance(), new Runnable() {
          @Override
          public void run() {
            hitting.setMaterial(VanillaMaterials.AIR);
          }
        });
        client.getLogger().info("Broke block: " + hitting.toString());
      }
    }
  }
View Full Code Here

    }

    public List<Growth> getNextGrowths(Growth last) {
      final List<Growth> nextGrowths = new ArrayList<Growth>();
      for (BlockFace face : BlockFaces.ALL) {
        final Block next = block.translate(face);
        if (!next.equals(last) && random.nextBoolean()) {
          nextGrowths.add(new Growth(next));
        }
      }
      return nextGrowths;
    }
View Full Code Here

    }
    args.assertCompletelyParsed();

    PlayerInteract hit = ((Player) source).get(PlayerInteract.class);
    if (hit != null) {
      Block hitting = hit.getTargetBlock(true);
      if (hitting != null && !hitting.getMaterial().equals(VanillaMaterials.AIR)) {
        client.getLogger().info(hitting.getMaterial().getName());
        selection = hitting.getMaterial();
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.spout.api.geo.cuboid.Block

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.