本文整理匯總了Java中net.minecraft.entity.EntityLivingBase.getHealth方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLivingBase.getHealth方法的具體用法?Java EntityLivingBase.getHealth怎麽用?Java EntityLivingBase.getHealth使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getHealth方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: hurtCameraEffect
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
private void hurtCameraEffect(float partialTicks)
{
if (this.mc.getRenderViewEntity() instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)this.mc.getRenderViewEntity();
float f = (float)entitylivingbase.hurtTime - partialTicks;
if (entitylivingbase.getHealth() <= 0.0F)
{
float f1 = (float)entitylivingbase.deathTime + partialTicks;
GlStateManager.rotate(40.0F - 8000.0F / (f1 + 200.0F), 0.0F, 0.0F, 1.0F);
}
if (f < 0.0F)
{
return;
}
f = f / (float)entitylivingbase.maxHurtTime;
f = MathHelper.sin(f * f * f * f * (float)Math.PI);
float f2 = entitylivingbase.attackedAtYaw;
GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-f * 14.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(f2, 0.0F, 1.0F, 0.0F);
}
}
示例2: calculateTargetingWeight
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
private double calculateTargetingWeight(EntityLivingBase entityLivingBase) {
Vec3 eyePosition = getEntityPositionVector(mc.thePlayer).up(mc.thePlayer.getEyeHeight());
Rotation currentAngles = new Rotation(mc.thePlayer.rotationYaw, mc.thePlayer.rotationPitch);
double weight = 0;
switch (targetingType.getValue()) {
case FOV:
Rotation targetAngles = ProjectionUtilities.faceOffsetDeg(getEntityPositionVector(entityLivingBase).up(entityLivingBase.getEyeHeight()).subtract(eyePosition));
Rotation delta = targetAngles.subtract(currentAngles).wrapDegrees();
weight = 180 / delta.length();
break;
case RANGE:
weight = 64 / mc.thePlayer.getDistanceSqToEntity(entityLivingBase);
break;
case HEALTH:
weight = entityLivingBase.getHealth() + entityLivingBase.getAbsorptionAmount();
break;
}
weight -= Math.min((idToLastHitMap.getOrDefault(entityLivingBase.getEntityId(), 0) - mc.thePlayer.ticksExisted), 25);
return weight;
}
示例3: cast
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@SuppressWarnings("ConstantConditions")
@Override
public void cast(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
final EntityLivingBase entity = (EntityLivingBase) sender.getCommandSenderEntity();
if (entity.isEntityAlive() && entity.getHealth() < entity.getMaxHealth()) {
entity.addPotionEffect(new PotionEffect(MobEffects.REGENERATION, 80, 0));
}
}
示例4: performEffect
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@Override
public void performEffect(EntityLivingBase entity, int amplifier){
if(TrustCircle.baseRegen > 0){
if(entity.getHealth() < entity.getMaxHealth()){
entity.heal(TrustCircle.baseRegen);
}
}
}
示例5: hurtCameraEffect
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
private void hurtCameraEffect(float partialTicks)
{
if (!Hacks.findMod(NoHurtCam.class).isEnabled()) {
if (this.mc.getRenderViewEntity() instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)this.mc.getRenderViewEntity();
float f = (float)entitylivingbase.hurtTime - partialTicks;
if (entitylivingbase.getHealth() <= 0.0F)
{
float f1 = (float)entitylivingbase.deathTime + partialTicks;
GlStateManager.rotate(40.0F - 8000.0F / (f1 + 200.0F), 0.0F, 0.0F, 1.0F);
}
if (f < 0.0F)
{
return;
}
f = f / (float)entitylivingbase.maxHurtTime;
f = MathHelper.sin(f * f * f * f * (float)Math.PI);
float f2 = entitylivingbase.attackedAtYaw;
GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-f * 14.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(f2, 0.0F, 1.0F, 0.0F);
}
}
}
示例6: onExecutionStart
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@Override
public void onExecutionStart(EntityPlayer player)
{
ItemStack is = player.getHeldItemMainhand().isEmpty() ? player.getHeldItemOffhand() : player.getHeldItemMainhand();
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 1F);
Vec3d look = player.getLookVec().scale(5);
Vec3d pos = player.getPositionVector();
List<EntityLivingBase> targets = Helpers.rayTraceEntities(player.world, pos.addVector(0, player.getEyeHeight(), 0), look, Optional.of(e -> e != player), EntityLivingBase.class);
EntityLivingBase assumedToBeLookedAt = Helpers.getClosest(targets, player);
if (assumedToBeLookedAt != null)
{
if (!player.world.isRemote)
{
is.damageItem(1, player);
}
assumedToBeLookedAt.attackEntityFrom(DamageSource.causePlayerDamage(player), (float) player.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE).getAttributeValue());
player.world.playSound(player, player.getPosition(), SoundEvents.ENTITY_PLAYER_ATTACK_NODAMAGE, SoundCategory.PLAYERS, 1, 0.1F);
Vec3d targetPos = assumedToBeLookedAt.getPositionVector();
player.world.spawnParticle(EnumParticleTypes.SWEEP_ATTACK, targetPos.x, targetPos.y + assumedToBeLookedAt.getEyeHeight(), targetPos.z, 0, 0, 0);
float chance = (1 - assumedToBeLookedAt.getHealth() / assumedToBeLookedAt.getMaxHealth());
if (!player.world.isRemote && player.world.rand.nextFloat() < chance / 10)
{
assumedToBeLookedAt.hurtResistantTime = assumedToBeLookedAt.hurtTime = 0;
assumedToBeLookedAt.attackEntityFrom(DamageSource.causePlayerDamage(player), Float.MAX_VALUE);
}
}
}
示例7: 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());
}
}
示例8: 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());
}
}
示例9: attackEntityWithRangedAttack
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
if (!this.getAggressive())
{
EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732);
double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
entitypotion.rotationPitch -= -20.0F;
double d1 = p_82196_1_.posX + p_82196_1_.motionX - this.posX;
double d2 = d0 - this.posY;
double d3 = p_82196_1_.posZ + p_82196_1_.motionZ - this.posZ;
float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);
if (f >= 8.0F && !p_82196_1_.isPotionActive(Potion.moveSlowdown))
{
entitypotion.setPotionDamage(32698);
}
else if (p_82196_1_.getHealth() >= 8.0F && !p_82196_1_.isPotionActive(Potion.poison))
{
entitypotion.setPotionDamage(32660);
}
else if (f <= 3.0F && !p_82196_1_.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F)
{
entitypotion.setPotionDamage(32696);
}
entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
this.worldObj.spawnEntityInWorld(entitypotion);
}
}
示例10: getHealthBasedBonus
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public float getHealthBasedBonus(ItemStack item, EntityLivingBase living, float maxbonus) {
if(living != null && living.getHealth()<living.getMaxHealth()*0.8f) {
float multiplier=1f -((living.getHealth()/(living.getMaxHealth()*0.8f)));
return TF2Util.lerp(1, maxbonus, multiplier);
}
return 1f;
}
示例11: hurtCameraEffect
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
private void hurtCameraEffect(float partialTicks) {
if (this.mc.getRenderViewEntity() instanceof EntityLivingBase) {
EventHurtCam e = new EventHurtCam();
e.call();
if (e.isCancelled())
return;
EntityLivingBase entitylivingbase = (EntityLivingBase) this.mc.getRenderViewEntity();
float f = (float) entitylivingbase.hurtTime - partialTicks;
if (entitylivingbase.getHealth() <= 0.0F) {
float f1 = (float) entitylivingbase.deathTime + partialTicks;
GlStateManager.rotate(40.0F - 8000.0F / (f1 + 200.0F), 0.0F, 0.0F, 1.0F);
}
if (f < 0.0F) {
return;
}
f = f / (float) entitylivingbase.maxHurtTime;
f = MathHelper.sin(f * f * f * f * (float) Math.PI);
float f2 = entitylivingbase.attackedAtYaw;
GlStateManager.rotate(-f2, 0.0F, 1.0F, 0.0F);
GlStateManager.rotate(-f * 14.0F, 0.0F, 0.0F, 1.0F);
GlStateManager.rotate(f2, 0.0F, 1.0F, 0.0F);
}
}
示例12: performEffect
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public void performEffect(EntityLivingBase entityLivingBaseIn, int p_76394_2_)
{
if (this.id == regeneration.id)
{
if (entityLivingBaseIn.getHealth() < entityLivingBaseIn.getMaxHealth())
{
entityLivingBaseIn.heal(1.0F);
}
}
else if (this.id == poison.id)
{
if (entityLivingBaseIn.getHealth() > 1.0F)
{
entityLivingBaseIn.attackEntityFrom(DamageSource.magic, 1.0F);
}
}
else if (this.id == wither.id)
{
entityLivingBaseIn.attackEntityFrom(DamageSource.wither, 1.0F);
}
else if (this.id == hunger.id && entityLivingBaseIn instanceof EntityPlayer)
{
((EntityPlayer)entityLivingBaseIn).addExhaustion(0.025F * (float)(p_76394_2_ + 1));
}
else if (this.id == saturation.id && entityLivingBaseIn instanceof EntityPlayer)
{
if (!entityLivingBaseIn.worldObj.isRemote)
{
((EntityPlayer)entityLivingBaseIn).getFoodStats().addStats(p_76394_2_ + 1, 1.0F);
}
}
else if ((this.id != heal.id || entityLivingBaseIn.isEntityUndead()) && (this.id != harm.id || !entityLivingBaseIn.isEntityUndead()))
{
if (this.id == harm.id && !entityLivingBaseIn.isEntityUndead() || this.id == heal.id && entityLivingBaseIn.isEntityUndead())
{
entityLivingBaseIn.attackEntityFrom(DamageSource.magic, (float)(6 << p_76394_2_));
}
}
else
{
entityLivingBaseIn.heal((float)Math.max(4 << p_76394_2_, 0));
}
}
示例13: performEffect
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public void performEffect(EntityLivingBase entityLivingBaseIn, int p_76394_2_)
{
if (this == MobEffects.REGENERATION)
{
if (entityLivingBaseIn.getHealth() < entityLivingBaseIn.getMaxHealth())
{
entityLivingBaseIn.heal(1.0F);
}
}
else if (this == MobEffects.POISON)
{
if (entityLivingBaseIn.getHealth() > 1.0F)
{
entityLivingBaseIn.attackEntityFrom(DamageSource.magic, 1.0F);
}
}
else if (this == MobEffects.WITHER)
{
entityLivingBaseIn.attackEntityFrom(DamageSource.wither, 1.0F);
}
else if (this == MobEffects.HUNGER && entityLivingBaseIn instanceof EntityPlayer)
{
((EntityPlayer)entityLivingBaseIn).addExhaustion(0.005F * (float)(p_76394_2_ + 1));
}
else if (this == MobEffects.SATURATION && entityLivingBaseIn instanceof EntityPlayer)
{
if (!entityLivingBaseIn.world.isRemote)
{
((EntityPlayer)entityLivingBaseIn).getFoodStats().addStats(p_76394_2_ + 1, 1.0F);
}
}
else if ((this != MobEffects.INSTANT_HEALTH || entityLivingBaseIn.isEntityUndead()) && (this != MobEffects.INSTANT_DAMAGE || !entityLivingBaseIn.isEntityUndead()))
{
if (this == MobEffects.INSTANT_DAMAGE && !entityLivingBaseIn.isEntityUndead() || this == MobEffects.INSTANT_HEALTH && entityLivingBaseIn.isEntityUndead())
{
entityLivingBaseIn.attackEntityFrom(DamageSource.magic, (float)(6 << p_76394_2_));
}
}
else
{
entityLivingBaseIn.heal((float)Math.max(4 << p_76394_2_, 0));
}
}
示例14: getHealth
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
public static float getHealth(EntityLivingBase ent) {
return ent.getHealth();
}