SmileycorpMC / ldoh-tweaks

GNU Lesser General Public License v2.1
2 stars 2 forks source link

[1.1.4b][Crash][Server] NoSuchMethodError: net.minecraft.util.FoodStats.func_75119_b(F)V triggered by TF2 NPCs #1

Closed TigerWalts closed 2 years ago

TigerWalts commented 2 years ago

The net.minecraft.util.FoodStats.setFoodSaturationLevel method doesn't appear to be available on dedicated servers. This is leading to crash when TF2 NPCs are ticked:

java.lang.NoSuchMethodError: net.minecraft.util.FoodStats.func_75119_b(F)V
    at net.smileycorp.ldoh.common.capabilities.IHunger$Hunger.onUpdate(IHunger.java:142)
    at net.smileycorp.ldoh.common.events.TF2Events.livingTick(TF2Events.java:140)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_696_TF2Events_livingTick_LivingUpdateEvent.invoke(.dynamic)
    at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90)
    at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:182)
    at net.minecraftforge.common.ForgeHooks.onLivingUpdate(ForgeHooks.java:581)
    at net.minecraft.entity.EntityLivingBase.onUpdate(EntityLivingBase.java:2095)
    at net.minecraft.entity.EntityLiving.onUpdate(EntityLiving.java:295)
    at rafradek.TF2weapons.entity.mercenary.EntityTF2Character.onUpdate(EntityTF2Character.java:1376)
    at net.minecraft.world.World.updateEntityWithOptionalForce(World.java:1996)

I don't know why it isn't available on dedicated servers but this problem has been encountered in the past for other mods, Way of Time avoided it by converting to an NBT object, making the change and then reading the NBT back:

                                NBTTagCompound nbt = new NBTTagCompound();
                                foodStats.writeNBT(nbt);
                                nbt.setFloat("foodSaturationLevel", saturatedHeal + satLevel);
                                foodStats.readNBT(nbt);
SmileycorpMC commented 2 years ago

I haven't been able to get the issue to happen on my end, but I have had a few reports with this problem.

It may be possible to use nbt to handle it, so I'll look into doing it that way, although I'm not certain, because I already have to use methods to change the base values in the object.

I will investigate it a bit and see if I can convert to using this. Thank you for bringing this to me