本文整理汇总了Java中org.bukkit.entity.Entity.getPassenger方法的典型用法代码示例。如果您正苦于以下问题:Java Entity.getPassenger方法的具体用法?Java Entity.getPassenger怎么用?Java Entity.getPassenger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.Entity
的用法示例。
在下文中一共展示了Entity.getPassenger方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
示例2: onPlayerInteractEntity
import org.bukkit.entity.Entity; //导入方法依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
Player p = event.getPlayer();
Entity t = event.getRightClicked();
PetInstance pet = PetInstance.get(t);
if (pet == null)
return;
if (pet.getOwner().equalsIgnoreCase(p.getName())) {
if (t.getPassenger() != null) {
t.eject();
t.setPassenger(null);
}
else {
if (!p.isInsideVehicle())
t.setPassenger(p);
}
}
else {
Chat.player(p, "&2[Pets] &cBuy pets at www.mczone.co/shop");
}
}