Java Code Examples for net.minecraft.entity.player.EntityPlayer#getHealth()
The following examples show how to use
net.minecraft.entity.player.EntityPlayer#getHealth() .
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: SoulNetworkHandler.java From Framez with GNU General Public License v3.0 | 5 votes |
public static void hurtPlayer(EntityPlayer user, int energySyphoned) { if (energySyphoned < 100 && energySyphoned > 0) { if (!user.capabilities.isCreativeMode) { user.setHealth((user.getHealth() - 1)); if (user.getHealth() <= 0.0005f) { user.onDeath(DamageSource.generic); } } } else if (energySyphoned >= 100) { if (!user.capabilities.isCreativeMode) { for (int i = 0; i < ((energySyphoned + 99) / 100); i++) { user.setHealth((user.getHealth() - 1)); if (user.getHealth() <= 0.0005f) { user.onDeath(DamageSource.generic); break; } } } } }
Example 2
Source File: ItemDivineOrb.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
private void hurtPlayer(EntityPlayer user, int energySyphoned) { if (energySyphoned < 100 && energySyphoned > 0) { if (!user.capabilities.isCreativeMode) { user.setHealth((user.getHealth() - 1)); if (user.getHealth() <= 0.0005f) { user.func_110142_aN().func_94547_a(new DamageSource("blooderp"), 1, 1); user.onDeath(new DamageSource("blooderp")); } } } else if (energySyphoned >= 100) { if (!user.capabilities.isCreativeMode) { for (int i = 0; i < ((energySyphoned + 99) / 100); i++) { user.setHealth((user.getHealth() - 1)); if (user.getHealth() <= 0.0005f) { user.func_110142_aN().func_94547_a(new DamageSource("blooderp"), 1, 1); user.onDeath(new DamageSource("blooderp")); break; } } } } }
Example 3
Source File: BloodStaffUpdate.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
public boolean syphonHealth(EntityPlayer player){ if(player.getHealth() > 3){ player.setHealth(player.getHealth() - 3); return true; } else if(player.getHealth() > 0){ player.func_110142_aN().func_94547_a(new DamageSource("blooderp"), 3, 3); player.setHealth(0); player.onDeath(new DamageSource("blooderp")); return true; } else return false; }
Example 4
Source File: BloodWandUpdate.java From ForbiddenMagic with Do What The F*ck You Want To Public License | 5 votes |
public boolean syphonHealth(EntityPlayer player) { if(player.getHealth() > 6) { player.setHealth(player.getHealth() - 3); return true; } else return false; }
Example 5
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 6
Source File: SoulNetworkHandler.java From PneumaticCraft with GNU General Public License v3.0 | 5 votes |
public static void hurtPlayer(EntityPlayer user, int energySyphoned) { if (energySyphoned < 100 && energySyphoned > 0) { if (!user.capabilities.isCreativeMode) { user.setHealth((user.getHealth() - 1)); if (user.getHealth() <= 0.0005f) { user.onDeath(DamageSource.generic); } } } else if (energySyphoned >= 100) { if (!user.capabilities.isCreativeMode) { for (int i = 0; i < ((energySyphoned + 99) / 100); i++) { user.setHealth((user.getHealth() - 1)); if (user.getHealth() <= 0.0005f) { user.onDeath(DamageSource.generic); break; } } } } }
Example 7
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 8
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 9
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); } }