本文整理汇总了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());
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}