本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getHealth方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getHealth方法的具体用法?Java EntityPlayer.getHealth怎么用?Java EntityPlayer.getHealth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.player.EntityPlayer
的用法示例。
在下文中一共展示了EntityPlayer.getHealth方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onRenderOverlay
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onRenderOverlay(RenderGameOverlayEvent.Post event)
{
if (event.getType() != ElementType.EXPERIENCE) return;
else
{
ScaledResolution sr = event.getResolution();
EntityPlayer player = Minecraft.getMinecraft().player;
if (!player.capabilities.isCreativeMode)
{
double healthBarWidth = (double) player.getHealth() / player.getMaxHealth() * 81.0;
int xPos = sr.getScaledWidth() / 2 - 91;
int yPos = sr.getScaledHeight() - 39;
mc.renderEngine.bindTexture(location);
this.drawTexturedModalRect(xPos, yPos, 0, 0, 81, 9);
this.drawTexturedModalRect(xPos, yPos, 0, 9, (int) healthBarWidth, 8);
}
}
}
示例2: onRenderOverlayText
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent
public void onRenderOverlayText(RenderGameOverlayEvent.Text event)
{
ScaledResolution sr = event.getResolution();
EntityPlayer player = Minecraft.getMinecraft().player;
if (!player.capabilities.isCreativeMode)
{
String health = (int) player.getHealth() + " / " + (int) player.getMaxHealth();
GL11.glPushMatrix();
GL11.glScalef(0.5F, 0.5F, 0.5F);
Minecraft.getMinecraft().fontRenderer.drawStringWithShadow(health, (sr.getScaledWidth() / 2 - 60) * 2, (sr.getScaledHeight() - 36) * 2, 0xFFFFFF);
GL11.glPopMatrix();
}
}
示例3: func_96635_a
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
public int func_96635_a(List<EntityPlayer> p_96635_1_)
{
float f = 0.0F;
for (EntityPlayer entityplayer : p_96635_1_)
{
f += entityplayer.getHealth() + entityplayer.getAbsorptionAmount();
}
if (p_96635_1_.size() > 0)
{
f /= (float)p_96635_1_.size();
}
return MathHelper.ceiling_float_int(f);
}
示例4: getRedstoneValue
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public int getRedstoneValue(World world, BlockPos pos, int sensorRange, String textBoxText) {
EntityPlayer player = FMLCommonHandler.instance().getMinecraftServerInstance().getPlayerList().getPlayerByUsername(textBoxText);
if (player != null) {
return (int) (15 * player.getHealth() / player.getMaxHealth());
} else {
return 0;
}
}
示例5: okToFeed
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
private boolean okToFeed(@Nonnull ItemStack stack, EntityPlayer player) {
int foodValue = getFoodValue(stack);
int curFoodLevel = player.getFoodStats().getFoodLevel();
int tmpFeedMode = feedMode;
if (tmpFeedMode == 2) {
tmpFeedMode = player.getMaxHealth() - player.getHealth() > 0 ? 1 : 0;
}
switch (tmpFeedMode) {
case 0:
return 20 - curFoodLevel >= foodValue * stack.getCount();
case 1:
return 20 - curFoodLevel >= foodValue * (stack.getCount() - 1) + 1;
}
return false;
}
示例6: onBreakProgress
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onBreakProgress(PlayerEvent.BreakSpeed event) {
EntityPlayer player = event.getEntityPlayer();
if (player != null && player.getHealth() <= 0f) {
event.setNewSpeed(0f);
}
}
示例7: onPlayerInteract
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onPlayerInteract(PlayerInteractEvent event) {
EntityPlayer player = event.getEntityPlayer();
if (player != null && player.getHealth() <= 0f) {
if (!(event instanceof PlayerInteractEvent.RightClickEmpty || event instanceof PlayerInteractEvent.LeftClickEmpty)) {
event.setCanceled(true);
}
}
}
示例8: onAttack
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.HIGHEST)
public void onAttack(AttackEntityEvent event) {
EntityPlayer player = event.getEntityPlayer();
if (player != null && player.getHealth() <= 0f) {
// if(ModConfig.allowUnarmedMelee && player.getHeldItemMainhand().isEmpty()) {
// return;
// }
event.setCanceled(true);
}
}
示例9: onUpdate
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Handles the food game logic.
*/
public void onUpdate(EntityPlayer player)
{
EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
this.prevFoodLevel = this.foodLevel;
if (this.foodExhaustionLevel > 4.0F)
{
this.foodExhaustionLevel -= 4.0F;
if (this.foodSaturationLevel > 0.0F)
{
this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
}
else if (enumdifficulty != EnumDifficulty.PEACEFUL)
{
this.foodLevel = Math.max(this.foodLevel - 1, 0);
}
}
if (player.worldObj.getGameRules().getBoolean("naturalRegeneration") && this.foodLevel >= 18 && player.shouldHeal())
{
++this.foodTimer;
if (this.foodTimer >= 80)
{
player.heal(1.0F);
this.addExhaustion(3.0F);
this.foodTimer = 0;
}
}
else if (this.foodLevel <= 0)
{
++this.foodTimer;
if (this.foodTimer >= 80)
{
if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
{
player.attackEntityFrom(DamageSource.starve, 1.0F);
}
this.foodTimer = 0;
}
}
else
{
this.foodTimer = 0;
}
}
示例10: onUpdate
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Handles the food game logic.
*/
public void onUpdate(EntityPlayer player)
{
EnumDifficulty enumdifficulty = player.world.getDifficulty();
this.prevFoodLevel = this.foodLevel;
if (this.foodExhaustionLevel > 4.0F)
{
this.foodExhaustionLevel -= 4.0F;
if (this.foodSaturationLevel > 0.0F)
{
this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
}
else if (enumdifficulty != EnumDifficulty.PEACEFUL)
{
this.foodLevel = Math.max(this.foodLevel - 1, 0);
}
}
boolean flag = player.world.getGameRules().getBoolean("naturalRegeneration");
if (flag && this.foodSaturationLevel > 0.0F && player.shouldHeal() && this.foodLevel >= 20)
{
++this.foodTimer;
if (this.foodTimer >= 10)
{
float f = Math.min(this.foodSaturationLevel, 6.0F);
player.heal(f / 6.0F);
this.addExhaustion(f);
this.foodTimer = 0;
}
}
else if (flag && this.foodLevel >= 18 && player.shouldHeal())
{
++this.foodTimer;
if (this.foodTimer >= 80)
{
player.heal(1.0F);
this.addExhaustion(6.0F);
this.foodTimer = 0;
}
}
else if (this.foodLevel <= 0)
{
++this.foodTimer;
if (this.foodTimer >= 80)
{
if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
{
player.attackEntityFrom(DamageSource.starve, 1.0F);
}
this.foodTimer = 0;
}
}
else
{
this.foodTimer = 0;
}
}
示例11: onUpdate
import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
/**
* Handles the food game logic.
*/
public void onUpdate(EntityPlayer player)
{
EnumDifficulty enumdifficulty = player.worldObj.getDifficulty();
this.prevFoodLevel = this.foodLevel;
if (this.foodExhaustionLevel > 4.0F)
{
this.foodExhaustionLevel -= 4.0F;
if (this.foodSaturationLevel > 0.0F)
{
this.foodSaturationLevel = Math.max(this.foodSaturationLevel - 1.0F, 0.0F);
}
else if (enumdifficulty != EnumDifficulty.PEACEFUL)
{
this.foodLevel = Math.max(this.foodLevel - 1, 0);
}
}
boolean flag = player.worldObj.getGameRules().getBoolean("naturalRegeneration");
if (flag && this.foodSaturationLevel > 0.0F && player.shouldHeal() && this.foodLevel >= 20)
{
++this.foodTimer;
if (this.foodTimer >= 10)
{
float f = Math.min(this.foodSaturationLevel, 4.0F);
player.heal(f / 4.0F);
this.addExhaustion(f);
this.foodTimer = 0;
}
}
else if (flag && this.foodLevel >= 18 && player.shouldHeal())
{
++this.foodTimer;
if (this.foodTimer >= 80)
{
player.heal(1.0F);
this.addExhaustion(4.0F);
this.foodTimer = 0;
}
}
else if (this.foodLevel <= 0)
{
++this.foodTimer;
if (this.foodTimer >= 80)
{
if (player.getHealth() > 10.0F || enumdifficulty == EnumDifficulty.HARD || player.getHealth() > 1.0F && enumdifficulty == EnumDifficulty.NORMAL)
{
player.attackEntityFrom(DamageSource.starve, 1.0F);
}
this.foodTimer = 0;
}
}
else
{
this.foodTimer = 0;
}
}