NoHaxJustLegit
-
Posts
11 -
Joined
-
Last visited
Posts posted by NoHaxJustLegit
-
-
1 hour ago, diesieben07 said:
Cooked beef gives 8 food level (not saturation), that's 4 hunger-bars. This value can be gotten using ItemFood#getHealAmount(ItemStack). For cooked beef this returns 8.
Saturation is a different concept, it is not shown in the UI directly.
I know, I wanted to add how much saturation a food gives based on 20 food level (max) like AppleSkin does with the yellow food level border when food is held. If it's useless then I'll just add the food level
-
8 hours ago, diesieben07 said:
That is not how you handle exceptions. At all. Ever.
Why are you passing a string to Field#getFloat?
Just to be sure, you know I want to know how much saturation a food gives right? like AppleSkin does
Example: If a cooked beef gives you 3 saturation points (1.5 as hunger shanks) it should say 1.5
-
Just now, DavidM said:
Use reflection.
Sorry, I edited my last post, I've used it
-
25 minutes ago, diesieben07 said:
No... You need to actually use the value of FoodStats#foodSaturationLevel.
But the value is private
Tried this but
public static final Field saturationLevel = ReflectionHelper.findField(FoodStats.class, "field_75125_b", "foodSaturationLevel"); try { tooltip.add("§2Saturation level: §a" + saturationLevel.getFloat("foodSaturationLevel"))); } catch (IllegalArgumentException | IllegalAccessException e) { e.printStackTrace(); }
java.lang.IllegalArgumentException: Can not set float field net.minecraft.util.FoodStats.foodSaturationLevel to java.lang.String
-
12 minutes ago, diesieben07 said:
- Do not use @SideOnly.
- Use the TextFormatting class instead of hardcoded color prefixes (which are even broken, you need to use §, not & if you were to use them).
- You can see how the new food and saturation levels are calculated in FoodStats#addStats.
tooltip.add("§2Saturation level: §a"+ Math.min(5F + heal * saturation * 2.0F, heal));
5F is from foodSaturationLevel inside FoodStats class, is it correct?
-
Hello, I'm trying to add the saturation level and the food heal that a fooditem gives.
@SideOnly(Side.CLIENT) public class FoodNutrition { private static final KeyBinding keyBindSneak = Minecraft.getMinecraft().gameSettings.keyBindSneak; @SubscribeEvent public void onTooltipDisplayed(ItemTooltipEvent event) { if (event.getEntityPlayer() == null) { return; } if (!event.getItemStack().isEmpty() && event.getItemStack().getItem() instanceof ItemFood) { Item item = event.getItemStack().getItem(); ItemStack stack = event.getItemStack(); final List<String> tooltip = event.getToolTip(); float heal = ((ItemFood) item).getHealAmount(stack); float saturation = ((ItemFood) item).getSaturationModifier(stack); System.out.print("\nSat: " + event.getEntityPlayer().getFoodStats().getSaturationLevel() + "\nFood: " + event.getEntityPlayer().getFoodStats().getFoodLevel()); if (GameSettings.isKeyDown(keyBindSneak)) { tooltip.add("&2Food level: &a" + (heal / 2)); tooltip.add("&2Saturation level: &a"+ saturation); } else { tooltip.add(Messages.color("Press shift")); } } } }
The cooked chicken gives Food Level: 6.0 restoring 6 points and its correct and Saturation level gives me 0.6 and the print gives:
Sat: 6.0 Food: 6
is there a better way to get/show how many heal points (not hearts) and saturation points a food gives? I think my only problem is Saturation level which gives me a 0.x number
-
Any help?
-
1 hour ago, Animefan8888 said:
Try setting it on both the client and server. Aka remove !world.isRemote
No, still the same
-
1 hour ago, Animefan8888 said:
That's because you are adding to the speed every tick... Instead of changing the base value with setBaseValue add a modifier to it.
I've tried to set the base value to 50 like this:
player.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).setBaseValue(50);
(default is 4) but the player dig/attack like if has 4
-
Hello, I'm creating a helmet that gives the same effect that gives haste without adding haste (I don't like to see it) but using:
@SubscribeEvent public static void onUse(PlayerTickEvent event) { EntityPlayer player = (EntityPlayer) event.player; World world = player.world; ItemStack head = player.getItemStackFromSlot(EntityEquipmentSlot.HEAD); double speed = player.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue(); if (!world.isRemote) { player.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).setBaseValue(speed + 0.321903904932D); //as test } }
But obviously, after some time, it prints "Infinity" and the attack speed doesn't change
1.12 NPE trying to add a potion effect that doesn't exists
in Modder Support
Posted · Edited by NoHaxJustLegit
Hello, I'm trying to add configurable join effects to give to a player when he joins a world. This is my class:
I dont know why you would be but if you want to know what is the Messages.serverLog then:
My default effects are:
public String[] effects = { "minecraft:regeneration,60,1", "minecraft:resistance,60,1" };
and it works but when I try to add something like: (is an example)
notminecraft:notregeneration
The error that says that the effect doesn't exist works but after the game crash with
[09:12:15] [Server thread/ERROR] [minecraft/MinecraftServer]: Encountered an unexpected exception net.minecraft.util.ReportedException: Ticking player at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:212) ~[NetworkSystem.class:?] at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865) ~[MinecraftServer.class:?] at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_221] Caused by: java.lang.NullPointerException at net.minecraft.potion.PotionEffect.onUpdate(PotionEffect.java:127) ~[PotionEffect.class:?] at net.minecraft.entity.EntityLivingBase.updatePotionEffects(EntityLivingBase.java:688) ~[EntityLivingBase.class:?] at net.minecraft.entity.EntityLivingBase.onEntityUpdate(EntityLivingBase.java:406) ~[EntityLivingBase.class:?] at net.minecraft.entity.Entity.onUpdate(Entity.java:466) ~[Entity.class:?] at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2315) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:272) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423) ~[EntityPlayerMP.class:?] at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185) ~[NetHandlerPlayServer.class:?] at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212) ~[NetworkDispatcher$1.class:?] at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) ~[NetworkManager.class:?] at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) ~[NetworkSystem.class:?] ... 5 more [09:12:15] [Server thread/ERROR] [minecraft/MinecraftServer]: This crash report has been saved to: C:\Users\cpiva\Documents\GitHub\CrisCore\run\.\crash-reports\crash-2019-11-13_09.12.15-server.txt [09:12:15] [Server thread/INFO] [minecraft/MinecraftServer]: Stopping server [09:12:15] [Server thread/INFO] [minecraft/MinecraftServer]: Saving players [09:12:15] [Server thread/ERROR] [minecraft/MinecraftServer]: Exception stopping the server net.minecraft.util.ReportedException: Saving entity NBT at net.minecraft.entity.Entity.writeToNBT(Entity.java:1988) ~[Entity.class:?] at net.minecraft.server.integrated.IntegratedPlayerList.writePlayerData(IntegratedPlayerList.java:30) ~[IntegratedPlayerList.class:?] at net.minecraft.server.management.PlayerList.saveAllPlayerData(PlayerList.java:1000) ~[PlayerList.class:?] at net.minecraft.server.MinecraftServer.stopServer(MinecraftServer.java:493) ~[MinecraftServer.class:?] at net.minecraft.server.integrated.IntegratedServer.stopServer(IntegratedServer.java:413) ~[IntegratedServer.class:?] at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:645) [MinecraftServer.class:?] at java.lang.Thread.run(Unknown Source) [?:1.8.0_221] Caused by: java.lang.NullPointerException at net.minecraft.potion.PotionEffect.getCurativeItems(PotionEffect.java:286) ~[PotionEffect.class:?] at net.minecraft.potion.PotionEffect.writeCurativeItems(PotionEffect.java:333) ~[PotionEffect.class:?] at net.minecraft.potion.PotionEffect.writeCustomPotionEffectToNBT(PotionEffect.java:219) ~[PotionEffect.class:?] at net.minecraft.entity.EntityLivingBase.writeEntityToNBT(EntityLivingBase.java:614) ~[EntityLivingBase.class:?] at net.minecraft.entity.player.EntityPlayer.writeEntityToNBT(EntityPlayer.java:1021) ~[EntityPlayer.class:?] at net.minecraft.entity.player.EntityPlayerMP.writeEntityToNBT(EntityPlayerMP.java:275) ~[EntityPlayerMP.class:?] at net.minecraft.entity.Entity.writeToNBT(Entity.java:1959) ~[Entity.class:?] ... 6 more [09:12:16] [Server thread/INFO] [FML]: Applying holder lookups [09:12:16] [Server thread/INFO] [FML]: Holder lookups appliedjava.lang.NullPointerException: Ticking player at net.minecraft.potion.PotionEffect.onUpdate(PotionEffect.java:127) at net.minecraft.entity.EntityLivingBase.updatePotionEffects(EntityLivingBase.java:688) at net.minecraft.entity.EntityLivingBase.onEntityUpdate(EntityLivingBase.java:406) at net.minecraft.entity.Entity.onUpdate(Entity.java:466) at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2315) at net.minecraft.entity.player.EntityPlayer.onUpdate(EntityPlayer.java:272) at net.minecraft.entity.player.EntityPlayerMP.onUpdateEntity(EntityPlayerMP.java:423) at net.minecraft.network.NetHandlerPlayServer.update(NetHandlerPlayServer.java:185) at net.minecraftforge.fml.common.network.handshake.NetworkDispatcher$1.update(NetworkDispatcher.java:212) at net.minecraft.network.NetworkManager.processReceivedPackets(NetworkManager.java:307) at net.minecraft.network.NetworkSystem.networkTick(NetworkSystem.java:197) at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:865) at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:743) at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:192) at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:592) at java.lang.Thread.run(Unknown Source)