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


Java EntityPlayer.getMaxHealth方法代码示例

本文整理汇总了Java中net.minecraft.entity.player.EntityPlayer.getMaxHealth方法的典型用法代码示例。如果您正苦于以下问题:Java EntityPlayer.getMaxHealth方法的具体用法?Java EntityPlayer.getMaxHealth怎么用?Java EntityPlayer.getMaxHealth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.player.EntityPlayer的用法示例。


在下文中一共展示了EntityPlayer.getMaxHealth方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);	
		}
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:23,代码来源:GuiHealth.java

示例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();
	}
}
 
开发者ID:TheXFactor117,项目名称:Loot-Slash-Conquer,代码行数:17,代码来源:GuiHealth.java

示例3: 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;
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:10,代码来源:PlayerHealthSensor.java

示例4: 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;
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:16,代码来源:TileEntityAerialInterface.java

示例5: tick

import net.minecraft.entity.player.EntityPlayer; //导入方法依赖的package包/类
@Override
public void tick(World world, EntityPlayer player) {
    if (isDead(player))
        return;

    float currentHealth = getCurrentHealth();
    if (currentHealth <= 0F) {
        FirstAid.logger.error("Got {} health left, but isn't marked as dead!", currentHealth);
        return;
    }

    if (FirstAid.playerMaxHealth != -1) {
        float newCurrentHealth = (player.getMaxHealth() * currentHealth) / FirstAid.playerMaxHealth;

        if (Float.isInfinite(newCurrentHealth)) {
            FirstAid.logger.error("Error calculating current health: Value was infinite"); //Shouldn't happen anymore, but let's be safe
        } else {
            if (newCurrentHealth != prevHealthCurrent)
                ((DataManagerWrapper) player.dataManager).set_impl(EntityPlayer.HEALTH, newCurrentHealth);
            prevHealthCurrent = newCurrentHealth;
        }
    }

    if (!this.hasTutorial)
        this.hasTutorial = PlayerDataManager.tutorialDone.contains(player.getName());

    if (FirstAid.scaleMaxHealth) { //Attempt to calculate the max health of the body parts based on the maxHealth attribute
        float globalFactor = player.getMaxHealth() / 20F;
        if (prevScaleFactor != globalFactor) {
            int reduced = 0;
            int added = 0;
            for (AbstractDamageablePart part : this) {
                int result = Math.round(part.initialMaxHealth * globalFactor);
                if (result % 2 == 1) {
                    int partMaxHealth = part.getMaxHealth();
                    if (part.currentHealth < partMaxHealth && reduced < 4) {
                        result--;
                        reduced++;
                    } else if (part.currentHealth > partMaxHealth && added < 4) {
                        result++;
                        added++;
                    } else if (reduced > added) {
                        result++;
                        added++;
                    } else {
                        result--;
                        reduced++;
                    }
                }
                part.setMaxHealth(result);
            }
        }
        prevScaleFactor = globalFactor;
    }

    if (!world.isRemote && world instanceof WorldServer && FirstAid.activeHealingConfig.sleepHealing != 0) {
        WorldServer worldServer = (WorldServer) player.world;
        if (worldServer.areAllPlayersAsleep()) { // We are going to wake up on the next tick, add health
            HealthDistribution.distributeHealth(FirstAid.activeHealingConfig.sleepHealing, player, true);
        }
    }

    forEach(part -> part.tick(world, player, morphineTicksLeft == 0));
    if (morphineTicksLeft <= 0)
        sharedDebuffs.forEach(sharedDebuff -> sharedDebuff.tick(player));
    else
        morphineTicksLeft--;
}
 
开发者ID:ichttt,项目名称:FirstAid,代码行数:69,代码来源:PlayerDamageModel.java


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