org.bukkit.Location#getX ( )源码实例Demo

下面列出了org.bukkit.Location#getX ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Civs   文件: TownManager.java
public List<Town> checkIntersect(Location location, TownType townType, int modifier) {
    int buildRadius = townType.getBuildRadius() + modifier;
    int buildRadiusY = townType.getBuildRadiusY() + modifier;
    List<Town> towns = new ArrayList<>();
    for (Town town : getTowns()) {
        if (!location.getWorld().equals(town.getLocation().getWorld())) {
            continue;
        }
        TownType currentTownType = (TownType) ItemManager.getInstance().getItemType(town.getType());
        if (location.getX() + buildRadius >= town.getLocation().getX() - currentTownType.getBuildRadius() &&
                location.getX() - buildRadius <= town.getLocation().getX() + currentTownType.getBuildRadius() &&
                location.getZ() + buildRadius >= town.getLocation().getZ() - currentTownType.getBuildRadius() &&
                location.getZ() - buildRadius <= town.getLocation().getZ() + currentTownType.getBuildRadius() &&
                Math.max(location.getY() - buildRadiusY, 0) <=
                        Math.max(town.getLocation().getY() + currentTownType.getBuildRadiusY(), 0) &&
                Math.min(location.getY() + buildRadiusY, location.getWorld().getMaxHeight()) >=
                        Math.min(town.getLocation().getY() - currentTownType.getBuildRadiusY(), town.getLocation().getWorld().getMaxHeight())) {
            towns.add(town);
        }
    }
    return towns;
}
 
源代码2 项目: Crazy-Crates   文件: NMS_v1_9_R2.java
@Override
public List<Location> getLocations(File f, Location loc) {
    loc = loc.subtract(2, 1, 2);
    List<Location> locations = new ArrayList<>();
    try {
        FileInputStream fis = new FileInputStream(f);
        NBTTagCompound nbt = NBTCompressedStreamTools.a(fis);
        short width = nbt.getShort("Width");
        short height = nbt.getShort("Height");
        short length = nbt.getShort("Length");
        fis.close();
        //paste
        for (int x = 0; x < width; ++x) {
            for (int y = 0; y < height; ++y) {
                for (int z = 0; z < length; ++z) {
                    final Location l = new Location(loc.getWorld(), x + loc.getX(), y + loc.getY(), z + loc.getZ());
                    locations.add(l);
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return locations;
}
 
源代码3 项目: Civs   文件: ArrowTurret.java
private boolean hasCleanShot(Location shootHere, Location targetHere) {
        double x = shootHere.getX();
        double y = shootHere.getY();
        double z = shootHere.getZ();

        double x1 = targetHere.getX();
        double y1 = targetHere.getY();
        double z1 = targetHere.getZ();

        Vector start = new Vector(x, y, z);
        Vector end = new Vector (x1, y1, z1);

        BlockIterator bi = new BlockIterator(shootHere.getWorld(), start, end, 0, (int) shootHere.distance(targetHere));
        while (bi.hasNext()) {
            Block block = bi.next();
//            System.out.println(Civs.getPrefix() + ((int) block.getLocation().getX()) +
//                    ":" + ((int) block.getLocation().getY()) + ":" +
//                    ((int) block.getLocation().getZ()) + " " + !Util.isSolidBlock(block.getType()));
            if (!Util.isSolidBlock(block.getType())) {
                return false;
            }
        }

        return true;
    }
 
源代码4 项目: TAB   文件: MethodAPI_v1_13_R1.java
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new PacketPlayOutEntityTeleport(entity);
}
 
源代码5 项目: BedWars   文件: GameCreator.java
public static boolean isInArea(Location l, Location p1, Location p2) {
    if (!p1.getWorld().equals(l.getWorld())) {
        return false;
    }

    Location min = new Location(p1.getWorld(), Math.min(p1.getX(), p2.getX()), Math.min(p1.getY(), p2.getY()),
            Math.min(p1.getZ(), p2.getZ()));
    Location max = new Location(p1.getWorld(), Math.max(p1.getX(), p2.getX()), Math.max(p1.getY(), p2.getY()),
            Math.max(p1.getZ(), p2.getZ()));
    return (min.getX() <= l.getX() && min.getY() <= l.getY() && min.getZ() <= l.getZ() && max.getX() >= l.getX()
            && max.getY() >= l.getY() && max.getZ() >= l.getZ());
}
 
源代码6 项目: Civs   文件: RegionManager.java
private Region treeSort(double maxdex, UUID worldUuid, Location location) {
    int index;
    double mindex = 0;
    double prevIndex = -5;
    double prevDiff = 999999;
    boolean roundUp = false;
    for (;;) {
        if (roundUp) {
            index = (int) Math.ceil(((maxdex - mindex) / 2) + mindex);
        } else {
            index = (int) Math.floor(((maxdex - mindex) / 2) + mindex);
        }
        Region r = regions.get(worldUuid).get(index);

        if (withinRegion(r, location)) {
            return r;
        } else if (location.getX() < r.getLocation().getX() - r.getRadiusXN()) {
            maxdex = index;
            roundUp = false;
        } else if (location.getX() > r.getLocation().getX() + r.getRadiusXN()) {
            mindex = index;
            roundUp = true;
        } else {
            return findRegion((int) mindex, (int) maxdex, location, index);
        }
        if (prevIndex == index || prevDiff == Math.abs(maxdex - mindex)) {
            return null;
        }
        prevDiff = Math.abs(maxdex - mindex);
        prevIndex = index;
    }
}
 
源代码7 项目: XSeries   文件: XParticle.java
/**
 * Display a rendered image repeatedly.
 *
 * @param render   the rendered image map.
 * @param location the dynamic location to display the image at.
 * @param quality  the quality of the image is exactly the number of particles display for each pixel. Recommended value is 1
 * @param speed    the speed is exactly the same value as the speed of particles. Recommended amount is 0
 * @param size     the size of the particle. Recommended amount is 0.8
 * @since 1.0.0
 */
public static void displayRenderedImage(Map<Location, Color> render, Location location, int quality, int speed, float size) {
    for (Map.Entry<Location, Color> pixel : render.entrySet()) {
        Particle.DustOptions data = new Particle.DustOptions(pixel.getValue(), size);
        Location pixelLoc = pixel.getKey();

        Location loc = new Location(location.getWorld(), location.getX() - pixelLoc.getX(),
                location.getY() - pixelLoc.getY(), location.getZ() - pixelLoc.getZ());
        loc.getWorld().spawnParticle(Particle.REDSTONE, loc, quality, 0, 0, 0, speed, data);
    }
}
 
源代码8 项目: Survival-Games   文件: Arena.java
public boolean containsBlock(Location v) {
    if (v.getWorld() != min.getWorld()) return false;
    final double x = v.getX();
    final double y = v.getY();
    final double z = v.getZ();
    return x >= min.getBlockX() && x < max.getBlockX() + 1 && y >= min.getBlockY() && y < max.getBlockY() + 1 && z >= min.getBlockZ() && z < max.getBlockZ() + 1;  
}
 
源代码9 项目: ProjectAres   文件: NMSHacks.java
public static Packet spawnPlayerPacket(int entityId, UUID uuid, Location location, Player player) {
    return new PacketPlayOutNamedEntitySpawn(entityId,
                                             uuid,
                                             location.getX(), location.getY(), location.getZ(),
                                             encodeAngle(location.getYaw()),
                                             encodeAngle(location.getPitch()),
                                             copyEntityMetadata(player));
}
 
源代码10 项目: AreaShop   文件: WorldGuardHandler5.java
@Override
public Set<ProtectedRegion> getApplicableRegionsSet(Location location) {
	Set<ProtectedRegion> result = new HashSet<>();
	Vector vector = new Vector(location.getX(), location.getY(), location.getZ());
	for(ProtectedRegion region : pluginInterface.getWorldGuard().getRegionManager(location.getWorld()).getRegions().values()) {
		if(region.contains(vector)) {
			result.add(region);
		}
	}
	return result;
}
 
源代码11 项目: Skript   文件: BlockLineIterator.java
@SuppressWarnings("null")
private static Vector fitInWorld(final Location l, final Vector dir) {
	if (0 <= l.getBlockY() && l.getBlockY() < l.getWorld().getMaxHeight())
		return l.toVector();
	final double y = Math2.fit(0, l.getY(), l.getWorld().getMaxHeight());
	if (Math.abs(dir.getY()) < Skript.EPSILON)
		return new Vector(l.getX(), y, l.getZ());
	final double dy = y - l.getY();
	final double n = dy / dir.getY();
	return l.toVector().add(dir.clone().multiply(n));
}
 
源代码12 项目: Civs   文件: BlockLogger.java
public CVItem getBlock(Location location) {
    CVItem returnBlock = blocks.get(Region.locationToString(location));
    if (returnBlock == null) {
        Location newLocation = new Location(location.getWorld(), location.getX() + 0.5,
                location.getY() + 0.5, location.getZ() + 0.5);
        returnBlock = blocks.get(Region.locationToString(newLocation));
    }
    return returnBlock;
}
 
源代码13 项目: Civs   文件: SpawnEffect.java
@EventHandler(ignoreCancelled = true)
    public void onUpkeep(RegionUpkeepEvent event) {
        Location location = event.getRegion().getLocation();
        if (!event.getRegion().getEffects().containsKey(KEY) ||
                !Util.isLocationWithinSightOfPlayer(location)) {
            return;
        }
        EntityType entityType;
        try {
            entityType = EntityType.valueOf(event.getRegion().getEffects().get(KEY));
        } catch (Exception ex) {
            Civs.logger.severe("Wrong entity type " + event.getRegion().getEffects().get(KEY) + " for " +
                    event.getRegion().getType());
            return;
        }

        RegionType regionType = (RegionType) ItemManager.getInstance().getItemType(event.getRegion().getType());
//        int entityCount = 0;
        //TODO fix this so that it detects the correct type of entity
        int radius = Math.max(regionType.getEffectRadius(), regionType.getBuildRadius());
//        for (Entity e : location.getWorld().getNearbyEntities(location,
//                radius, radius, radius)) {
//            if (entityType.getEntityClass().isAssignableFrom(e.getClass())) {
//                entityCount++;
//                if (entityCount > 5) {
//                    return;
//                }
//            }
//        }
        if (location.getWorld().getNearbyEntities(location, radius, radius, radius).size() > 5) {
            return;
        }

        Location spawnLocation = new Location(location.getWorld(), location.getX(), location.getY() + 1, location.getZ());

        location.getWorld().spawnEntity(spawnLocation, entityType);
    }
 
源代码14 项目: TAB   文件: MethodAPI_v1_13_R2.java
public Object newPacketPlayOutEntityTeleport(Object entityliving, Location loc) {
	EntityLiving entity = (EntityLiving) entityliving;
	entity.locX = loc.getX();
	entity.locY = loc.getY();
	entity.locZ = loc.getZ();
	entity.yaw = loc.getYaw();
	entity.pitch = loc.getPitch();
	return new PacketPlayOutEntityTeleport(entity);
}
 
源代码15 项目: civcraft   文件: FishingBoat.java
@Override
protected Location repositionCenter(Location center, String dir, double x_size, double z_size) {
	Location loc = new Location(center.getWorld(), 
			center.getX(), center.getY(), center.getZ(), 
			center.getYaw(), center.getPitch());
	
	// Reposition tile improvements
	if (this.isTileImprovement()) {
		// just put the center at 0,0 of this chunk?
		loc = center.getChunk().getBlock(0, center.getBlockY(), 0).getLocation();
		//loc = center.getChunk().getBlock(arg0, arg1, arg2)
	} else {
		if (dir.equalsIgnoreCase("east")) {
			loc.setZ(loc.getZ() - (z_size / 2));
			loc.setX(loc.getX() + SHIFT_OUT);
		}
		else if (dir.equalsIgnoreCase("west")) {
			loc.setZ(loc.getZ() - (z_size / 2));
			loc.setX(loc.getX() - (SHIFT_OUT+x_size));

		}
		else if (dir.equalsIgnoreCase("north")) {
			loc.setX(loc.getX() - (x_size / 2));
			loc.setZ(loc.getZ() - (SHIFT_OUT+z_size));
		}
		else if (dir.equalsIgnoreCase("south")) {
			loc.setX(loc.getX() - (x_size / 2));
			loc.setZ(loc.getZ() + SHIFT_OUT);

		}
	}
	
	if (this.getTemplateYShift() != 0) {
		// Y-Shift based on the config, this allows templates to be built underground.
		loc.setY(WATER_LEVEL + this.getTemplateYShift());
	}

	return loc;
}
 
源代码16 项目: WildernessTp   文件: ClaimChecks.java
private boolean checkSurroundingsClaims(Location loc) {
    int distance = range / 2;
    Vector top = new Vector(loc.getX() + distance, loc.getY(), loc.getZ() + distance);
    Vector bottom = new Vector(loc.getX() - distance, loc.getY(), loc.getZ() - distance);
    for (int z = bottom.getBlockZ(); z <= top.getBlockZ(); z++) {
        for (int x = bottom.getBlockX(); x <= top.getBlockX(); x++) {
            if (GriefPrevention.instance.dataStore.getClaimAt(new Location(loc.getWorld(), x, loc.getWorld().getHighestBlockYAt(x, z), z), false, null) != null)
                return true;
        }
    }

    return false;
}
 
源代码17 项目: QualityArmory   文件: BlockCollisionUtil.java
public static boolean isSolid(Block b, Location l) {
	if(b.getType().name().equals("SNOW"))
		return false;
	if(b.getType().name().contains("SIGN"))
		return false;
	if (b.getType().name().endsWith("CARPET")) {
		return false;
	}
	if (b.getType() == Material.WATER) {
		if (QAMain.blockbullet_water)
			return true;
	}
	if (b.getType().name().contains("LEAVE")) {
		if (QAMain.blockbullet_leaves)
			return true;
	}
	if (b.getType().name().contains("SLAB") || b.getType().name().contains("STEP")) {
		if (!QAMain.blockbullet_halfslabs && ((l.getY() - l.getBlockY() > 0.5 && b.getData() == 0)
				|| (l.getY() - l.getBlockY() <= 0.5 && b.getData() == 1)))
			return false;
		return true;
	}
	if (b.getType().name().contains("BED_") || b.getType().name().contains("_BED")
			|| b.getType().name().contains("DAYLIGHT_DETECTOR")) {
		if (!QAMain.blockbullet_halfslabs && (l.getY() - l.getBlockY() > 0.5))
			return false;
		return true;
	}
	if (b.getType().name().contains("DOOR")) {
		if (QAMain.blockbullet_door)
			return true;
		return false;
	}
	if (b.getType().name().contains("GLASS")) {
		if (QAMain.blockbullet_glass)
			return true;
		return false;
	}

	if (b.getType().name().contains("STAIR")) {
		if (b.getData() < 4 && (l.getY() - l.getBlockY() < 0.5))
			return true;
		if (b.getData() >= 4 && (l.getY() - l.getBlockY() > 0.5))
			return true;
		switch (b.getData()) {
			case 0:
			case 4:
				return l.getX() - (0.5 + l.getBlockX()) > 0;
			case 1:
			case 5:
				return l.getX() - (0.5 + l.getBlockX()) < 0;
			case 2:
			case 6:
				return l.getZ() - (0.5 + l.getBlockZ()) > 0;
			case 3:
			case 7:
				return l.getZ() - (0.5 + l.getBlockZ()) < 0;

		}
	}

	if (b.getType().name().endsWith("FERN")) {
		return false;
	}
	if (b.getType().isOccluding()) {
		return true;
	}
	return false;
}
 
源代码18 项目: CS-CoreLib   文件: Calculator.java
public static Location centerPosition(Location l ) {
	
	double x = l.getX();
	double z = l.getZ();
	
	String[] rawX = String.valueOf(x).split(".");
	String[] rawZ = String.valueOf(z).split(".");
	
	String newX = rawX[0] + ".5";
	String newZ = rawZ[0] + ".5";
	
	l.setX(Double.parseDouble(newX));
	l.setZ(Double.parseDouble(newZ));
	
	return l;
}
 
源代码19 项目: WorldBorderAPI   文件: Position.java
public Position(Location location){
    this(location.getX(),location.getZ());
}
 
源代码20 项目: ProjectAres   文件: Locations.java
public static double horizontalDistance(Location a, Location b) {
    if(a.getWorld() != b.getWorld()) throw new IllegalArgumentException("Locations are in different worlds");
    double dx = b.getX() - a.getX();
    double dz = b.getZ() - a.getZ();
    return Math.sqrt(dx * dx + dz * dz);
}