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


Java Location.toVector方法代码示例

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


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

示例1: Region

import org.bukkit.Location; //导入方法依赖的package包/类
public Region(Location pointA, Location pointB) {
    Validate.isTrue(pointA.getWorld().equals(pointB.getWorld()), "Two worlds are different.");

    double minX = Math.min(pointA.getBlockX(), pointB.getBlockX());
    double maxX = Math.max(pointA.getBlockX(), pointB.getBlockX()) + 1;
    double minY = Math.min(pointA.getBlockY(), pointB.getBlockY());
    double maxY = Math.max(pointA.getBlockY(), pointB.getBlockY());
    double minZ = Math.min(pointA.getBlockZ(), pointB.getBlockZ());
    double maxZ = Math.max(pointA.getBlockZ(), pointB.getBlockZ()) + 1;

    pointA.setX(minX);
    pointA.setY(minY);
    pointA.setZ(minZ);
    pointB.setX(maxX);
    pointB.setY(maxY);
    pointB.setZ(maxZ);

    this.world = pointA.getWorld().getName();
    this.min = pointA.toVector();
    this.max = pointB.toVector();
}
 
开发者ID:EntryPointKR,项目名称:MCLibrary,代码行数:22,代码来源:Region.java

示例2: getYawBetween

import org.bukkit.Location; //导入方法依赖的package包/类
public static double getYawBetween(Location from, Location to) {
	final Location change = from.clone();

	final Vector start = change.toVector();
	final Vector target = to.toVector();

	// Get the difference between the two locations and set this as the
	// direction (the direct line from location to location).
	change.setDirection(target.subtract(start));

	return change.getYaw();
}
 
开发者ID:davidm98,项目名称:Crescent,代码行数:13,代码来源:Helper.java

示例3: shouldReload

import org.bukkit.Location; //导入方法依赖的package包/类
private boolean shouldReload(Location from, Location to, Player player) {
	if (from.getWorld() != to.getWorld()) {
		return true;
	}
	Vector fvec = from.toVector();
	Vector tvec = to.toVector();
	double distance = fvec.distance(tvec);
	if (distance < 6) {
		return false;
	}
	return true;
}
 
开发者ID:GelandiAssociation,项目名称:EscapeLag,代码行数:13,代码来源:TeleportPreLoader.java

示例4: 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


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