Java Code Examples for com.sk89q.worldedit.Vector#getBlockY()
The following examples show how to use
com.sk89q.worldedit.Vector#getBlockY() .
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: EllipsoidRegion.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean contains(Vector position) { int cx = position.getBlockX() - center.getBlockX(); int cx2 = cx * cx; if (cx2 > radiusSqr.getBlockX()) { return false; } int cz = position.getBlockZ() - center.getBlockZ(); int cz2 = cz * cz; if (cz2 > radiusSqr.getBlockZ()) { return false; } int cy = position.getBlockY() - center.getBlockY(); int cy2 = cy * cy; if (radiusSqr.getBlockY() < 255 && cy2 > radiusSqr.getBlockY()) { return false; } if (sphere) { return cx2 + cy2 + cz2 <= radiusLengthSqr; } double cxd = (double) cx / radius.getBlockX(); double cyd = (double) cy / radius.getBlockY(); double czd = (double) cz / radius.getBlockZ(); return cxd * cxd + cyd * cyd + czd * czd <= 1; }
Example 2
Source File: CorruptSchematicStreamer.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public FaweClipboard setupClipboard() { if (fc != null) { return fc; } Vector dimensions = guessDimensions(volume.get(), width.get(), height.get(), length.get()); if (width.get() == 0 || height.get() == 0 || length.get() == 0) { Fawe.debug("No dimensions found! Estimating based on factors:" + dimensions); } if (Settings.IMP.CLIPBOARD.USE_DISK) { fc = new DiskOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ(), uuid); } else if (Settings.IMP.CLIPBOARD.COMPRESSION_LEVEL == 0) { fc = new CPUOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ()); } else { fc = new MemoryOptimizedClipboard(dimensions.getBlockX(), dimensions.getBlockY(), dimensions.getBlockZ()); } return fc; }
Example 3
Source File: RadiusMask.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean test(Vector to) { if (pos == null) { pos = new MutableBlockVector(to); } int dx = pos.getBlockX() - to.getBlockX(); int d = dx * dx; if (d > maxSqr) { return false; } int dz = pos.getBlockZ() - to.getBlockZ(); d += dz * dz; if (d > maxSqr) { return false; } int dy = pos.getBlockY() - to.getBlockY(); d += dy * dy; if (d < minSqr || d > maxSqr) { return false; } return true; }
Example 4
Source File: CuboidRegion.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Clamps the cuboid according to boundaries of the world. */ protected void recalculate() { if (pos1 == null || pos2 == null) { return; } pos1 = pos1.clampY(world == null ? Integer.MIN_VALUE : 0, world == null ? Integer.MAX_VALUE : world.getMaxY()); pos2 = pos2.clampY(world == null ? Integer.MIN_VALUE : 0, world == null ? Integer.MAX_VALUE : world.getMaxY()); Vector min = getMinimumPoint(); Vector max = getMaximumPoint(); minX = min.getBlockX(); minY = min.getBlockY(); minZ = min.getBlockZ(); maxX = max.getBlockX(); maxY = max.getBlockY(); maxZ = max.getBlockZ(); }
Example 5
Source File: AngleMask.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
public boolean adjacentAir(Vector v) { int x = v.getBlockX(); int y = v.getBlockY(); int z = v.getBlockZ(); if (!mask.test(x + 1, y, z)) { return true; } if (!mask.test(x - 1, y, z)) { return true; } if (!mask.test(x, y, z + 1)) { return true; } if (!mask.test(x, y, z - 1)) { return true; } if (y < 255 && !mask.test(x, y + 1, z)) { return true; } if (y > 0 && !mask.test(x, y - 1, z)) { return true; } return false; }
Example 6
Source File: CuboidRegion.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public Set<Vector> getChunkCubes() { Set chunks = new LocalBlockVectorSet(); Vector min = getMinimumPoint(); Vector max = getMaximumPoint(); for (int x = max.getBlockX() >> ChunkStore.CHUNK_SHIFTS; x >= min.getBlockX() >> ChunkStore.CHUNK_SHIFTS; --x) { for (int z = max.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; z >= min.getBlockZ() >> ChunkStore.CHUNK_SHIFTS; --z) { for (int y = max.getBlockY() >> ChunkStore.CHUNK_SHIFTS; y >= min.getBlockY() >> ChunkStore.CHUNK_SHIFTS; --y) { chunks.add(new Vector(x, y, z)); } } } return chunks; }
Example 7
Source File: CuboidSpawnpointGenerator.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
@Override public void generateSpawnpoints(CuboidRegion region, World world, List<Location> spawnpoints, int n) { Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); int dx = max.getBlockX() - min.getBlockX(); int dz = max.getBlockZ() - min.getBlockZ(); int py = max.getBlockY() + 1; for (int i = 0; i < n; i++) { int rx = (int) (Math.random() * dx); int rz = (int) (Math.random() * dz); int px = min.getBlockX() + rx; int pz = min.getBlockZ() + rz; Location location = new Location(world, px + 0.5, py, pz + 0.5); spawnpoints.add(location); } }
Example 8
Source File: CuboidRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void explainSecondarySelection(Actor player, LocalSession session, Vector pos) { checkNotNull(player); checkNotNull(session); checkNotNull(pos); Message msg; if (position1 != null && position2 != null) { msg = BBC.SELECTOR_POS.m(2, position2, region.getArea()); } else { msg = BBC.SELECTOR_POS.m(2, position2, ""); } String prefix = WorldEdit.getInstance().getConfiguration().noDoubleSlash ? "" : "/"; String cmd = prefix + Commands.getAlias(SelectionCommands.class, "/pos2") + " " + pos.getBlockX() + "," + pos.getBlockY() + "," + pos.getBlockZ(); msg.suggestTip(cmd).send(player); session.dispatchCUIEvent(player, new SelectionPointEvent(1, pos, getArea())); }
Example 9
Source File: Linear3DBlockPattern.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean apply(Extent extent, Vector set, Vector get) throws WorldEditException { int index = (get.getBlockX() + get.getBlockY() + get.getBlockZ()) % patternsArray.length; if (index < 0) { index += patternsArray.length; } return patternsArray[index].apply(extent, set, get); }
Example 10
Source File: Linear3DBlockPattern.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public BaseBlock apply(Vector position) { int index = (position.getBlockX() + position.getBlockY() + position.getBlockZ()) % patternsArray.length; if (index < 0) { index += patternsArray.length; } return patternsArray[index].apply(position); }
Example 11
Source File: DataAnglePattern.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public int getSlope(BaseBlock block, Vector vector) { int x = vector.getBlockX(); int y = vector.getBlockY(); int z = vector.getBlockZ(); if (FaweCache.canPassThrough(block.getId(), block.getData())) { return -1; } int slope; boolean aboveMin; slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z, y, 0, maxY)) * 7; slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - distance, y, 0, maxY)) * 7; slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z - distance, y, 0, maxY)) * 5; slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x - distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x + distance, z - distance, y, 0, maxY)) * 5; return slope; }
Example 12
Source File: ClipboardPattern.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public BaseBlock apply(Vector position) { int xp = position.getBlockX() % sx; int yp = position.getBlockY() % sy; int zp = position.getBlockZ() % sz; if (xp < 0) xp += sx; if (yp < 0) yp += sy; if (zp < 0) zp += sz; mutable.mutX((min.getX() + xp)); mutable.mutY((min.getY() + yp)); mutable.mutZ((min.getZ() + zp)); return clipboard.getBlock(mutable); }
Example 13
Source File: BlockBagChangeSet.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void add(Vector loc, BaseBlock from, BaseBlock to) { int x = loc.getBlockX(); int y = loc.getBlockY(); int z = loc.getBlockZ(); add(x, y, z, from, to); }
Example 14
Source File: Triangle.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public Triangle(Vector pos1, Vector pos2, Vector pos3) { verts[0] = new double[]{pos1.getBlockX(), pos1.getBlockY(), pos1.getBlockZ()}; verts[1] = new double[]{pos2.getBlockX(), pos2.getBlockY(), pos2.getBlockZ()}; verts[2] = new double[]{pos3.getBlockX(), pos3.getBlockY(), pos3.getBlockZ()}; radius[0] = RADIUS; radius[1] = RADIUS; radius[2] = RADIUS; this.normalVec = pos2.subtract(pos1).cross(pos3.subtract(pos1)).normalize(); this.b = Math.max(Math.max(this.normalVec.dot(pos1), this.normalVec.dot(pos2)), this.normalVec.dot(pos3)); }
Example 15
Source File: WorldCopyClipboard.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public WorldCopyClipboard(EditSession editSession, Region region, boolean hasEntities, boolean hasBiomes) { super(region); this.hasBiomes = hasBiomes; this.hasEntities = hasEntities; final Vector origin = region.getMinimumPoint(); this.mx = origin.getBlockX(); this.my = origin.getBlockY(); this.mz = origin.getBlockZ(); this.editSession = editSession; }
Example 16
Source File: BlockArrayClipboard.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException { if (region.contains(location)) { final int x = location.getBlockX(); final int y = location.getBlockY(); final int z = location.getBlockZ(); return setBlock(x, y, z, block); } return false; }
Example 17
Source File: CPUOptimizedClipboard.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public void setDimensions(Vector dimensions) { width = dimensions.getBlockX(); height = dimensions.getBlockY(); length = dimensions.getBlockZ(); area = width * length; int newVolume = area * height; if (newVolume != volume) { volume = newVolume; ids = new byte[volume]; datas = new byte[volume]; } }
Example 18
Source File: SurfaceRandomOffsetPattern.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
private boolean allowed(Vector v) { BaseBlock block = pattern.apply(v); if (FaweCache.canPassThrough(block.getId(), block.getData())) { return false; } int x = v.getBlockX(); int y = v.getBlockY(); int z = v.getBlockZ(); v.mutY(y + 1); if (canPassthrough(v)) { v.mutY(y); return true; } v.mutY(y - 1); if (canPassthrough(v)) { v.mutY(y); return true; } v.mutY(y); v.mutX(x + 1); if (canPassthrough(v)) { v.mutX(x); return true; } v.mutX(x - 1); if (canPassthrough(v)) { v.mutX(x); return true; } v.mutX(x); v.mutZ(z + 1); if (canPassthrough(v)) { v.mutZ(z); return true; } v.mutZ(z - 1); if (canPassthrough(v)) { v.mutZ(z); return true; } v.mutZ(z); return false; }
Example 19
Source File: Triangle.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
public boolean contains(Vector pos) { center[0] = pos.getBlockX() + RADIUS; center[1] = pos.getBlockY() + RADIUS; center[2] = pos.getBlockZ() + RADIUS; return overlaps(center, radius, verts); }
Example 20
Source File: StencilBrush.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException { final int cx = position.getBlockX(); final int cy = position.getBlockY(); final int cz = position.getBlockZ(); int size = (int) sizeDouble; int size2 = (int) (sizeDouble * sizeDouble); int maxY = editSession.getMaxY(); int add; if (yscale < 0) { add = maxY; } else { add = 0; } double scale = (yscale / sizeDouble) * (maxY + 1); final HeightMap map = getHeightMap(); map.setSize(size); int cutoff = onlyWhite ? maxY : 0; final SolidBlockMask solid = new SolidBlockMask(editSession); final AdjacentAnyMask adjacent = new AdjacentAnyMask(Masks.negate(solid)); Player player = editSession.getPlayer().getPlayer(); Vector pos = player.getPosition(); Location loc = editSession.getPlayer().getPlayer().getLocation(); float yaw = loc.getYaw(); float pitch = loc.getPitch(); AffineTransform transform = new AffineTransform().rotateY((-yaw) % 360).rotateX(pitch - 90).inverse(); RecursiveVisitor visitor = new RecursiveVisitor(new Mask() { private final MutableBlockVector mutable = new MutableBlockVector(); @Override public boolean test(Vector vector) { if (solid.test(vector)) { int dx = vector.getBlockX() - cx; int dy = vector.getBlockY() - cy; int dz = vector.getBlockZ() - cz; Vector srcPos = transform.apply(mutable.setComponents(dx, dy, dz)); dx = srcPos.getBlockX(); dz = srcPos.getBlockZ(); int distance = dx * dx + dz * dz; if (distance > size2 || Math.abs(dx) > 256 || Math.abs(dz) > 256) return false; double raise = map.getHeight(dx, dz); int val = (int) Math.ceil(raise * scale) + add; if (val < cutoff) { return true; } if (val >= 255 || PseudoRandom.random.random(maxY) < val) { editSession.setBlock(vector.getBlockX(), vector.getBlockY(), vector.getBlockZ(), pattern); } return true; } return false; } }, vector -> true, Integer.MAX_VALUE, editSession); visitor.setDirections(Arrays.asList(visitor.DIAGONAL_DIRECTIONS)); visitor.visit(position); Operations.completeBlindly(visitor); }