本文整理汇总了Java中org.bukkit.entity.LivingEntity.getHealth方法的典型用法代码示例。如果您正苦于以下问题:Java LivingEntity.getHealth方法的具体用法?Java LivingEntity.getHealth怎么用?Java LivingEntity.getHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.bukkit.entity.LivingEntity
的用法示例。
在下文中一共展示了LivingEntity.getHealth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: defenseEffect
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@Override
public void defenseEffect(LivingEntity user, LivingEntity damager, EntityDamageByEntityEvent event){
double health = user.getHealth();
if (health == 3.0 || health == 2.5) {
event.setDamage(event.getDamage() - 0.5);
} else if (health == 2.0 || health == 1.5) {
event.setDamage(event.getDamage() - 1.0);
} else if (health == 1.0){
event.setDamage(event.getDamage() - 1.5);
} else if (health == 0.5){
event.setDamage(event.getDamage() - 2.0);
}
}
示例2: offenseEffect
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@Override
public void offenseEffect(LivingEntity user, LivingEntity target, EntityDamageByEntityEvent event){
double health = user.getHealth();
if (health == 3.0 || health == 2.5) {
event.setDamage(event.getDamage() + 0.5);
} else if (health == 2.0 || health == 1.5) {
event.setDamage(event.getDamage() + 1.0);
} else if (health == 1.0){
event.setDamage(event.getDamage() + 1.5);
} else if (health == 0.5){
event.setDamage(event.getDamage() + 2.0);
}
}
示例3: execute
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@Override
public void execute(KingdomFactionsPlayer player) {
setLocation(player.getPlayer().getTargetBlock((Set<Material>) null, 80).getLocation());
SpellExecuteEvent event = new SpellExecuteEvent(executeLocation, this, player);
if (event.isCancelled())
return;
playSmoke(executeLocation);
for (Entity e : Utils.getInstance().getNearbyEntities(executeLocation, 3)) {
if (e instanceof LivingEntity) {
LivingEntity en = (LivingEntity) e;
if (e instanceof Player) {
Player p = (Player) e;
if (PlayerModule.getInstance().getPlayer(p).isVanished())
return;
if (en.getHealth() > 5) {
en.damage(5D);
} else {
en.damage(en.getHealth());
}
}
}
}
}
示例4: onDamage
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@Override
public void onDamage() {
BossStage stage = getStages().getValueSafe(1);
LivingEntity le = getLiving();
if (stage == null || stage.getHealthPercent() * le.getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue() < le.getHealth())
return; // If there isn't a stage queued after this.
getStages().pop(); // Remove the current stage.
updateStage(); // Update stage.
}
示例5: onPetFeed
import org.bukkit.entity.LivingEntity; //导入方法依赖的package包/类
@EventHandler
public void onPetFeed(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();
ItemStack itemInHand = player.getEquipment().getItemInMainHand();
if (!InventoryManager.playerIsLoaded(player)) {
return;
}
PlayerWrapper playerWrapper = InventoryManager.get(player);
if (PetFood.isFoodItem(itemInHand) && playerWrapper.hasPet() && event.getRightClicked() == playerWrapper.getPet()) {
event.setCancelled(true);
LivingEntity pet = (LivingEntity) event.getRightClicked();
PetFood petFood = PetManager.getFoodFromItem(itemInHand);
if (pet.getHealth() == pet.getMaxHealth() || petFood == null || !petFood.canBeEaten(playerWrapper.getPet())) {
return;
}
double health = pet.getHealth() + petFood.getValue();
pet.setHealth(health < pet.getMaxHealth() ? health : pet.getMaxHealth());
itemInHand.setAmount(itemInHand.getAmount() - 1);
player.getEquipment().setItemInMainHand(itemInHand);
pet.getWorld().playSound(pet.getLocation(), Sound.ENTITY_GENERIC_EAT, 1.0f, (float) (1.0 + Math.random() * 0.4));
}
}