/** * Returns the position that precipitation ends falling in the column * of the given position. * * <p>A position is still returned for positions in biomes which do not * receive precipitation.</p> * * @param position The position value * @return The position that precipitation ends */ default Vector3i getPrecipitationLevelAt(Vector3i position) { return new Vector3i(position.getX(), this.getPrecipitationLevelAt(position.getX(), position.getZ()), position.getZ()); }
/** * Returns true if the block volume contains a block at the specified * position. This is defined as <code>{{@link #getBlockMin()} <= position <= * {@link #getBlockMax()}</code> * * @param position The position to check * @return Whether or not the position has a block in this volume */ default boolean containsBlock(Vector3i position) { return containsBlock(position.getX(), position.getY(), position.getZ()); }
/** * Constructs a new bounding box from two opposite corners. * Fails the resulting box would be degenerate (a dimension is 0). * * @param firstCorner The first corner * @param secondCorner The second corner */ public AABB(Vector3i firstCorner, Vector3i secondCorner) { this(checkNotNull(firstCorner, "firstCorner").toDouble(), checkNotNull(secondCorner, "secondCorner").toDouble()); }
Vector3i min = req.getMin().min(req.getMax()); Vector3i max = req.getMax().max(req.getMin()); Vector3i size = max.sub(min).add(1, 1, 1); int numBlocks = size.getX() * size.getY() * size.getZ(); BlockState state = req.getBlock(); for (int x = min.getX(); x <= max.getX(); x++) { for (int y = min.getY(); y <= max.getY(); y++) { for (int z = min.getZ(); z <= max.getZ(); z++) { blocks.put(new Vector3i(x, y, z), state); for (int x = 0; x < size.getX(); x++) { BlockState[][] xBlocks = req.getBlocks()[x]; continue; for (int y = 0; y < size.getY(); y++) { BlockState[] yBlocks = xBlocks[y]; for (int z = 0; z < size.getZ(); z++) { BlockState block = yBlocks[z]; blocks.put(new Vector3i(min.getX() + x, min.getY() + y, min.getZ() + z), block); } catch (Exception e) { throw new BadRequestException("Could not process block state: " + e.getMessage());
/** * Returns the position of the block that was hit. * * @return The coordinates of the hit block */ public Vector3i getBlockPosition() { if (this.blockPosition == null) { this.blockPosition = new Vector3i(this.xBlock, this.yBlock, this.zBlock); } return this.blockPosition; }
@Override protected final void powder(final SnipeData v) { if (this.pos == null) { v.sendMessage(TextColors.RED + "Select a first point with the arrow."); return; } v.sendMessage(TextColors.AQUA + "X change: " + (this.targetBlock.getX() - this.pos.getX())); v.sendMessage(TextColors.AQUA + "Y change: " + (this.targetBlock.getY() - this.pos.getY())); v.sendMessage(TextColors.AQUA + "Z change: " + (this.targetBlock.getZ() - this.pos.getZ())); final double distance = this.targetBlock.getBlockPosition().sub(this.pos).length(); v.sendMessage(TextColors.AQUA + "Distance = " + distance); }
private void execute(final SnipeData v) { if (this.pos == null || this.worldUid == null || !this.worldUid.equals(this.targetBlock.getExtent().getUniqueId())) { this.worldUid = this.targetBlock.getExtent().getUniqueId(); this.pos = this.targetBlock.getChunkPosition(); v.sendMessage(TextColors.YELLOW, "First point selected!"); } else { Vector3i other = this.targetBlock.getChunkPosition(); v.sendMessage(TextColors.YELLOW, "Second point selected!"); Vector3i min = other.min(this.pos); Vector3i max = other.max(this.pos); this.undo = new Undo((max.getX() - min.getX()) * (max.getZ() - min.getZ()) * 16 * 4 * 256); for (int x = min.getX(); x <= max.getX(); x++) { for (int z = min.getZ(); z <= max.getZ(); z++) { Optional<Chunk> chunk = this.world.getChunk(x, 0, z); if (chunk.isPresent()) { operate(v, chunk.get()); } } } v.owner().storeUndo(this.undo); this.undo = null; this.worldUid = null; this.pos = null; } }
public Vector3i add(Vector3i v) { return add(v.x, v.y, v.z); }
public Vector3i max(Vector3i v) { return max(v.x, v.y, v.z); }
public Vector3i sub(Vector3i v) { return sub(v.x, v.y, v.z); }
public BlockOperation(CachedWorld world, Vector3i min, Vector3i max) { super(null); this.blockService = WebAPI.getBlockService(); this.uuid = UUID.randomUUID(); this.world = world; this.min = min; this.max = max; this.size = max.sub(min).add(1, 1, 1); this.cause = Cause.of(EventContext.empty(), WebAPI.getContainer()); this.totalBlocks = size.getX() * size.getY() * size.getZ(); }
/** * Create a new instance. * * @param extent The extent * @param x The X-axis position * @param y The Y-axis position * @param z The Z-axis position */ public Location(E extent, int x, int y, int z) { this(extent, new Vector3i(x, y, z)); }
public Vector3i add(Vector3i v) { return add(v.x, v.y, v.z); }
public Vector3i max(Vector3i v) { return max(v.x, v.y, v.z); }
public Vector3i sub(Vector3i v) { return sub(v.x, v.y, v.z); }