本文整理汇总了Java中org.bukkit.Location.setDirection方法的典型用法代码示例。如果您正苦于以下问题:Java Location.setDirection方法的具体用法?Java Location.setDirection怎么用?Java Location.setDirection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.Location
的用法示例。
在下文中一共展示了Location.setDirection方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shoot
import org.bukkit.Location; //导入方法依赖的package包/类
/**
* A basic shoot method, it _can_ be overridden but take care.
* Handles passing the bullet to its BulletType for configuration, sets shooter, velocity, etc.
*
* @param begin The location to shoot from
* @param bulletType the Bullet type of this bullet
* @param shooter the entity shooting
* @param velocity the velocity to use as base for this shooting, if any
* @param overrideVelocity if true, use the passed velocity and override anything set up by the bullet type.
* @return the new Projectile that has been unleashed.
*/
public Projectile shoot(Location begin, Bullet bulletType, ProjectileSource shooter, Vector velocity, boolean overrideVelocity) {
World world = begin.getWorld();
begin = begin.clone();
begin.setDirection(velocity);
Projectile newBullet = world.spawn(begin, bulletType.getProjectileType() );
newBullet.setCustomName(this.bulletTag);
newBullet.setBounce(false);
newBullet.setGravity(true);
newBullet.setShooter(shooter);
bulletType.configureBullet(newBullet, world, shooter, velocity);
if (overrideVelocity) {
newBullet.setVelocity(velocity);
}
return newBullet;
}
示例2: onPlayerMoveEvent
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void onPlayerMoveEvent(PlayerMoveEvent e) {
for (Entity en : e.getPlayer().getWorld().getEntities()) {
if (en.getCustomName() != null && en.getCustomName().equals(getName()) && en.getLocation().distance(e.getTo()) <= 1) {
Location l = en.getLocation();
//e.getPlayer().sendMessage(getPlayerDirection(e.getPlayer()));
if (getPlayerDirection(e.getPlayer()).equals("north")) {
l.add(-1.2, 0, 0);
}
else if (getPlayerDirection(e.getPlayer()).equals("south")) {
l.add(1.2, 0, 0);
}
else if (getPlayerDirection(e.getPlayer()).equals("east")) {
l.add(0, 0, -1.2);
}
else if (getPlayerDirection(e.getPlayer()).equals("west")) {
l.add(0, 0, 1.2);
}
else {
l = e.getPlayer().getLocation();
}
l.setDirection(e.getPlayer().getLocation().getDirection());
e.setTo(l);
}
}
}
示例3: onCommand
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public boolean onCommand(CommandSender commandSender, Command command, String cmd, String[] args) {
if (args.length == 2 && commandSender instanceof Player) {
Player p = (Player) commandSender;
int x, z;
try {
x = Integer.parseInt(args[0]);
z = Integer.parseInt(args[1]);
} catch (Exception e) {
return false;
}
if (x >= 0 && x <= 1000 && z >= 0 && z <= 1000) {
Location l = new Location(p.getWorld(), x, 120, z);
l.setDirection(p.getLocation().getDirection());
p.teleport(l);
return true;
} else {
commandSender.sendMessage("x and y should be between 0 and 1000");
return false;
}
}
return false;
}
示例4: stepLocation
import org.bukkit.Location; //导入方法依赖的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);
}
示例5: 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();
}
示例6: run
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public void run()
{
Location location = new Location(this.center.getWorld(), this.center.getX() + Math.cos(this.i) * RADIUS, this.center.getY() + 1D, this.center.getZ() + Math.sin(this.i) * RADIUS);
location.setDirection(this.center.clone().subtract(location).toVector().setY(location.getY()));
location.setPitch(0.0F);
this.camera.move(location);
this.i += 0.025D;
if (this.i > Math.PI * 2.0D)
this.i = 0.0D;
}
示例7: getLocation
import org.bukkit.Location; //导入方法依赖的package包/类
@Override
public Location getLocation(Location loc)
{
loc.setWorld(location.getWorld());
loc.setDirection(location.getDirection());
loc.setX(location.getX());
loc.setY(location.getY());
loc.setZ(location.getZ());
return loc;
}
示例8: event
import org.bukkit.Location; //导入方法依赖的package包/类
@EventHandler
public void event(PlayerMoveEvent e) {
if (!GameArea.isInside(e.getTo())) {
Location old = e.getFrom().getBlock().getLocation().add(0.5, 0, 0.5);
old.setDirection(e.getFrom().getDirection());
e.getPlayer().teleport(old);
e.getPlayer().sendMessage(ChatColor.RED + "You can't go so far!");
}
}
示例9: faceEntity
import org.bukkit.Location; //导入方法依赖的package包/类
public static Location faceEntity(Location location, Entity entity) {
Vector direction = location.toVector().subtract(entity.getLocation().toVector());
direction.multiply(-1);
location.setDirection(direction);
return location;
}