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


Java EntityLivingBase.setHealth方法代码示例

本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.setHealth方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.setHealth方法的具体用法?Java EntityLivingBase.setHealth怎么用?Java EntityLivingBase.setHealth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.EntityLivingBase的用法示例。


在下文中一共展示了EntityLivingBase.setHealth方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAttributeModifiers

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void setAttributeModifiers(EntityLivingBase entity, int level)
{
	AttributeModifier attackDamage = new AttributeModifier(ATTACK_DAMAGE, "attackDamage", level * 0.1, 1);
	AttributeModifier maxHealth = new AttributeModifier(MAX_HEALTH, "maxHealth", level * 0.2, 1);
	
	if (!entity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).hasModifier(attackDamage))
		entity.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).applyModifier(attackDamage);
	
	if (!entity.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).hasModifier(maxHealth))
	{
		entity.getEntityAttribute(SharedMonsterAttributes.MAX_HEALTH).applyModifier(maxHealth);
		entity.setHealth(entity.getMaxHealth());
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:15,代码来源:EventEntityJoinWorld.java

示例2: removeAttributesModifiersFromEntity

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111187_2_, int amplifier)
{
    super.removeAttributesModifiersFromEntity(entityLivingBaseIn, p_111187_2_, amplifier);

    if (entityLivingBaseIn.getHealth() > entityLivingBaseIn.getMaxHealth())
    {
        entityLivingBaseIn.setHealth(entityLivingBaseIn.getMaxHealth());
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:10,代码来源:PotionHealthBoost.java

示例3: removeAttributesModifiersFromEntity

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void removeAttributesModifiersFromEntity(EntityLivingBase entityLivingBaseIn, AbstractAttributeMap attributeMapIn, int amplifier)
{
    super.removeAttributesModifiersFromEntity(entityLivingBaseIn, attributeMapIn, amplifier);

    if (entityLivingBaseIn.getHealth() > entityLivingBaseIn.getMaxHealth())
    {
        entityLivingBaseIn.setHealth(entityLivingBaseIn.getMaxHealth());
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:10,代码来源:PotionHealthBoost.java

示例4: holster

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public void holster(WeaponsCapability cap, ItemStack stack, EntityLivingBase living, World world) {
	super.holster(cap, stack, living, world);
	cap.focusShotRemaining=0;
	cap.focusShotTicks=0;
	cap.setCharging(false);
	float removeHealth=0;
	for (Entry<String, AttributeModifier> entry : stack.getAttributeModifiers(EntityEquipmentSlot.MAINHAND).entries())
       {
		if(entry.getValue().getID()==HEALTH_MODIFIER)
			removeHealth+=entry.getValue().getAmount();
           //IAttributeInstance iattributeinstance = livinggetAttributeInstanceByName((String)entry.getKey());
       }
	if(removeHealth != 0)
		living.setHealth((living.getMaxHealth()/(removeHealth+living.getMaxHealth())*living.getHealth()));
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:16,代码来源:ItemWeapon.java

示例5: onUpdate

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public void onUpdate(ItemStack stack, World par2World, Entity par3Entity, int par4, boolean par5) {
	super.onUpdate(stack, par2World, par3Entity, par4, par5);
	if(stack.isEmpty())
		return;
	/*
	 * if(itemProperties.get(par2World.isRemote).get(par3Entity)==null){
	 * itemProperties.get(par2World.isRemote).put((EntityLivingBase)
	 * par3Entity, new NBTTagCompound()); }
	 */
	WeaponsCapability cap = par3Entity.getCapability(TF2weapons.WEAPONS_CAP, null);
	WeaponData.WeaponDataCapability stackcap = stack.getCapability(TF2weapons.WEAPONS_DATA_CAP, null);
	EntityLivingBase living=(EntityLivingBase) par3Entity;
	if (stackcap.active == 0 && par5) {
		stackcap.active = 1;
		// itemProperties.get(par2World.isRemote).get(par3Entity).setShort("reloadd",
		// (short) 800);

		if(!par2World.isRemote && living.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).getModifier(ItemWeapon.HEALTH_MODIFIER)!=null){
			float addHealth=(float) living.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.MAX_HEALTH).getModifier(ItemWeapon.HEALTH_MODIFIER).getAmount();
			living.setHealth((living.getMaxHealth())/(living.getMaxHealth()-addHealth)*living.getHealth());
		}
		cap.fire1Cool = this.getDeployTime(stack, living);
		cap.fire2Cool = this.getDeployTime(stack, living);
	} else if (stackcap.active > 0
			&& stack != living.getHeldItemOffhand() && !par5) {
		if (stackcap.active == 2 && (cap.state & 3) > 0)
			this.endUse(stack, living, par2World, cap.state, 0);
		
		stackcap.active = 0;
		this.holster(cap, stack, living, par2World);

	}
	if (par3Entity.ticksExisted % 5 == 0 && stackcap.active == 2
			&& TF2Attribute.getModifier("Mark Death", stack, 0, living) > 0)
		living.addPotionEffect(new PotionEffect(TF2weapons.markDeath,
				(int) TF2Attribute.getModifier("Mark Death", stack, 0,living) * 20));
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:39,代码来源:ItemUsable.java

示例6: setHealth

import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void setHealth(EntityLivingBase ent, float val) {
    ent.setHealth(val);
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:4,代码来源:ZWrapper.java


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