public static ItemStack chargeHealth( ItemStack stack, World world, EntityPlayer player, String tag) { if (!stack.hasTagCompound()) stack.setTagCompound(new NBTTagCompound()); NBTTagCompound nbtData = stack.getTagCompound(); if (nbtData == null) { stack.getTagCompound().setInteger(tag, 0); } if (player.isSneaking()) { int points = stack.getTagCompound().getInteger(tag); if (points != 0) { int current = (int) player.getHealth(); int max = (int) player.getMaxHealth(); if (current != max & (current < max)) { int used = max - current; if (!(points - used < 0)) { nbtData.setInteger(tag, points - used); player.setHealth(player.getMaxHealth()); } else if ((points - used < 0)) { nbtData.setInteger(tag, 0); player.setHealth(nbtData.getInteger(tag) + current); } } } } else { FontHelper.sendMessage( FontHelper.translate("points.health") + ": " + stack.getTagCompound().getInteger(tag), world, player); } return stack; }
public static ItemStack chargeHunger( ItemStack stack, World world, EntityPlayer player, String tag) { if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } NBTTagCompound nbtData = stack.getTagCompound(); if (nbtData == null) { stack.getTagCompound().setInteger(tag, 0); } int points = stack.getTagCompound().getInteger(tag); if (player.isSneaking()) { int hunger = player.getFoodStats().getFoodLevel(); int usedpoints = 20 - hunger; if (!(hunger >= 20)) { if (points - usedpoints > 1) { points -= usedpoints; nbtData.setInteger(tag, points); player.getFoodStats().addStats(20, 2.0F); } else if (points - usedpoints < 1) { nbtData.setInteger(tag, 0); player.getFoodStats().addStats(points, 2.0F); } } } else if (!world.isRemote) { FontHelper.sendMessage( FontHelper.translate("points.hunger") + ": " + stack.getTagCompound().getInteger(tag), world, player); } return stack; }
@SideOnly(Side.CLIENT) public List<String> getWailaInfo(List<String> currenttip) { super.getWailaInfo(currenttip); if (cookTime > 0) { String active = FontHelper.translate("locator.state") + ":" + FontHelper.translate("locator.active"); currenttip.add(active); } else { String idle = FontHelper.translate("locator.state") + ":" + FontHelper.translate("locator.idle"); currenttip.add(idle); } return currenttip; }
@Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) { super.addInformation(stack, player, list, par4); if (!CalculatorConfig.isEnabled(stack)) { list.add(FontHelper.translate("calc.ban")); } }