本文整理汇总了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());
}
}
示例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());
}
}
示例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());
}
}
示例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()));
}
示例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));
}
示例6: setHealth
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static void setHealth(EntityLivingBase ent, float val) {
ent.setHealth(val);
}