Java Code Examples for org.bukkit.util.BlockVector#getBlockX()
The following examples show how to use
org.bukkit.util.BlockVector#getBlockX() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RegionSave.java From CardinalPGM with MIT License | 6 votes |
public RegionSave(RegionModule region) { BlockVector min = blockAlign(region.getMin()); BlockVector max = blockAlign(region.getMax()); BlockVector size = max.minus(min).toBlockVector(); this.min = min; this.size = size; List<Pair<Material,Byte>> blocks = new ArrayList<>(); for (int z = min.getBlockZ(); z < max.getBlockZ(); z++) { for (int y = min.getBlockY(); y < max.getBlockY(); y++) { for (int x = min.getBlockX(); x < max.getBlockX(); x++) { Block block = new Location(GameHandler.getGameHandler().getMatchWorld(), x, y, z).getBlock(); blocks.add(new ImmutablePair<>(block.getType(), block.getData())); } } } this.blocks = blocks; }
Example 2
Source File: Bounds.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
public boolean containsBlock(BlockVector v) { BlockVector min = this.getBlockMin(); BlockVector max = this.getBlockMaxInside(); return min.getBlockX() <= v.getBlockX() && v.getBlockX() <= max.getBlockX() && min.getBlockY() <= v.getBlockY() && v.getBlockY() <= max.getBlockY() && min.getBlockZ() <= v.getBlockZ() && v.getBlockZ() <= max.getBlockZ(); }
Example 3
Source File: BlockImage.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
private int offset(BlockVector pos) { if (!this.bounds.containsBlock(pos)) { throw new IndexOutOfBoundsException("Block is not inside this BlockImage"); } return (pos.getBlockZ() - this.origin.getBlockZ()) * this.size.getBlockX() * this.size.getBlockY() + (pos.getBlockY() - this.origin.getBlockY()) * this.size.getBlockX() + (pos.getBlockX() - this.origin.getBlockX()); }
Example 4
Source File: CraftStructureBlock.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void setRelativePosition(BlockVector vector) { Validate.isTrue(isBetween(vector.getBlockX(), -MAX_SIZE, MAX_SIZE), "Structure Size (X) must be between -" + MAX_SIZE + " and " + MAX_SIZE); Validate.isTrue(isBetween(vector.getBlockY(), -MAX_SIZE, MAX_SIZE), "Structure Size (Y) must be between -" + MAX_SIZE + " and " + MAX_SIZE); Validate.isTrue(isBetween(vector.getBlockZ(), -MAX_SIZE, MAX_SIZE), "Structure Size (Z) must be between -" + MAX_SIZE + " and " + MAX_SIZE); getSnapshot().position = new BlockPos(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // PAIL: rename relativePosition }
Example 5
Source File: CraftStructureBlock.java From Kettle with GNU General Public License v3.0 | 5 votes |
@Override public void setStructureSize(BlockVector vector) { Validate.isTrue(isBetween(vector.getBlockX(), 0, MAX_SIZE), "Structure Size (X) must be between 0 and " + MAX_SIZE); Validate.isTrue(isBetween(vector.getBlockY(), 0, MAX_SIZE), "Structure Size (Y) must be between 0 and " + MAX_SIZE); Validate.isTrue(isBetween(vector.getBlockZ(), 0, MAX_SIZE), "Structure Size (Z) must be between 0 and " + MAX_SIZE); getSnapshot().size = new BlockPos(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ()); // PAIL: rename size }
Example 6
Source File: BlockFaces.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
static BlockVector getRelative(BlockVector pos, BlockFace face) { return new BlockVector( pos.getBlockX() + face.getModX(), pos.getBlockY() + face.getModY(), pos.getBlockZ() + face.getModZ()); }
Example 7
Source File: BlockFaces.java From ProjectAres with GNU Affero General Public License v3.0 | 4 votes |
public static BlockVector getRelative(BlockVector pos, BlockFace face) { return new BlockVector(pos.getBlockX() + face.getModX(), pos.getBlockY() + face.getModY(), pos.getBlockZ() + face.getModZ()); }
Example 8
Source File: RegionSave.java From CardinalPGM with MIT License | 4 votes |
public Pair<Material,Byte> getBlockAt(BlockVector loc) { int x = loc.getBlockX() - min.getBlockX(); int y = (loc.getBlockY() - this.min.getBlockY()) * this.size.getBlockX(); int z = (loc.getBlockZ() - this.min.getBlockZ()) * this.size.getBlockX() * this.size.getBlockY(); return blocks.get(x + y + z); }