Java Code Examples for org.spongepowered.api.world.Location#getBlockZ()
The following examples show how to use
org.spongepowered.api.world.Location#getBlockZ() .
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: Region.java From Nations with MIT License | 6 votes |
public boolean isInside(Location<World> loc) { Rect extr = extrema.get(loc.getExtent().getUniqueId()); Vector2i p = new Vector2i(loc.getBlockX(), loc.getBlockZ()); if (p.getX() < extr.getMinX() || p.getX() > extr.getMaxX() || p.getY() < extr.getMinY() || p.getY() > extr.getMaxY()) { return false; } for (Rect r : rects) { if (r.isInside(p)) { return true; } } return false; }
Example 2
Source File: Region.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public List<Location<World>> getLimitLocs(int miny, int maxy, boolean define) { final List<Location<World>> locBlocks = new ArrayList<>(); Location<World> loc1 = this.getMinLocation(); Location<World> loc2 = this.getMaxLocation(); World w = Sponge.getServer().getWorld(this.getWorld()).get(); for (int x = loc1.getBlockX(); x <= loc2.getBlockX(); ++x) { for (int z = loc1.getBlockZ(); z <= loc2.getBlockZ(); ++z) { for (int y = miny; y <= maxy; ++y) { if ((z == loc1.getBlockZ() || z == loc2.getBlockZ() || x == loc1.getBlockX() || x == loc2.getBlockX()) && (define || new Location<>(w, x, y, z).getBlock().getType().getName().contains(RedProtect.get().config.configRoot().region_settings.block_id))) { locBlocks.add(new Location<>(w, x, y, z)); } } } } return locBlocks; }
Example 3
Source File: RedProtectUtil.java From RedProtect with GNU General Public License v3.0 | 6 votes |
public boolean canBuildNear(Player p, Location<World> loc) { if (RedProtect.get().config.configRoot().region_settings.deny_build_near <= 0) { return true; } int x = loc.getBlockX(); int y = loc.getBlockY(); int z = loc.getBlockZ(); int radius = RedProtect.get().config.configRoot().region_settings.deny_build_near; for (int ix = x - radius; ix <= x + radius; ++ix) { for (int iy = y - radius; iy <= y + radius; ++iy) { for (int iz = z - radius; iz <= z + radius; ++iz) { Region reg = RedProtect.get().rm.getTopRegion(new Location<>(p.getWorld(), ix, iy, iz), RedProtectUtil.class.getName()); if (reg != null && !reg.canBuild(p)) { RedProtect.get().lang.sendMessage(p, RedProtect.get().lang.get("blocklistener.cantbuild.nearrp").replace("{distance}", "" + radius)); return false; } } } } return true; }
Example 4
Source File: WorldUtil.java From Prism with MIT License | 5 votes |
public static int removeIllegalBlocks(Location<World> location, int radius) { final World world = location.getExtent(); int xMin = location.getBlockX() - radius; int xMax = location.getBlockX() + radius; int zMin = location.getBlockZ() - radius; int zMax = location.getBlockZ() + radius; int yMin = location.getBlockY() - radius; int yMax = location.getBlockY() + radius; // Clamp Y basement if (yMin < 0) { yMin = 0; } // Clamp Y ceiling if (yMax >= world.getDimension().getBuildHeight()) { yMax = world.getDimension().getBuildHeight(); } int changeCount = 0; for (int x = xMin; x <= xMax; x++) { for (int z = zMin; z <= zMax; z++) { for (int y = yMin; y <= yMax; y++) { BlockType existing = world.getBlock(x, y, z).getType(); if (existing.equals(BlockTypes.FIRE) || existing.equals(BlockTypes.TNT)) { world.setBlockType(x, y, z, BlockTypes.AIR); changeCount++; } } } } return changeCount; }
Example 5
Source File: WorldUtil.java From Prism with MIT License | 5 votes |
/** * Remove a specific block from a given radius around a region. * * @param type BlockType to remove. * @param location Location center * @param radius Integer radius around location * @return integer Count of removals */ public static int removeAroundFromLocation(BlockType type, Location<World> location, int radius) { final World world = location.getExtent(); int xMin = location.getBlockX() - radius; int xMax = location.getBlockX() + radius; int zMin = location.getBlockZ() - radius; int zMax = location.getBlockZ() + radius; int yMin = location.getBlockY() - radius; int yMax = location.getBlockY() + radius; // Clamp Y basement if (yMin < 0) { yMin = 0; } // Clamp Y ceiling if (yMax >= world.getDimension().getBuildHeight()) { yMax = world.getDimension().getBuildHeight(); } int changeCount = 0; for (int x = xMin; x <= xMax; x++) { for (int z = zMin; z <= zMax; z++) { for (int y = yMin; y <= yMax; y++) { if (world.getBlock(x, y, z).getType().equals(type)) { world.setBlockType(x, y, z, BlockTypes.AIR); changeCount++; } } } } return changeCount; }
Example 6
Source File: WorldUtil.java From Prism with MIT License | 5 votes |
/** * Removes all item entities in a radius around a given a location. * * @param location Location center * @param radius Integer radius around location * @return integer Count of removals */ public static int removeItemEntitiesAroundLocation(Location<World> location, int radius) { int xMin = location.getBlockX() - radius; int xMax = location.getBlockX() + radius; int zMin = location.getBlockZ() - radius; int zMax = location.getBlockZ() + radius; int yMin = location.getBlockY() - radius; int yMax = location.getBlockY() + radius; Collection<Entity> entities = location.getExtent().getEntities(e -> { Location<World> loc = e.getLocation(); return (e.getType().equals(EntityTypes.ITEM) && (loc.getX() > xMin && loc.getX() <= xMax) && (loc.getY() > yMin && loc.getY() <= yMax) && (loc.getZ() > zMin && loc.getZ() <= zMax) ); }); if (!entities.isEmpty()) { entities.forEach(Entity::remove); } return entities.size(); }
Example 7
Source File: Region.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public void setTPPoint(@Nullable Location<World> loc) { setToSave(true); if (loc != null) { this.tppoint = new int[]{loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()}; double x = loc.getX(); double y = loc.getY(); double z = loc.getZ(); String pos = loc.getPosition().toString(); RedProtect.get().rm.updateLiveRegion(this, "tppoint", x + "," + y + "," + z + "," + pos); } else { this.tppoint = null; RedProtect.get().rm.updateLiveRegion(this, "tppoint", ""); } }
Example 8
Source File: RedProtectUtil.java From RedProtect with GNU General Public License v3.0 | 5 votes |
public void addProps(CommentedConfigurationNode fileDB, Region r) { String rname = r.getName(); fileDB.getNode(rname, "name").setValue(rname); fileDB.getNode(rname, "lastvisit").setValue(r.getDate()); fileDB.getNode(rname, "leaders").setValue(r.getLeaders().stream().map(t -> t.getUUID() + "@" + t.getPlayerName()).collect(Collectors.toList())); fileDB.getNode(rname, "admins").setValue(r.getAdmins().stream().map(t -> t.getUUID() + "@" + t.getPlayerName()).collect(Collectors.toList())); fileDB.getNode(rname, "members").setValue(r.getMembers().stream().map(t -> t.getUUID() + "@" + t.getPlayerName()).collect(Collectors.toList())); fileDB.getNode(rname, "priority").setValue(r.getPrior()); fileDB.getNode(rname, "welcome").setValue(r.getWelcome()); fileDB.getNode(rname, "world").setValue(r.getWorld()); fileDB.getNode(rname, "maxX").setValue(r.getMaxMbrX()); fileDB.getNode(rname, "maxZ").setValue(r.getMaxMbrZ()); fileDB.getNode(rname, "minX").setValue(r.getMinMbrX()); fileDB.getNode(rname, "minZ").setValue(r.getMinMbrZ()); fileDB.getNode(rname, "maxY").setValue(r.getMaxY()); fileDB.getNode(rname, "minY").setValue(r.getMinY()); fileDB.getNode(rname, "candelete").setValue(r.canDelete()); for (Map.Entry<String, Object> flag : r.getFlags().entrySet()) { fileDB.getNode(rname, "flags", flag.getKey()).setValue(flag.getValue()); } fileDB.getNode(rname, "value").setValue(r.getValue()); Location<World> loc = r.getTPPoint(); if (loc != null) { int x = loc.getBlockX(); int y = loc.getBlockY(); int z = loc.getBlockZ(); //float yaw = loc.getYaw(); //float pitch = loc.getPitch(); fileDB.getNode(rname, "tppoint").setValue(x + "," + y + "," + z/*+","+yaw+","+pitch*/); } else { fileDB.getNode(rname, "tppoint").setValue(""); } }
Example 9
Source File: GPClaim.java From GriefPrevention with MIT License | 5 votes |
public boolean contains(Location<World> location, boolean excludeChildren, GPPlayerData playerData, boolean useBorderBlockRadius) { int x = location.getBlockX(); int y = location.getBlockY(); int z = location.getBlockZ(); int borderBlockRadius = 0; if (useBorderBlockRadius && (playerData != null && !playerData.ignoreBorderCheck)) { final int borderRadiusConfig = GriefPreventionPlugin.getActiveConfig(location.getExtent().getUniqueId()).getConfig().claim.borderBlockRadius; if (borderRadiusConfig > 0 && !this.isUserTrusted((User) playerData.getPlayerSubject(), TrustType.BUILDER)) { borderBlockRadius = borderRadiusConfig; } } // main check boolean inClaim = ( y >= (this.lesserBoundaryCorner.getBlockY() - borderBlockRadius)) && y < (this.greaterBoundaryCorner.getBlockY() + 1 + borderBlockRadius) && x >= (this.lesserBoundaryCorner.getBlockX() - borderBlockRadius) && x < (this.greaterBoundaryCorner.getBlockX() + 1 + borderBlockRadius) && z >= (this.lesserBoundaryCorner.getBlockZ() - borderBlockRadius) && z < (this.greaterBoundaryCorner.getBlockZ() + 1 + borderBlockRadius); if (!inClaim) { return false; } // additional check for children claims, you're only in a child claim when you're also in its parent claim // NOTE: if a player creates children then resizes the parent claim, // it's possible that a child can reach outside of its parent's boundaries. so this check is important! if (!excludeChildren && this.parent != null && (this.getData() == null || (this.getData() != null && this.getData().doesInheritParent()))) { return this.parent.contains(location, false); } return true; }
Example 10
Source File: GPClaim.java From GriefPrevention with MIT License | 5 votes |
boolean hasSurfaceFluids() { Location<World> lesser = this.getLesserBoundaryCorner(); Location<World> greater = this.getGreaterBoundaryCorner(); // don't bother for very large claims, too expensive if (this.getClaimBlocks() > MAX_AREA) { return false; } int seaLevel = 0; // clean up all fluids in the end // respect sea level in normal worlds if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.OVERWORLD)) { seaLevel = GriefPreventionPlugin.instance.getSeaLevel(lesser.getExtent()); } for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) { for (int z = lesser.getBlockZ(); z <= greater.getBlockZ(); z++) { for (int y = seaLevel - 1; y < lesser.getExtent().getDimension().getBuildHeight(); y++) { // dodge the exclusion claim BlockState block = lesser.getExtent().getBlock(x, y, z); if (block.getType() == BlockTypes.WATER || block.getType() == BlockTypes.FLOWING_WATER || block.getType() == BlockTypes.LAVA || block.getType() == BlockTypes.FLOWING_LAVA) { return true; } } } } return false; }
Example 11
Source File: Nation.java From Nations with MIT License | 5 votes |
public Zone getZone(Location<World> loc) { Vector2i p = new Vector2i(loc.getBlockX(), loc.getBlockZ()); for (Zone zone : zones.values()) { if (zone.getRect().isInside(p)) { return zone; } } return null; }
Example 12
Source File: SpongePlayer.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public FaweLocation getLocation() { Location<World> loc = this.parent.getLocation(); return new FaweLocation(loc.getExtent().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); }
Example 13
Source File: SpongePlayer.java From FastAsyncWorldedit with GNU General Public License v3.0 | 4 votes |
@Override public FaweLocation getLocation() { Location<World> loc = this.parent.getLocation(); return new FaweLocation(loc.getExtent().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); }
Example 14
Source File: GPClaim.java From GriefPrevention with MIT License | 4 votes |
public void removeSurfaceFluids(GPClaim exclusionClaim) { // don't do this for administrative claims if (this.isAdminClaim()) { return; } // don't do it for very large claims if (this.getClaimBlocks() > MAX_AREA) { return; } // only in creative mode worlds if (!GriefPreventionPlugin.instance.claimModeIsActive(this.lesserBoundaryCorner.getExtent().getProperties(), ClaimsMode.Creative)) { return; } Location<World> lesser = this.getLesserBoundaryCorner(); Location<World> greater = this.getGreaterBoundaryCorner(); if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.NETHER)) { return; // don't clean up lava in the nether } int seaLevel = 0; // clean up all fluids in the end // respect sea level in normal worlds if (lesser.getExtent().getDimension().getType().equals(DimensionTypes.OVERWORLD)) { seaLevel = GriefPreventionPlugin.instance.getSeaLevel(lesser.getExtent()); } for (int x = lesser.getBlockX(); x <= greater.getBlockX(); x++) { for (int z = lesser.getBlockZ(); z <= greater.getBlockZ(); z++) { for (int y = seaLevel - 1; y < lesser.getExtent().getDimension().getBuildHeight(); y++) { // dodge the exclusion claim BlockSnapshot block = lesser.getExtent().createSnapshot(x, y, z); if (exclusionClaim != null && exclusionClaim.contains(block.getLocation().get(), false)) { continue; } if (block.getState().getType() == BlockTypes.LAVA || block.getState().getType() == BlockTypes.FLOWING_WATER || block.getState().getType() == BlockTypes.WATER || block.getState().getType() == BlockTypes.FLOWING_LAVA) { block.withState(BlockTypes.AIR.getDefaultState()).restore(true, BlockChangeFlags.PHYSICS); } } } } }
Example 15
Source File: GriefPreventionPlugin.java From GriefPrevention with MIT License | 4 votes |
public static String getfriendlyLocationString(Location<World> location) { return location.getExtent().getName() + ": x" + location.getBlockX() + ", z" + location.getBlockZ(); }
Example 16
Source File: Visualization.java From GriefPrevention with MIT License | 4 votes |
private void addClaimElements(int height, Location<World> locality, GPPlayerData playerData) { this.initBlockVisualTypes(type); Location<World> lesser = this.claim.getLesserBoundaryCorner(); Location<World> greater = this.claim.getGreaterBoundaryCorner(); World world = lesser.getExtent(); boolean liquidTransparent = locality.getBlock().getType().getProperty(MatterProperty.class).isPresent() ? false : true; this.smallx = lesser.getBlockX(); this.smally = this.useCuboidVisual() ? lesser.getBlockY() : 0; this.smallz = lesser.getBlockZ(); this.bigx = greater.getBlockX(); this.bigy = this.useCuboidVisual() ? greater.getBlockY() : 0; this.bigz = greater.getBlockZ(); this.minx = this.claim.cuboid ? this.smallx : locality.getBlockX() - 75; this.minz = this.claim.cuboid ? this.smallz : locality.getBlockZ() - 75; this.maxx = this.claim.cuboid ? this.bigx : locality.getBlockX() + 75; this.maxz = this.claim.cuboid ? this.bigz : locality.getBlockZ() + 75; // initialize visualization elements without Y values and real data // that will be added later for only the visualization elements within // visualization range if (this.smallx == this.bigx && this.smally == this.bigy && this.smallz == this.bigz) { BlockSnapshot blockClicked = snapshotBuilder.from(new Location<World>(world, this.smallx, this.smally, this.smallz)).blockState(this.cornerMaterial.getDefaultState()).build(); elements.add(new Transaction<BlockSnapshot>(blockClicked.getLocation().get().createSnapshot(), blockClicked)); return; } // check CUI support if (GriefPreventionPlugin.instance.worldEditProvider != null && playerData != null && GriefPreventionPlugin.instance.worldEditProvider.hasCUISupport(playerData.getPlayerName())) { playerData.showVisualFillers = false; STEP = 0; } if (this.useCuboidVisual()) { this.addVisuals3D(claim, playerData); } else { this.addVisuals2D(claim, height, liquidTransparent); } }
Example 17
Source File: Region.java From RedProtect with GNU General Public License v3.0 | 2 votes |
/** * Represents the region created by player. * * @param name Name of region. * @param admins List of admins. * @param members List of members. * @param leaders List of leaders. * @param minLoc Min coord. * @param maxLoc Max coord. * @param flags Flag names and values. * @param wMessage Welcome message. * @param prior Priority of region. * @param worldName Name of world for this region. * @param date Date of latest visit of an admin or leader. * @param value Last playername of this region. * @param tppoint Teleport Point * @param candel Can delete? */ public Region(String name, Set<PlayerRegion> admins, Set<PlayerRegion> members, Set<PlayerRegion> leaders, int[] minLoc, int[] maxLoc, HashMap<String, Object> flags, String wMessage, int prior, String worldName, String date, long value, Location<World> tppoint, boolean candel, boolean canPurge) { super(name, admins, members, leaders, minLoc, maxLoc, flags, wMessage, prior, worldName, date, value, tppoint == null ? null : new int[]{tppoint.getBlockX(), tppoint.getBlockY(), tppoint.getBlockZ()}, tppoint == null ? null : new float[]{0, 0}, candel, canPurge); checkParticle(); }
Example 18
Source File: Region.java From RedProtect with GNU General Public License v3.0 | 2 votes |
/** * Represents the region created by player. * * @param name Name of region. * @param admins List of admins. * @param members List of members. * @param leaders List of leaders. * @param maxMbrX Max coord X * @param minMbrX Min coord X * @param maxMbrZ Max coord Z * @param minMbrZ Min coord Z * @param minY Min location * @param maxY Max Location * @param flags Flag names and values. * @param wMessage Welcome message. * @param prior Priority of region. * @param worldName Name of world for this region. * @param date Date of latest visit of an admin or leader. * @param value Last playername of this region. * @param tppoint Teleport Point * @param candel Can delete? */ public Region(String name, Set<PlayerRegion> admins, Set<PlayerRegion> members, Set<PlayerRegion> leaders, int maxMbrX, int minMbrX, int maxMbrZ, int minMbrZ, int minY, int maxY, HashMap<String, Object> flags, String wMessage, int prior, String worldName, String date, long value, Location<World> tppoint, boolean candel, boolean canPurge) { super(name, admins, members, leaders, maxMbrX, minMbrX, maxMbrZ, minMbrZ, minY, maxY, flags, wMessage, prior, worldName, date, value, tppoint == null ? null : new int[]{tppoint.getBlockX(), tppoint.getBlockY(), tppoint.getBlockZ()}, tppoint == null ? null : new float[]{0, 0}, candel, canPurge); checkParticle(); }
Example 19
Source File: Region.java From RedProtect with GNU General Public License v3.0 | 2 votes |
/** * Represents the region created by player. * * @param name Region name. * @param admins Admins names/uuids. * @param members Members names/uuids. * @param leaders Leaders name/uuid. * @param x Locations of x coords. * @param z Locations of z coords. * @param miny Min coord y of this region. * @param maxy Max coord y of this region. * @param prior Location of x coords. * @param worldName Name of world region. * @param date Date of latest visit of an admins or leader. * @param flags Default flags. * @param welcome Set a welcome message. * @param value A playername in server economy. * @param tppoint Teleport Point * @param candel Can delete? */ public Region(String name, Set<PlayerRegion> admins, Set<PlayerRegion> members, Set<PlayerRegion> leaders, int[] x, int[] z, int miny, int maxy, int prior, String worldName, String date, Map<String, Object> flags, String welcome, long value, Location<World> tppoint, boolean candel, boolean canPurge) { super(name, admins, members, leaders, x, z, miny, maxy, prior, worldName, date, flags, welcome, value, tppoint == null ? null : new int[]{tppoint.getBlockX(), tppoint.getBlockY(), tppoint.getBlockZ()}, tppoint == null ? null : new float[]{0, 0}, candel, canPurge); checkParticle(); }
Example 20
Source File: Region.java From RedProtect with GNU General Public License v3.0 | 2 votes |
/** * Represents the region created by player. * * @param name Region name. * @param min Min Location. * @param max Max Location. * @param world World name. */ public Region(String name, Location min, Location max, String world) { super(name, new int[]{min.getBlockX(), min.getBlockY(), min.getBlockZ()}, new int[]{max.getBlockX(), max.getBlockY(), max.getBlockZ()}, world, RedProtect.get().config.configRoot().region_settings.default_leader, RedProtect.get().config.getDefFlagsValues()); checkParticle(); }