本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getMaxHealth方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getMaxHealth方法的具体用法?Java EntityLivingBase.getMaxHealth怎么用?Java EntityLivingBase.getMaxHealth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getMaxHealth方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
}
}
示例2: 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);
}
}
}
示例3: draw
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public double draw(SurfaceBuilder builder, EntityLivingBase living, double topX, double topY, double botX, double botY, double width, double height) {
float hp = MathHelper.clamp(living.getHealth(), 0, living.getMaxHealth()) / living.getMaxHealth();
double x = topX - (HEALTHBAR_WIDTH / 2);
double y = topY - HEALTHBAR_HEIGHT - 2;
int color = (living.getHealth() + living.getAbsorptionAmount() > living.getMaxHealth()) ? Utils.Colors.YELLOW
: Utils.toRGBA((int) ((255 - hp) * 255), (int) (255 * hp), 0, 255); // if above 20 hp bar is yellow
builder.reset() // clean up from previous uses
.push()
.task(SurfaceBuilder::enableBlend)
.task(SurfaceBuilder::disableTexture2D)
.beginQuads()
.color(Utils.Colors.BLACK)
.rectangle(x, y, HEALTHBAR_WIDTH, HEALTHBAR_HEIGHT)
.end()
.reset()
.beginQuads()
.color(color)
.rectangle(x + 1.D, y + 1.D, ((double)HEALTHBAR_WIDTH - 2.D) * hp, HEALTHBAR_HEIGHT - 2.D)
.end()
.task(SurfaceBuilder::disableBlend)
.task(SurfaceBuilder::enableTexture2D)
.pop();
return HEALTHBAR_HEIGHT + 1.D;
}
示例4: 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());
}
}
示例5: 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());
}
}
示例6: 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;
}
示例7: 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.025F * (float)(p_76394_2_ + 1));
}
else if (this == MobEffects.SATURATION && entityLivingBaseIn instanceof EntityPlayer)
{
if (!entityLivingBaseIn.worldObj.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));
}
}
示例8: 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));
}
}
示例9: getMaxHealth
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public static float getMaxHealth(EntityLivingBase ent) {
return ent.getMaxHealth();
}
示例10: renderMountHealth
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
private void renderMountHealth(ScaledResolution p_184047_1_)
{
if (this.mc.getRenderViewEntity() instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity();
Entity entity = entityplayer.getRidingEntity();
if (entity instanceof EntityLivingBase)
{
this.mc.mcProfiler.endStartSection("mountHealth");
EntityLivingBase entitylivingbase = (EntityLivingBase)entity;
int i = (int)Math.ceil((double)entitylivingbase.getHealth());
float f = entitylivingbase.getMaxHealth();
int j = (int)(f + 0.5F) / 2;
if (j > 30)
{
j = 30;
}
int k = p_184047_1_.getScaledHeight() - 39;
int l = p_184047_1_.getScaledWidth() / 2 + 91;
int i1 = k;
int j1 = 0;
for (boolean flag = false; j > 0; j1 += 20)
{
int k1 = Math.min(j, 10);
j -= k1;
for (int l1 = 0; l1 < k1; ++l1)
{
int i2 = 52;
int j2 = 0;
int k2 = l - l1 * 8 - 9;
this.drawTexturedModalRect(k2, i1, 52 + j2 * 9, 9, 9, 9);
if (l1 * 2 + 1 + j1 < i)
{
this.drawTexturedModalRect(k2, i1, 88, 9, 9, 9);
}
if (l1 * 2 + 1 + j1 == i)
{
this.drawTexturedModalRect(k2, i1, 97, 9, 9, 9);
}
}
i1 -= 10;
}
}
}
}
示例11: 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));
}
}
示例12: isValidTarget
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public boolean isValidTarget(EntityLivingBase target) {
return !((target instanceof EntityMedic && target.getHealth() >= target.getMaxHealth()) || target instanceof EntityBuilding)
&& TF2Util.isOnSameTeam(EntityMedic.this, target);
}
示例13: renderHealthMount
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
protected void renderHealthMount(int width, int height)
{
EntityPlayer player = (EntityPlayer)mc.getRenderViewEntity();
Entity tmp = player.getRidingEntity();
if (!(tmp instanceof EntityLivingBase)) return;
bind(ICONS);
if (pre(HEALTHMOUNT)) return;
boolean unused = false;
int left_align = width / 2 + 91;
mc.mcProfiler.endStartSection("mountHealth");
GlStateManager.enableBlend();
EntityLivingBase mount = (EntityLivingBase)tmp;
int health = (int)Math.ceil((double)mount.getHealth());
float healthMax = mount.getMaxHealth();
int hearts = (int)(healthMax + 0.5F) / 2;
if (hearts > 30) hearts = 30;
final int MARGIN = 52;
final int BACKGROUND = MARGIN + (unused ? 1 : 0);
final int HALF = MARGIN + 45;
final int FULL = MARGIN + 36;
for (int heart = 0; hearts > 0; heart += 20)
{
int top = height - right_height;
int rowCount = Math.min(hearts, 10);
hearts -= rowCount;
for (int i = 0; i < rowCount; ++i)
{
int x = left_align - i * 8 - 9;
drawTexturedModalRect(x, top, BACKGROUND, 9, 9, 9);
if (i * 2 + 1 + heart < health)
drawTexturedModalRect(x, top, FULL, 9, 9, 9);
else if (i * 2 + 1 + heart == health)
drawTexturedModalRect(x, top, HALF, 9, 9, 9);
}
right_height += 10;
}
GlStateManager.disableBlend();
post(HEALTHMOUNT);
}
示例14: renderMountHealth
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
protected void renderMountHealth(ScaledResolution p_184047_1_)
{
if (this.mc.getRenderViewEntity() instanceof EntityPlayer)
{
EntityPlayer entityplayer = (EntityPlayer)this.mc.getRenderViewEntity();
Entity entity = entityplayer.getRidingEntity();
if (entity instanceof EntityLivingBase)
{
this.mc.mcProfiler.endStartSection("mountHealth");
EntityLivingBase entitylivingbase = (EntityLivingBase)entity;
int i = (int)Math.ceil((double)entitylivingbase.getHealth());
float f = entitylivingbase.getMaxHealth();
int j = (int)(f + 0.5F) / 2;
if (j > 30)
{
j = 30;
}
int k = p_184047_1_.getScaledHeight() - 39;
int l = p_184047_1_.getScaledWidth() / 2 + 91;
int i1 = k;
int j1 = 0;
for (boolean flag = false; j > 0; j1 += 20)
{
int k1 = Math.min(j, 10);
j -= k1;
for (int l1 = 0; l1 < k1; ++l1)
{
int i2 = 52;
int j2 = 0;
int k2 = l - l1 * 8 - 9;
this.drawTexturedModalRect(k2, i1, 52 + j2 * 9, 9, 9, 9);
if (l1 * 2 + 1 + j1 < i)
{
this.drawTexturedModalRect(k2, i1, 88, 9, 9, 9);
}
if (l1 * 2 + 1 + j1 == i)
{
this.drawTexturedModalRect(k2, i1, 97, 9, 9, 9);
}
}
i1 -= 10;
}
}
}
}