当前位置: 首页>>代码示例>>Java>>正文


Java LivingEntity.getHealth方法代码示例

本文整理汇总了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);
    }
}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:14,代码来源:Endurance.java

示例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);
    }

}
 
开发者ID:Warvale,项目名称:Scorch,代码行数:15,代码来源:LastHope.java

示例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());
				}
			}
		}
	}

}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:28,代码来源:Spark.java

示例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.
}
 
开发者ID:Kneesnap,项目名称:Kineticraft,代码行数:10,代码来源:DungeonBoss.java

示例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));
    }
}
 
开发者ID:EndlessCodeGroup,项目名称:RPGInventory,代码行数:29,代码来源:PetListener.java


注:本文中的org.bukkit.entity.LivingEntity.getHealth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。