Java Code Examples for org.spongepowered.api.world.Location#getZ()

The following examples show how to use org.spongepowered.api.world.Location#getZ() . 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: Visualization.java    From GriefPrevention with MIT License 5 votes vote down vote up
private void removeElementsOutOfRange(ArrayList<Transaction<BlockSnapshot>> elements, int minx, int minz, int maxx, int maxz) {
    for (int i = 0; i < elements.size(); i++) {
        Location<World> location = elements.get(i).getFinal().getLocation().get();
        if (location.getX() < minx || location.getX() > maxx || location.getZ() < minz || location.getZ() > maxz) {
            elements.remove(i);
        }
    }
}
 
Example 2
Source File: BlockUtils.java    From GriefPrevention with MIT License 5 votes vote down vote up
public static boolean isLocationNearClaim(GPClaim claim, Location<World> location, int howNear) {
    Location<World> lesserBoundaryCorner = new Location<World>(claim.lesserBoundaryCorner.getExtent(), claim.lesserBoundaryCorner.getBlockX() - howNear,
            claim.lesserBoundaryCorner.getBlockY(), claim.lesserBoundaryCorner.getBlockZ() - howNear);
    Location<World> greaterBoundaryCorner = new Location<World>(claim.greaterBoundaryCorner.getExtent(), claim.greaterBoundaryCorner.getBlockX() + howNear,
            claim.greaterBoundaryCorner.getBlockY(), claim.greaterBoundaryCorner.getBlockZ() + howNear);
    // not in the same world implies false
    if (!location.getExtent().equals(lesserBoundaryCorner.getExtent())) {
        return false;
    }

    double x = location.getX();
    double y = location.getY();
    double z = location.getZ();

    // main check
    boolean inClaim = false;
    if (claim.isCuboid()) {
        inClaim = (
                x >= lesserBoundaryCorner.getX() &&
                x <= greaterBoundaryCorner.getX() &&
                y >= lesserBoundaryCorner.getY()) &&
                y <= greaterBoundaryCorner.getY() &&
                z >= lesserBoundaryCorner.getZ() &&
                z <= greaterBoundaryCorner.getZ();
    } else {
        inClaim = (y >= lesserBoundaryCorner.getY()) &&
            x >= lesserBoundaryCorner.getX() &&
            x < greaterBoundaryCorner.getX() + 1 &&
            z >= lesserBoundaryCorner.getZ() &&
            z < greaterBoundaryCorner.getZ() + 1;
    }

    if (!inClaim) {
        return false;
    }

    return true;
}
 
Example 3
Source File: Region.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
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 4
Source File: ConfigManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void putSign(String rid, Location<World> loc) {
    try {
        List<String> lsigns = new ArrayList<>(signCfgs.getNode(rid).getList(of(String.class)));
        String locs = loc.getExtent().getName() + "," + loc.getX() + "," + loc.getY() + "," + loc.getZ();
        if (!lsigns.contains(locs)) {
            lsigns.add(locs);
            saveSigns(rid, lsigns);
        }
    } catch (ObjectMappingException e) {
        CoreUtil.printJarVersion();
        e.printStackTrace();
    }
}
 
Example 5
Source File: ConfigManager.java    From RedProtect with GNU General Public License v3.0 5 votes vote down vote up
public void removeSign(String rid, Location<World> loc) {
    try {
        List<String> lsigns = new ArrayList<>(signCfgs.getNode(rid).getList(of(String.class)));
        String locs = loc.getExtent().getName() + "," + loc.getX() + "," + loc.getY() + "," + loc.getZ();
        if (lsigns.contains(locs)) {
            lsigns.remove(locs);
            saveSigns(rid, lsigns);
        }
    } catch (ObjectMappingException e) {
        CoreUtil.printJarVersion();
        e.printStackTrace();
    }
}