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


Java EntityLivingBase.getHealth方法代码示例

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

示例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;
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:25,代码来源:KillAura.java

示例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));
	}
}
 
开发者ID:Um-Mitternacht,项目名称:Bewitchment,代码行数:9,代码来源:IncantationHeal.java

示例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);
        }
    }
}
 
开发者ID:Ellpeck,项目名称:TrustCircle,代码行数:9,代码来源:PotionTrust.java

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

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

示例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());
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:10,代码来源:PotionHealthBoost.java

示例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());
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:10,代码来源:PotionHealthBoost.java

示例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);
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:33,代码来源:EntityWitch.java

示例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;
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:8,代码来源:ItemUsable.java

示例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);
		}
	}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:28,代码来源:EntityRenderer.java

示例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));
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:44,代码来源:Potion.java

示例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));
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:44,代码来源:Potion.java

示例14: getHealth

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


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