當前位置: 首頁>>代碼示例>>Java>>正文


Java Vector.add方法代碼示例

本文整理匯總了Java中org.bukkit.util.Vector.add方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector.add方法的具體用法?Java Vector.add怎麽用?Java Vector.add使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.bukkit.util.Vector的用法示例。


在下文中一共展示了Vector.add方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: WayPointTravel

import org.bukkit.util.Vector; //導入方法依賴的package包/類
public void WayPointTravel(boolean forward) {
	Location nextWaypoint;
	if(forward == true)
		nextWaypoint = WayPoints.get(currentWayPoint + 1);
	else
		nextWaypoint = WayPoints.get(currentWayPoint - 1);
	
	currentWayPoint++;
	if (forward == true && WayPoints.size() >= currentWayPoint)
		forward = false;
	if (forward == false && currentWayPoint == 0)
		forward = true;
	
	Vector deviation = new Vector();
	deviation.add(getLocation().toVector());
	deviation.add(nextWaypoint.toVector());
	
	plugin.getServer().getPlayer(driverName).sendMessage(deviation.toString());
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:20,代碼來源:Craft.java

示例2: startDungeon

import org.bukkit.util.Vector; //導入方法依賴的package包/類
/**Dungeon activation function called when a player gives the /start command. Calls the genEntry() function at that players position.
 * @param p		The player that gave the /start command.
 */
private void startDungeon(Player p) {
	// calc starting location in front of player on level ground:
	// also check if ground is solid. if not then paste over the gras etc.
	int initDist = 10; // distance to player
	Vector start = new Vector(p.getLocation().getBlockX(),p.getLocation().getBlockY(),p.getLocation().getBlockZ());
	Direc playerDirec = Helper.getPlayerDirec(p);
	int deltaX = (int)Math.round(-Helper.sind(playerDirec.degree())*initDist);
	int deltaZ = (int)Math.round(+Helper.cosd(playerDirec.degree())*initDist);
	start.add(new Vector(deltaX,0,deltaZ));
	int solidOffset = 0;
	if (world.getHighestBlockAt(start.getBlockX(), start.getBlockZ()).getType().isSolid()) {
		solidOffset = 1;
	}
	start.setY(world.getHighestBlockYAt(start.getBlockX(), start.getBlockZ())+solidOffset);
	
	genEntry(start, playerDirec);
}
 
開發者ID:TheRoot89,項目名稱:DungeonGen,代碼行數:21,代碼來源:DunGen.java

示例3: stepLocation

import org.bukkit.util.Vector; //導入方法依賴的package包/類
private void stepLocation(Entity ent, Location to, double blocksPerTick) {
    if (!ent.isValid())
        return;

    Location from = ent.getLocation();
    World world = from.getWorld();
    Vector fv = new Vector(from.getX(), from.getY(), from.getZ());
    Vector tv = new Vector(to.getX(), to.getY(), to.getZ());

    double bpt = blocksPerTick;
    Vector dv = new Vector(0d, 0d, 0d);
    dv.add(tv);
    dv.subtract(fv);
    Vector nv = dv.clone();
    nv.multiply(1 / dv.length() * bpt);

    if (nv.length() > dv.length())
        return;

    nv.add(fv);
    Location nl = new Location(world, nv.getX(), nv.getY(), nv.getZ());
    nl.setDirection(dv);
    ent.teleport(nl);
}
 
開發者ID:Kneesnap,項目名稱:Kineticraft,代碼行數:25,代碼來源:ActionEntityPathfind.java

示例4: run

import org.bukkit.util.Vector; //導入方法依賴的package包/類
public void run()
{
    if(Bukkit.getPlayer(uuid) == null)
        Bukkit.getScheduler().cancelTask(id);
    else
    if(Bukkit.getPlayer(uuid).isDead())
        Bukkit.getScheduler().cancelTask(id);
    else
    if(!Bukkit.getPlayer(uuid).isSneaking())
    {
        Bukkit.getScheduler().cancelTask(id);
    } else
    {
        Player p = Bukkit.getPlayer(uuid);
        float cost = 0.08F;
        float charge = ItemEnergy.getStoredEnergy(p.getInventory().getChestplate());
        if(charge >= cost)
        {
            p.getInventory().setChestplate(ItemEnergy.chargeItem(p.getInventory().getChestplate(), -cost));
            me.mrCookieSlime.CSCoreLibPlugin.general.Player.PlayerInventory.update(p);
            p.getWorld().playSound(p.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 0.25F, 1.0F);
            p.getWorld().playEffect(p.getLocation(), Effect.SMOKE, 1, 1);
            p.setFallDistance(0.0F);
            Vector vector = new Vector(0, 1, 0);
            vector.multiply(thrust);
            vector.add(p.getEyeLocation().getDirection().multiply(0.2F));
            p.setVelocity(vector);
        } else
        {
            Bukkit.getScheduler().cancelTask(id);
        }
    }
}
 
開發者ID:StarWishsama,項目名稱:Slimefun4-Chinese-Version,代碼行數:34,代碼來源:JetpackTask.java

示例5: tickForce

import org.bukkit.util.Vector; //導入方法依賴的package包/類
@Repeatable(scope = MatchScope.LOADED)
public void tickForce() {
    final Vector acceleration = new Vector();
    for(PlayerForce force : forces) {
        acceleration.add(force.acceleration(matchPlayer));
    }
    if(acceleration.lengthSquared() > MIN_FORCE) {
        player.applyImpulse(acceleration);
    }
}
 
開發者ID:OvercastNetwork,項目名稱:ProjectAres,代碼行數:11,代碼來源:AccelerationPlayerFacet.java

示例6: movePlayer

import org.bukkit.util.Vector; //導入方法依賴的package包/類
public void movePlayer(Entity p, int dx, int dy, int dz) {
	NavyCraft.instance.DebugMessage("Moving player", 4);
	int mccraftspeed = craft.speed;
	if (mccraftspeed > 2) {
		mccraftspeed = 2;
	}

	Vector pVel = p.getVelocity();

	if (dx > 0) {
		dx = craft.speed;
	} else {
		dx = craft.speed * -1;
	}
	if (dy > 0) {
		dy = craft.speed;
	} else {
		dy = craft.speed * -1;
	}
	if (dz > 0) {
		dz = craft.speed;
	} else {
		dz = craft.speed * -1;
	}
	pVel = pVel.add(new Vector(dx, dy, dz));


	if ((pVel.getX() > 10) || (pVel.getZ() > 10) || (pVel.getY() > 10)) {

		System.out.println("Velocity is too high, have to teleport " + p.getEntityId());
		Location pLoc = p.getLocation();
		pLoc.setX(pLoc.getX() + pVel.getX());
		pLoc.setY(pLoc.getY() + pVel.getY() + .05);
		pLoc.setZ(pLoc.getZ() + pVel.getZ());
		p.teleport(pLoc);
	} else {
		p.setVelocity(pVel);
	}
}
 
開發者ID:Maximuspayne,項目名稱:NavyCraft2-Lite,代碼行數:40,代碼來源:CraftMover.java

示例7: run

import org.bukkit.util.Vector; //導入方法依賴的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.util.Vector.add方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。