本文整理汇总了Java中org.bukkit.entity.LivingEntity.teleport方法的典型用法代码示例。如果您正苦于以下问题:Java LivingEntity.teleport方法的具体用法?Java LivingEntity.teleport怎么用?Java LivingEntity.teleport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.LivingEntity
的用法示例。
在下文中一共展示了LivingEntity.teleport方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: knockback
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
/**
* Based on shooting the gun, jerks the player's head to the direction of firing
*
* @param entity the entity shooting
* @param direction the direction of shot
*/
public void knockback(LivingEntity entity, Vector direction) {
if (entity instanceof Player) {
Player p = (Player) entity;
Vector begin = p.getEyeLocation().getDirection().clone();
Vector end = begin.clone().getMidpoint(direction).getMidpoint(begin); // 25% of "direction" between start and where fire occurred.
long kickback = Math.max(Math.min(this.cooldown / 3, (long) Animation.FRAME_DELAY * 3l), (long) Animation.FRAME_DELAY * 2l);
long kickdown = Math.max((long) Animation.FRAME_DELAY * 2l, this.cooldown - kickback);
AddGun.getPlugin().getPlayerListener().playAnimation(p, new Animation(p, begin, kickback, direction, kickdown, end));
} else {
entity.teleport(entity.getLocation().setDirection(direction), TeleportCause.PLUGIN);
}
}