Java Code Examples for net.minecraft.entity.player.EntityPlayer#getMaxHealth()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#getMaxHealth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UpgradeFeeding.java From BetterChests with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void update(IUpgradableBlock chest, ItemStack stack) { if (UpgradeHelper.INSTANCE.getFrequencyTick(chest, stack, 100) != 0) { return; } Entity e = ((IMobileUpgradableBlock)chest).getEntity(); if (e instanceof EntityPlayer && hasUpgradeOperationCost(chest)) { EntityPlayer player = (EntityPlayer) e; if (!player.getFoodStats().needFood()) { return; } IBetterChest inv = (IBetterChest) chest; int idx = InvUtil.findInInvInternal(inv, null, test -> test.getItem() instanceof ItemFood); if (idx != -1) { ItemStack food = inv.getStackInSlot(idx); if (20 - player.getFoodStats().getFoodLevel() >= ((ItemFood)food.getItem()).getHealAmount(food) || player.getFoodStats().getFoodLevel() <= 17 && player.getHealth() <= player.getMaxHealth() - 1.0F || player.getFoodStats().getFoodLevel() <= 6) { inv.setInventorySlotContents(idx, ((ItemFood)food.getItem()).onItemUseFinish(food, chest.getWorldObj(), player)); drawUpgradeOperationCode(chest); inv.markDirty(); } } } }
Example 2
Source File: PlayerHealthSensor.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public int getRedstoneValue(World world, int x, int y, int z, int sensorRange, String textBoxText){ EntityPlayer player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(textBoxText); if(player != null) { return (int)(15 * player.getHealth() / player.getMaxHealth()); } else { return 0; } }
Example 3
Source File: TileEntityAerialInterface.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
@Override public boolean canInsertItem(int i, ItemStack itemstack, int j){ if(i < 4) return true; EntityPlayer player = getPlayer(); if(player == null) return false; if(getPressure(ForgeDirection.UNKNOWN) > PneumaticValues.MIN_PRESSURE_AERIAL_INTERFACE) { if(!dispenserUpgradeInserted || i >= 40 && i <= 43) { return i < 40 || itemstack != null && itemstack.getItem() instanceof ItemArmor && ((ItemArmor)itemstack.getItem()).armorType == 43 - i; } else { if(i == 4 + player.inventory.getSizeInventory() && getFoodValue(itemstack) > 0) { int foodValue = getFoodValue(itemstack); int curFoodLevel = player.getFoodStats().getFoodLevel(); int feedMode = this.feedMode; if(feedMode == 2) { feedMode = player.getMaxHealth() - player.getHealth() > 0 ? 1 : 0; } switch(feedMode){ case 0: return 20 - curFoodLevel >= foodValue * itemstack.stackSize; case 1: return 20 - curFoodLevel >= foodValue * (itemstack.stackSize - 1) + 1; } } return false; } } else { return false; } }
Example 4
Source File: ArtifactTickHandler.java From Artifacts with MIT License | 5 votes |
private void updateHealthBoost(int artifactHealthBoostCount, EntityPlayer player) { NBTTagCompound playerData = player.getEntityData(); int oldHealthBoostCount = playerData.getInteger("artifactHealthBoostCount"); if(oldHealthBoostCount != artifactHealthBoostCount) { String uu = playerData.getString("artifactHealthBoostUUID"); UUID healthID; if(uu.equals("")) { healthID = UUID.randomUUID(); playerData.setString("artifactHealthBoostUUID", healthID.toString()); } else { healthID = UUID.fromString(uu); } IAttributeInstance atinst = player.getEntityAttribute(SharedMonsterAttributes.maxHealth); atinst.removeModifier(new AttributeModifier(healthID, "HealthBoostComponent", 5F * oldHealthBoostCount, 0)); atinst.applyModifier(new AttributeModifier(healthID, "HealthBoostComponent", 5F * artifactHealthBoostCount, 0)); if(player.getHealth() > player.getMaxHealth()) { player.setHealth(player.getMaxHealth()); } int diff = (artifactHealthBoostCount - oldHealthBoostCount); if(diff > 0 && player.getHealth() < player.getMaxHealth()) { player.heal(5*diff); } playerData.setInteger("artifactHealthBoostCount", artifactHealthBoostCount); } }