com.sk89q.worldedit.BlockVector Java Examples
The following examples show how to use
com.sk89q.worldedit.BlockVector.
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: FlagShowBarriers.java From HeavySpleef with GNU General Public License v3.0 | 6 votes |
private void calculateSpawnLocations() { spawningBarriers.clear(); for (Floor floor : game.getFloors()) { Region region = floor.getRegion(); RegionIterator iterator = new RegionIterator(region); while (iterator.hasNext()) { BlockVector vector = iterator.next(); Location location = BukkitUtil.toLocation(game.getWorld(), vector); Block block = location.getBlock(); if (block.getType() != Material.BARRIER) { continue; } spawningBarriers.add(vector.add(0.5, 0.5, 0.5)); } } Collections.shuffle(spawningBarriers); }
Example #2
Source File: WorldGuardSixCommunicator.java From WorldGuardExtraFlagsPlugin with MIT License | 6 votes |
@Override public void doUnloadChunkFlagCheck(org.bukkit.World world) { for (ProtectedRegion region : this.getRegionContainer().get(world).getRegions().values()) { if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY) { System.out.println("Loading chunks for region " + region.getId() + " located in " + world.getName() + " due to chunk-unload flag being deny"); BlockVector min = region.getMinimumPoint(); BlockVector max = region.getMaximumPoint(); for(int x = min.getBlockX() >> 4; x <= max.getBlockX() >> 4; x++) { for(int z = min.getBlockZ() >> 4; z <= max.getBlockZ() >> 4; z++) { world.getChunkAt(x, z).load(true); } } } } }
Example #3
Source File: FloodFillTool.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public boolean actPrimary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked) { World world = (World) clicked.getExtent(); int initialType = world.getBlockType(clicked.toVector()); if (initialType == BlockID.AIR) { return true; } if (initialType == BlockID.BEDROCK && !player.canDestroyBedrock()) { return true; } EditSession editSession = session.createEditSession(player); try { recurse(server, editSession, world, clicked.toVector().toBlockVector(), clicked.toVector(), range, initialType, new HashSet<BlockVector>()); } catch (WorldEditException e) { throw new RuntimeException(e); } editSession.flushQueue(); session.remember(editSession); return true; }
Example #4
Source File: WorldGuardFilter.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public void calculateRegions() { TaskManager.IMP.sync(new RunnableVal<Object>() { @Override public void run(Object value) { WorldGuardFilter.this.manager = WorldGuardPlugin.inst().getRegionManager(world); for (ProtectedRegion region : manager.getRegions().values()) { BlockVector min = region.getMinimumPoint(); BlockVector max = region.getMaximumPoint(); if (max.getBlockX() - min.getBlockX() > 1024 || max.getBlockZ() - min.getBlockZ() > 1024) { Fawe.debug("Large or complex region shapes cannot be optimized. Filtering will be slower"); large = true; break; } add(min.toVector2D(), max.toVector2D()); } } }); }
Example #5
Source File: EllipsoidRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
/** * Create a new selector from the given selector. * * @param oldSelector the old selector */ public EllipsoidRegionSelector(RegionSelector oldSelector) { this(checkNotNull(oldSelector).getIncompleteRegion().getWorld()); if (oldSelector instanceof EllipsoidRegionSelector) { final EllipsoidRegionSelector ellipsoidRegionSelector = (EllipsoidRegionSelector) oldSelector; region = new EllipsoidRegion(ellipsoidRegionSelector.getIncompleteRegion()); } else { Region oldRegion; try { oldRegion = oldSelector.getRegion(); } catch (IncompleteRegionException e) { return; } BlockVector pos1 = oldRegion.getMinimumPoint().toBlockVector(); BlockVector pos2 = oldRegion.getMaximumPoint().toBlockVector(); Vector center = pos1.add(pos2).divide(2).floor(); region.setCenter(center); region.setRadius(pos2.subtract(center)); } }
Example #6
Source File: EllipsoidRegion.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public Set<Vector2D> getChunks() { final Set<Vector2D> chunks = new HashSet<Vector2D>(); final Vector min = getMinimumPoint(); final Vector max = getMaximumPoint(); final int centerY = getCenter().getBlockY(); for (int x = min.getBlockX(); x <= max.getBlockX(); ++x) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); ++z) { if (!contains(new BlockVector(x, centerY, z))) { continue; } chunks.add(new BlockVector2D( x >> ChunkStore.CHUNK_SHIFTS, z >> ChunkStore.CHUNK_SHIFTS )); } } return chunks; }
Example #7
Source File: LocalBlockVectorSet.java From FastAsyncWorldedit with GNU General Public License v3.0 | 6 votes |
@Override public <T> T[] toArray(T[] array) { int size = size(); if (array == null || array.length < size) { array = (T[]) new BlockVector[size]; } int index = 0; for (int i = 0; i < size; i++) { index = set.nextSetBit(index); int b1 = (index & 0xFF); int b2 = ((byte) (index >> 8)) & 0x7F; int b3 = ((byte) (index >> 15)) & 0xFF; int b4 = ((byte) (index >> 23)) & 0xFF; int x = offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21); int y = b1; int z = offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21); array[i] = (T) new BlockVector(x, y, z); index++; } return array; }
Example #8
Source File: CylinderRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public BlockVector getPrimaryPosition() throws IncompleteRegionException { if (!isDefined()) { throw new IncompleteRegionException(); } return region.getCenter().toBlockVector(); }
Example #9
Source File: FloodFillTool.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
private void recurse(Platform server, EditSession editSession, World world, BlockVector pos, Vector origin, int size, int initialType, Set<BlockVector> visited) throws WorldEditException { if (origin.distance(pos) > size || visited.contains(pos)) { return; } visited.add(pos); if (editSession.getBlock(pos).getType() == initialType) { editSession.setBlock(pos, pattern); } else { return; } recurse(server, editSession, world, pos.add(1, 0, 0).toBlockVector(), origin, size, initialType, visited); recurse(server, editSession, world, pos.add(-1, 0, 0).toBlockVector(), origin, size, initialType, visited); recurse(server, editSession, world, pos.add(0, 0, 1).toBlockVector(), origin, size, initialType, visited); recurse(server, editSession, world, pos.add(0, 0, -1).toBlockVector(), origin, size, initialType, visited); recurse(server, editSession, world, pos.add(0, 1, 0).toBlockVector(), origin, size, initialType, visited); recurse(server, editSession, world, pos.add(0, -1, 0).toBlockVector(), origin, size, initialType, visited); }
Example #10
Source File: ArbitraryShape.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
private BaseBlock getMaterialCached(int x, int y, int z, Pattern pattern) { final int index = (y - cacheOffsetY) + (z - cacheOffsetZ) * cacheSizeY + (x - cacheOffsetX) * cacheSizeY * cacheSizeZ; final short cacheEntry = cache[index]; switch (cacheEntry) { case 0: // unknown, fetch material final BaseBlock material = getMaterial(x, y, z, pattern.apply(new BlockVector(x, y, z))); if (material == null) { // outside cache[index] = -1; return null; } short newCacheEntry = (short) (material.getType() | ((material.getData() + 1) << 8)); if (newCacheEntry == 0) { // type and data 0 newCacheEntry = -2; } cache[index] = newCacheEntry; return material; case -1: // outside return null; case -2: // type and data 0 return new BaseBlock(0, 0); } return new BaseBlock(cacheEntry & 255, ((cacheEntry >> 8) - 1) & 15); }
Example #11
Source File: CuboidRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public BlockVector getPrimaryPosition() throws IncompleteRegionException { if (position1 == null) { throw new IncompleteRegionException(); } return position1; }
Example #12
Source File: WorldGuard6Hook.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override public Iterator<Block> getBlocks() { final BlockVector min = region.getMinimumPoint(), max = region.getMaximumPoint(); return new AABB(world, new Vector(min.getBlockX(), min.getBlockY(), min.getBlockZ()), new Vector(max.getBlockX() + 1, max.getBlockY() + 1, max.getBlockZ() + 1)).iterator(); // final Iterator<BlockVector2D> iter = region.getPoints().iterator(); // if (!iter.hasNext()) // return EmptyIterator.get(); // return new Iterator<Block>() { // @SuppressWarnings("null") // BlockVector2D current = iter.next(); // int height = 0; // final int maxHeight = world.getMaxHeight(); // // @SuppressWarnings("null") // @Override // public boolean hasNext() { // if (height >= maxHeight && iter.hasNext()) { // height = 0; // current = iter.next(); // } // return height < maxHeight; // } // // @SuppressWarnings("null") // @Override // public Block next() { // if (!hasNext()) // throw new NoSuchElementException(); // return world.getBlockAt(current.getBlockX(), height++, current.getBlockZ()); // } // // @Override // public void remove() { // throw new UnsupportedOperationException(); // } // }; }
Example #13
Source File: Polygonal2DRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public BlockVector getPrimaryPosition() throws IncompleteRegionException { if (pos1 == null) { throw new IncompleteRegionException(); } return pos1; }
Example #14
Source File: ClipboardRemapper.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public void apply(Clipboard clipboard) throws WorldEditException { if (clipboard instanceof BlockArrayClipboard) { BlockArrayClipboard bac = (BlockArrayClipboard) clipboard; bac.IMP = new RemappedClipboard(bac.IMP, this); } else { Region region = clipboard.getRegion(); for (BlockVector pos : region) { BaseBlock block = clipboard.getBlock(pos); BaseBlock newBlock = remap(block); if (block != newBlock) { clipboard.setBlock(pos, newBlock); } } } }
Example #15
Source File: LocalBlockVectorSet.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public Iterator<Vector> iterator() { return new Iterator<Vector>() { int index = set.nextSetBit(0); int previous = -1; MutableBlockVector mutable = new MutableBlockVector(0, 0, 0); @Override public void remove() { set.clear(previous); } @Override public boolean hasNext() { return index != -1; } @Override public BlockVector next() { if (index != -1) { int b1 = (index & 0xFF); int b2 = ((byte) (index >> 8)) & 0x7F; int b3 = ((byte) (index >> 15)) & 0xFF; int b4 = ((byte) (index >> 23)) & 0xFF; mutable.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21)); mutable.mutY(b1); mutable.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21)); previous = index; index = set.nextSetBit(index + 1); return mutable; } return null; } }; }
Example #16
Source File: FuzzyRegionSelector.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public BlockVector getPrimaryPosition() throws IncompleteRegionException { if (positions.isEmpty()) { throw new IncompleteRegionException(); } return new BlockVector(positions.get(0)); }
Example #17
Source File: FaweChangeSet.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
public void add(BlockChange change) { try { BlockVector loc = change.getPosition(); BaseBlock from = change.getPrevious(); BaseBlock to = change.getCurrent(); add(loc, from, to); } catch (Exception e) { MainUtil.handleError(e); } }
Example #18
Source File: WorldGuardSixCommunicator.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
@Override public boolean doUnloadChunkFlagCheck(org.bukkit.World world, Chunk chunk) { for (ProtectedRegion region : this.getRegionContainer().get(world).getApplicableRegions(new ProtectedCuboidRegion("UnloadChunkFlagTester", new BlockVector(chunk.getX() * 16, 0, chunk.getZ() * 16), new BlockVector(chunk.getX() * 16 + 15, 256, chunk.getZ() * 16 + 15)))) { if (region.getFlag(Flags.CHUNK_UNLOAD) == State.DENY) { return false; } } return true; }
Example #19
Source File: FaweMask.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Deprecated public FaweMask(final BlockVector pos1, final BlockVector pos2) { this(pos1, pos2, null); if ((pos1 == null) || (pos2 == null)) { throw new IllegalArgumentException("BlockVectors cannot be null!"); } }
Example #20
Source File: Worldguard.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
private static Region adapt(ProtectedRegion region) { if (region instanceof ProtectedCuboidRegion) { return new CuboidRegion(region.getMinimumPoint(), region.getMaximumPoint()); } if (region instanceof GlobalProtectedRegion) { return RegionWrapper.GLOBAL(); } if (region instanceof ProtectedPolygonalRegion) { ProtectedPolygonalRegion casted = (ProtectedPolygonalRegion) region; BlockVector max = region.getMaximumPoint(); BlockVector min = region.getMinimumPoint(); return new Polygonal2DRegion(null, casted.getPoints(), min.getBlockY(), max.getBlockY()); } return new AdaptedRegion(region); }
Example #21
Source File: WorldGuardFilter.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean containsChunk(int chunkX, int chunkZ) { if (!large) return super.containsChunk(chunkX, chunkZ); BlockVector pos1 = new BlockVector(chunkX << 4, 0, chunkZ << 4); BlockVector pos2 = new BlockVector(pos1.getBlockX() + 15, 255, pos1.getBlockZ() + 15); ProtectedCuboidRegion chunkRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2); ApplicableRegionSet set = manager.getApplicableRegions(chunkRegion); return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__"); }
Example #22
Source File: WorldGuardFilter.java From FastAsyncWorldedit with GNU General Public License v3.0 | 5 votes |
@Override public boolean containsRegion(int mcaX, int mcaZ) { if (!large) return super.containsRegion(mcaX, mcaZ); BlockVector pos1 = new BlockVector(mcaX << 9, 0, mcaZ << 9); BlockVector pos2 = new BlockVector(pos1.getBlockX() + 511, 255, pos1.getBlockZ() + 511); ProtectedCuboidRegion regionRegion = new ProtectedCuboidRegion("unimportant", pos1, pos2); ApplicableRegionSet set = manager.getApplicableRegions(regionRegion); return set.size() > 0 && !set.getRegions().iterator().next().getId().equals("__global__"); }
Example #23
Source File: WorldGuardHandler5.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@Override public ProtectedCuboidRegion createCuboidRegion(String name, org.bukkit.util.Vector corner1, org.bukkit.util.Vector corner2) { return new ProtectedCuboidRegion(name, new BlockVector(corner1.getBlockX(), corner1.getBlockY(), corner1.getBlockZ()), new BlockVector(corner2.getBlockX(), corner2.getBlockY(), corner2.getBlockZ())); }
Example #24
Source File: WorldGuard7FAWEHook.java From Skript with GNU General Public License v3.0 | 4 votes |
@Override public Iterator<Block> getBlocks() { final BlockVector min = region.getMinimumPoint(), max = region.getMaximumPoint(); return new AABB(world, new Vector(min.getBlockX(), min.getBlockY(), min.getBlockZ()), new Vector(max.getBlockX() + 1, max.getBlockY() + 1, max.getBlockZ() + 1)).iterator(); }
Example #25
Source File: WorldGuardHandler6.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@Override public org.bukkit.util.Vector getMinimumPoint(ProtectedRegion region) { BlockVector min = region.getMinimumPoint(); return new org.bukkit.util.Vector(min.getX(), min.getY(), min.getZ()); }
Example #26
Source File: WorldGuardHandler6.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@Override public org.bukkit.util.Vector getMaximumPoint(ProtectedRegion region) { BlockVector min = region.getMaximumPoint(); return new org.bukkit.util.Vector(min.getX(), min.getY(), min.getZ()); }
Example #27
Source File: WorldGuardHandler6.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@Override public ProtectedCuboidRegion createCuboidRegion(String name, org.bukkit.util.Vector corner1, org.bukkit.util.Vector corner2) { return new ProtectedCuboidRegion(name, new BlockVector(corner1.getBlockX(), corner1.getBlockY(), corner1.getBlockZ()), new BlockVector(corner2.getBlockX(), corner2.getBlockY(), corner2.getBlockZ())); }
Example #28
Source File: FastAsyncWorldEditWorldGuardHandler.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@Override public Vector getMinimumPoint(ProtectedRegion region) { BlockVector min = region.getMinimumPoint(); return new Vector(min.getX(), min.getY(), min.getZ()); }
Example #29
Source File: FastAsyncWorldEditWorldGuardHandler.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@Override public Vector getMaximumPoint(ProtectedRegion region) { BlockVector min = region.getMaximumPoint(); return new Vector(min.getX(), min.getY(), min.getZ()); }
Example #30
Source File: FastAsyncWorldEditWorldGuardHandler.java From AreaShop with GNU General Public License v3.0 | 4 votes |
@Override public ProtectedCuboidRegion createCuboidRegion(String name, Vector corner1, Vector corner2) { return new ProtectedCuboidRegion(name, new BlockVector(corner1.getBlockX(), corner1.getBlockY(), corner1.getBlockZ()), new BlockVector(corner2.getBlockX(), corner2.getBlockY(), corner2.getBlockZ())); }