当前位置: 首页>>代码示例>>Java>>正文


Java Location.distanceSquared方法代码示例

本文整理汇总了Java中org.bukkit.Location.distanceSquared方法的典型用法代码示例。如果您正苦于以下问题:Java Location.distanceSquared方法的具体用法?Java Location.distanceSquared怎么用?Java Location.distanceSquared使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bukkit.Location的用法示例。


在下文中一共展示了Location.distanceSquared方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getArmorStand

import org.bukkit.Location; //导入方法依赖的package包/类
private static ArmorStand getArmorStand(Block b)
{
    Location l = new Location(b.getWorld(), (double)b.getX() + 0.5D, (double)b.getY() + 1.2D, (double)b.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    hologram.setCustomNameVisible(false);
    hologram.setCustomName(null);
    return hologram;
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:18,代码来源:AndroidStatusHologram.java

示例2: getArmorStand

import org.bukkit.Location; //导入方法依赖的package包/类
public static ArmorStand getArmorStand(Block hopper)
{
    Location l = new Location(hopper.getWorld(), (double)hopper.getX() + 0.5D, (double)hopper.getY() + 1.2D, (double)hopper.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    hologram.setCustomNameVisible(false);
    hologram.setCustomName(null);
    return hologram;
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:18,代码来源:XPCollector.java

示例3: getArmorStand

import org.bukkit.Location; //导入方法依赖的package包/类
public static ArmorStand getArmorStand(Block hopper)
{
    Location l = new Location(hopper.getWorld(), (double)hopper.getX() + 0.5D, hopper.getY(), (double)hopper.getZ() + 0.5D);
    Entity aentity[];
    int j = (aentity = l.getChunk().getEntities()).length;
    for(int i = 0; i < j; i++)
    {
        Entity n = aentity[i];
        if((n instanceof ArmorStand) && n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.40000000000000002D)
            return (ArmorStand)n;
    }

    ArmorStand hologram = ArmorStandFactory.createHidden(l);
    hologram.setCustomNameVisible(false);
    hologram.setCustomName(null);
    return hologram;
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:18,代码来源:AutoBreeder.java

示例4: getArmorStand

import org.bukkit.Location; //导入方法依赖的package包/类
public static ArmorStand getArmorStand(Block hopper, boolean createIfNoneFound) {
	Location l = new Location(hopper.getWorld(), hopper.getX() + 0.5, hopper.getY() + offset, hopper.getZ() + 0.5);
	
	for (Entity n: l.getChunk().getEntities()) {
		if (n instanceof ArmorStand) {
			if (n.getCustomName() == null && l.distanceSquared(n.getLocation()) < 0.4D) return (ArmorStand) n;
		}
	}

	if (!createIfNoneFound) {
		return null;
	}
	
	ArmorStand hologram = ArmorStandFactory.createHidden(l);
	hologram.setCustomNameVisible(false);
	hologram.setCustomName(null);
	return hologram;
}
 
开发者ID:StarWishsama,项目名称:Slimefun4-Chinese-Version,代码行数:19,代码来源:InfusedHopper.java

示例5: Yodel

import org.bukkit.Location; //导入方法依赖的package包/类
Yodel(Hub hub, Location boarding, Location start, Location end, Location landing)
{
    super(hub);
    this.boarding = boarding.clone();
    this.start    = start.clone();
    this.end      = end.clone();
    this.landing  = landing.clone();

    this.length = start.distanceSquared(end);

    this.startBeacon = boarding.getWorld().spawn(boarding, ArmorStand.class);
    this.startBeacon.setVisible(false);
    this.startBeacon.setGravity(false);

    this.hub.getTaskManager().getCirclesTask().addCircleAt(boarding);
    this.startTask = ProximityUtils.onNearbyOf(this.hub, this.startBeacon, 0.5D, 0.5D, 0.5D, Player.class, this::play);
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:18,代码来源:Yodel.java

示例6: getCheckpoint

import org.bukkit.Location; //导入方法依赖的package包/类
private int getCheckpoint(Player player) {
    Location location = player.getLocation();

    for (int i = 0; i < checkpointLocs.size(); i++) {
        Location checkpoint = checkpointLocs.get(i);

        if (checkpoint.distanceSquared(location) < checkpointSize) {
            return i;
        }
    }

    return -1;
}
 
开发者ID:ArcadiaPlugins,项目名称:Arcadia-Spigot,代码行数:14,代码来源:HorseRaceGame.java

示例7: getClosestEntity

import org.bukkit.Location; //导入方法依赖的package包/类
public static @Nullable <T extends Entity> T getClosestEntity(Location location, Vector range, final Class<T> type) {
    T closest = null;
    double minDistanceSquared = Double.POSITIVE_INFINITY;
    for(Entity entity : location.getWorld().getNearbyEntities(location, range.getX(), range.getY(), range.getZ())) {
        if(type.isInstance(entity)) {
            double distanceSquared = location.distanceSquared(entity.getLocation());
            if(distanceSquared < minDistanceSquared) {
                minDistanceSquared = distanceSquared;
                closest = type.cast(entity);
            }
        }
    }
    return closest;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:15,代码来源:EntityUtils.java

示例8: removeEntities

import org.bukkit.Location; //导入方法依赖的package包/类
private void removeEntities(Location origin, double radius) {
    if(radius <= 0) return;

    double radiusSq = radius * radius;
    for(Entity ent : origin.getWorld().getEntities()) {
        if(origin.distanceSquared(ent.getLocation()) > radiusSq)
            continue;

        if(ent instanceof TNTPrimed) {
            ent.remove();
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:14,代码来源:Freeze.java

示例9: run

import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void run()
{
    final Location playerLocation = player.getLocation();


    // Checks if the player is still on the line

    Vector position   = playerLocation.toVector();
    Vector origin     = getStart().toVector();
    Vector director   = yodel.getAngleVector();
    double k;

    if (isZero(origin)) origin = getEnd().toVector();

    try
    {
        k = director.getX() * (position.getX() - origin.getX())
                + director.getY() * (position.getY() - origin.getY())
                + director.getZ() * (position.getZ() - origin.getZ());

        k /= NumberConversions.square(director.getX())
                + NumberConversions.square(director.getY())
                + NumberConversions.square(director.getZ());
    }
    catch (ArithmeticException e)
    {
        this.hub.getLogger().log(Level.SEVERE, "Division by zero while checking route on yodel, remains unfixed", e);
        return;
    }

    Vector projection = origin.add(director.multiply(k));

    if (projection.distanceSquared(position) > 4)
    {
        player.teleport(projection.toLocation(playerLocation.getWorld()).setDirection(playerLocation.getDirection()));
    }


    // Updates the velocity

    player.setVelocity(velocityStep);
    player.setFallDistance(0);


    // Checks if the line is finished (either we are on the finish zone, or out of the path if for some
    // reason the landing zone was not entered)

    if (playerLocation.distanceSquared(getEnd()) < 6
            || playerLocation.distanceSquared(getStart()) > yodel.getLength() + 10)
    {
        this.yodel.stop(player);
    }
}
 
开发者ID:SamaGames,项目名称:Hub,代码行数:55,代码来源:YodelRunner.java

示例10: isPlayerInGeckRange

import org.bukkit.Location; //导入方法依赖的package包/类
/**
 * @param player
 *            The player in question
 * @return <CODE>True </CODE> If the player is inside geck range and geck is
 *         powered and built correctly.
 *         <p>
 *         <CODE>False </CODE> If the player is not in range. Also if the
 *         player is in range but geck is not powered or incorrect.
 */
public boolean isPlayerInGeckRange(Player player) {
	for (GeckObject geckObject : main.getGeckObjectManager().getGecklocationMap().values()) {
		Location geckLocation = geckObject.getGeckLocation();
		Location playerLocation = player.getLocation();
		
		if (!geckLocation.getWorld().equals(playerLocation.getWorld()))
			continue;

		double distance = geckLocation.distanceSquared(playerLocation);

		// if the distance is less than or = to x and the GECK is correct
		// and powered then you are in range of the geck
		// this is the squared range of blocks. the block range is 15
		// blocks.
		int x = 225;
		UUID uuid = player.getUniqueId();

		// If the player is not inside the radiationMap
		if (!main.getPlayerManager().containsMortuusPlayer(uuid)) {
			return false;
		}
	
		PlayerObject mortuusPlayer = main.getPlayerManager().getMortuusPlayer(uuid);
		
		if (distance <= x) {
	
			if (geckObject.isCorrect() && geckObject.isPowered()) {
				// Player inside radius and geck is powered + correct
				mortuusPlayer.setPlayerInRangeOfGeck(true);
				return true;
			} else {
				// Player is inside but either geck not powered or not
				// correct or both
				mortuusPlayer.setPlayerInRangeOfGeck(false);
				return false;
			}
		}
	}
	return false;
}
 
开发者ID:kadeska,项目名称:MT_Core,代码行数:50,代码来源:GeckManager.java


注:本文中的org.bukkit.Location.distanceSquared方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。