本文整理汇总了Java中org.bukkit.entity.Entity.teleport方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.teleport方法的具体用法?Java Entity.teleport怎么用?Java Entity.teleport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.teleport方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onPlayerMove
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerMove(final PlayerMoveEvent event) {
final Location from = event.getFrom();
final Location to = event.getTo();
if (from.getBlockX() == to.getBlockX() && from.getBlockZ() == to.getBlockZ()) {
return;
}
if (!isWithinBorder(to) && isWithinBorder(from)) {
final Player player = event.getPlayer();
player.sendMessage(ChatColor.RED + "You cannot go past the border.");
event.setTo(from);
final Entity vehicle = player.getVehicle();
if (vehicle != null) {
vehicle.eject();
vehicle.teleport(from);
vehicle.setPassenger((Entity)player);
}
}
}
示例2: pullEntityToLocation
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void pullEntityToLocation(Entity e, Location loc) {
Location entityLoc = e.getLocation();
entityLoc.setY(entityLoc.getY() + 0.5D);
e.teleport(entityLoc);
double g = -0.08D;
if (loc.getWorld() != entityLoc.getWorld())
return;
double d = loc.distance(entityLoc);
double t = d;
double v_x = (1.0D + 0.07000000000000001D * t) * (loc.getX() - entityLoc.getX()) / t;
double v_y = (1.0D + 0.03D * t) * (loc.getY() - entityLoc.getY()) / t - 0.5D * g * t;
double v_z = (1.0D + 0.07000000000000001D * t) * (loc.getZ() - entityLoc.getZ()) / t;
Vector v = e.getVelocity();
v.setX(v_x);
v.setY(v_y);
v.setZ(v_z);
e.setVelocity(v);
e.setFallDistance(0f);
}
示例3: execute
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
protected void execute(Event e) {
Entity ent = entity.getSingle(e);
Location to = towards.getSingle(e);
if (ent == null || to == null) {
return;
}
Vector velocity = ent.getVelocity();
float fallDistance = ent.getFallDistance();
Location from = ent.getLocation();
Vector direction = isToward ? MathUtils.vectorFromLocations(from, to) : MathUtils.vectorFromLocations(to, from);
ent.teleport(new Location(
ent.getWorld(),
from.getX(),
from.getY(),
from.getZ(),
MathUtils.notchYaw(MathUtils.getYaw(direction)),
MathUtils.notchPitch(MathUtils.getPitch(direction))
));
ent.setVelocity(velocity);
ent.setFallDistance(fallDistance);
}
示例4: teleportPlayer
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void teleportPlayer(Entity p, int dx, int dy, int dz) {
NavyCraft.instance.DebugMessage("Teleporting entity " + p.getEntityId(), 4);
Location pLoc = p.getLocation();
pLoc.setWorld(craft.world);
pLoc.setX(pLoc.getX() + dx);
pLoc.setY(pLoc.getY() + dy + .05);
pLoc.setZ(pLoc.getZ() + dz);
if (p instanceof Player) {
playerTeleports.put((Player) p, pLoc);
} else {
p.teleport(pLoc);
}
}
示例5: walkToPlayer
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public static void walkToPlayer(Entity e, Player p) {
// Tamed animals already handle their own following
if (e instanceof Tameable) {
if (((Tameable) e).isTamed()) {
return;
}
}
if (e.getPassenger() instanceof Player) {
return;
}
// Moving the dragon is too buggy
if (e instanceof EnderDragon) {
return;
}
// Once this is set we can't unset it.
//((Creature)e).setTarget(p);
// If the pet is too far just teleport instead of attempt navigation
if (e.getLocation().distance(p.getLocation()) > 20) {
e.teleport(p);
} else {
Navigation n = ((CraftLivingEntity) e).getHandle().getNavigation();
n.a(p.getLocation().getX(), p.getLocation().getY(), p.getLocation().getZ(), 0.30f);
}
}
示例6: clientMoved
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
public void clientMoved(final Channel channel, final double x, final double y, final double z, final double rx, final double ry) {
if (this.entityClass == null) {
// No bukkit entity, no web-bsaed entity for other players either TODO: synthesize a placeholder entity id for web-to-web only?
return;
}
final Entity entity = this.channelId2Entity.get(channel.id());
Location location = webSocketServerThread.blockBridge.toBukkitPlayerLocation(x, y, z);
if (constrainToSandbox && !webSocketServerThread.blockBridge.withinSandboxRange(location)) {
webSocketServerThread.log(Level.FINEST, "client tried to move outside of sandbox: "+location);
return;
}
// Opposite of PlayerBridge encodeLocation - given negated radians, convert to degrees
location.setYaw((float)(-rx * 180 / Math.PI));
location.setPitch((float)(-ry * 180 / Math.PI));
// Move the surrogate entity to represent where the web player is
entity.teleport(location);
// Notify other web clients (except this one) they moved
webSocketServerThread.broadcastLineExcept(channel.id(), "P,"+entity.getEntityId()+","+webSocketServerThread.playersBridge.encodeLocation(location));
}
示例7: onPlayerDamage
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGH)
public void onPlayerDamage(EntityDamageEvent event) {
if (event.getCause() == EntityDamageEvent.DamageCause.VOID) {
Entity entity = event.getEntity();
if (entity instanceof Player) {
// Allow players to die by VOID in the END
if (entity.getWorld().getEnvironment() == World.Environment.THE_END) {
return;
}
Location destination = BukkitUtils.getHighestLocation(entity.getLocation());
if (destination == null)
return;
if (entity.teleport(destination, PlayerTeleportEvent.TeleportCause.PLUGIN)) {
event.setCancelled(true);
((Player) entity).sendMessage(ChatColor.YELLOW + "You were saved from the void.");
}
}
}
}
示例8: movePlayer
import org.bukkit.entity.Entity; //导入方法依赖的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);
}
}
示例9: applyLocation
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@Override
public void applyLocation(Entity entity) {
entity.teleport(this.toLocation());
}