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