本文整理匯總了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");
}
}