MatrexsVigil / phc2crops

All rights reserved - None of my artwork is available to be used for FREE in your game EVER. If you want to HIRE ME, please contact me. Thank you. This code is here for people to learn from and to help find bugs ONLY.
https://www.patreon.com/pamsmods
Other
16 stars 23 forks source link

[Bug] Single player crash #43

Open winsrp opened 3 years ago

winsrp commented 3 years ago

Using version 1.16.3-1.0.2 got this error on the log that crashes single player

[13May2021 21:34:36.303] [Server thread/ERROR] [net.minecraftforge.eventbus.EventBus/EVENTBUS]: Exception caught during firing event: Unsupported mob type for TemptGoal
    Index: 27
    Listeners:
        0: HIGHEST
        1: ASM: net.minecraftforge.common.ForgeInternalHandler@1200612 onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        2: ASM: class com.performant.coremod.event.ForgeBusEventHandler onEntityAdded(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        3: NORMAL
        4: ASM: com.github.alexthe666.citadel.server.CitadelEvents@298367ef onJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        5: ASM: class chumbanotz.mutantbeasts.EventHandler onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        6: ASM: class tallestegg.guardvillagers.HandlerEvents onLivingSpawned(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        7: ASM: shadows.apotheosis.deadly.affix.AffixEvents@110eeee5 onEntityJoin(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        8: ASM: class net.mehvahdjukaar.dummmmmmy.common.Events onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        9: net.minecraftforge.eventbus.EventBus$$Lambda$2530/244886962@2b4f47cc
        10: ASM: invtweaks.InvTweaksMod@42e6cbad onEntityJoin(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        11: ASM: com.bobmowzie.mowziesmobs.server.ServerEventHandler@79da448e onJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        12: net.minecraftforge.eventbus.EventBus$$Lambda$2530/244886962@76d351b6
        13: ASM: vazkii.quark.content.automation.module.ChainLinkageModule@714aaa0b onVehicleArrive(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        14: ASM: vazkii.quark.content.automation.module.FeedingTroughModule@31e9c0eb onOrbSpawn(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        15: ASM: vazkii.quark.content.building.module.VariantChestsModule@2f32f28c onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        16: ASM: vazkii.quark.content.tools.module.SkullPikesModule@1d7457c0 onMonsterAppear(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        17: ASM: vazkii.quark.content.tweaks.module.PatTheDogsModule@26a54e75 onWolfAppear(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        18: ASM: vazkii.quark.content.tweaks.module.VillagersFollowEmeraldsModule@30470b2 onVillagerAppear(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        19: net.minecraftforge.eventbus.EventBus$$Lambda$2530/244886962@1aa8011b
        20: ASM: top.theillusivec4.curios.common.event.CuriosEventHandler@3e45ff8d entityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        21: ASM: com.mrcrayfish.obfuscate.common.data.SyncedPlayerData@98f3097 onPlayerJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        22: ASM: com.pam.pamhc2trees.events.TemptationTask@4b79d2b1 onEntitySpawn(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        23: ASM: journeymap.server.events.ForgeEvents@2c67f0fe onEntityJoinWorldEvent(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        24: ASM: mekanism.common.CommonPlayerTracker@4482cbf3 onEntitySpawn(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        25: ASM: top.theillusivec4.champions.common.ChampionEventsHandler@4739a942 onLivingJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        26: ASM: flaxbeard.immersivepetroleum.common.CommonEventHandler@329ef40c onEntityJoiningWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        27: ASM: pam.pamhc2crops.events.TemptationTask@6e4d4a2b onEntitySpawn(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        28: ASM: blusunrize.immersiveengineering.common.EventHandler@5777b285 onEntityJoiningWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        29: ASM: com.natamus.giantspawn.events.GiantEvent@65c0e815 onEntityJoin(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
        30: ASM: com.natamus.collective.events.EntityEvents@6da95d68 onEntityJoinWorld(Lnet/minecraftforge/event/entity/EntityJoinWorldEvent;)V
java.lang.IllegalArgumentException: Unsupported mob type for TemptGoal
    at net.minecraft.entity.ai.goal.TemptGoal.<init>(SourceFile:40)
    at pam.pamhc2crops.entities.ai.MoreTemptation.<init>(MoreTemptation.java:9)
    at pam.pamhc2crops.events.TemptationTask.onEntitySpawn(TemptationTask.java:193)
    at net.minecraftforge.eventbus.ASMEventHandler_1195_TemptationTask_onEntitySpawn_EntityJoinWorldEvent.invoke(.dynamic)
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85)
    at net.minecraftforge.eventbus.EventBus$$Lambda$2132/2127177759.invoke(Unknown Source)
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302)
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283)
    at net.minecraft.world.server.ServerWorld.func_217440_f(ServerWorld.java:829)
    at net.minecraft.world.server.ChunkManager.lambda$null$25(ChunkManager.java:763)
    at net.minecraft.world.server.ChunkManager$$Lambda$20818/1586305414.apply(Unknown Source)
    at com.mojang.datafixers.util.Either.lambda$mapLeft$0(Either.java:162)
    at com.mojang.datafixers.util.Either$$Lambda$20819/1394015253.apply(Unknown Source)
    at com.mojang.datafixers.util.Either$Left.map(Either.java:38)
    at com.mojang.datafixers.util.Either.mapLeft(Either.java:162)
    at net.minecraft.world.server.ChunkManager.lambda$func_219200_b$26(ChunkManager.java:733)
    at net.minecraft.world.server.ChunkManager$$Lambda$20815/340994234.apply(Unknown Source)
    at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:602)
    at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:442)
    at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter.func_219083_b(SourceFile:58)
    at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter$$Lambda$20736/986564478.run(Unknown Source)
    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213166_h(ThreadTaskExecutor.java:191)
    at net.minecraft.world.server.ServerChunkProvider$ChunkExecutor.func_213166_h(ServerChunkProvider.java:514)
    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213168_p(ThreadTaskExecutor.java:153)
    at net.minecraft.world.server.ServerChunkProvider$ChunkExecutor.func_213168_p(ServerChunkProvider.java:522)
    at net.minecraft.world.server.ServerChunkProvider.func_217234_d(ServerChunkProvider.java:267)
    at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:722)
    at net.minecraft.server.MinecraftServer.func_213168_p(MinecraftServer.java:711)
    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213161_c(ThreadTaskExecutor.java:169)
    at net.minecraft.server.MinecraftServer.func_213202_o(MinecraftServer.java:697)
    at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:646)
    at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232)
    at net.minecraft.server.MinecraftServer$$Lambda$20510/702261595.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Duorhs commented 3 years ago

Same here. My crash-report:

Description: Exception ticking world

java.lang.IllegalArgumentException: Unsupported mob type for TemptGoal
    at net.minecraft.entity.ai.goal.TemptGoal.<init>(SourceFile:40) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:quark.mixins.json:TemptGoalMixin,pl:mixin:A}
    at pam.pamhc2crops.entities.ai.MoreTemptation.<init>(MoreTemptation.java:9) ~[pamhc2crops:1.0.2] {re:classloading}
    at pam.pamhc2crops.events.TemptationTask.onEntitySpawn(TemptationTask.java:183) ~[pamhc2crops:1.0.2] {re:classloading}
    at net.minecraftforge.eventbus.ASMEventHandler_1188_TemptationTask_onEntitySpawn_EntityJoinWorldEvent.invoke(.dynamic) ~[?:?] {}
    at net.minecraftforge.eventbus.ASMEventHandler.invoke(ASMEventHandler.java:85) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:302) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraftforge.eventbus.EventBus.post(EventBus.java:283) ~[eventbus-4.0.0.jar:?] {}
    at net.minecraft.world.server.ServerWorld.func_217440_f(ServerWorld.java:829) ~[?:?] {re:mixin,pl:accesstransformer:B,re:computing_frames,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:abnormals_core.mixins.json:ServerWorldMixin,pl:mixin:APP:quark.mixins.json:ServerWorldMixin,pl:mixin:A}
    at net.minecraft.world.server.ChunkManager.lambda$null$25(ChunkManager.java:763) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,xf:OptiFine:default,pl:mixin:A}
    at com.mojang.datafixers.util.Either.lambda$mapLeft$0(Either.java:162) ~[datafixerupper-4.0.26.jar:?] {re:classloading}
    at com.mojang.datafixers.util.Either$Left.map(Either.java:38) ~[datafixerupper-4.0.26.jar:?] {re:classloading}
    at com.mojang.datafixers.util.Either.mapLeft(Either.java:162) ~[datafixerupper-4.0.26.jar:?] {re:classloading}
    at net.minecraft.world.server.ChunkManager.lambda$func_219200_b$26(ChunkManager.java:733) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,xf:OptiFine:default,pl:mixin:A}
    at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:642) ~[?:?] {}
    at java.util.concurrent.CompletableFuture$Completion.run(CompletableFuture.java:478) ~[?:?] {}
    at net.minecraft.world.chunk.ChunkTaskPriorityQueueSorter.func_219083_b(SourceFile:58) ~[?:?] {re:classloading}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213166_h(ThreadTaskExecutor.java:189) ~[?:?] {re:computing_frames,pl:accesstransformer:B,xf:OptiFine:default,re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,xf:OptiFine:default}
    at net.minecraft.world.server.ServerChunkProvider$ChunkExecutor.func_213166_h(ServerChunkProvider.java:514) ~[?:?] {re:classloading}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213168_p(ThreadTaskExecutor.java:151) ~[?:?] {re:computing_frames,pl:accesstransformer:B,xf:OptiFine:default,re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,xf:OptiFine:default}
    at net.minecraft.world.server.ServerChunkProvider$ChunkExecutor.func_213168_p(ServerChunkProvider.java:522) ~[?:?] {re:classloading}
    at net.minecraft.world.server.ServerChunkProvider.func_217234_d(ServerChunkProvider.java:267) ~[?:?] {re:classloading,pl:accesstransformer:B,re:mixin,pl:accesstransformer:B}
    at net.minecraft.server.MinecraftServer.func_213205_aW(MinecraftServer.java:722) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:betterendforge.mixins.json:MinecraftServerMixin,pl:mixin:A}
    at net.minecraft.server.MinecraftServer.func_213168_p(MinecraftServer.java:711) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:betterendforge.mixins.json:MinecraftServerMixin,pl:mixin:A}
    at net.minecraft.util.concurrent.ThreadTaskExecutor.func_213161_c(ThreadTaskExecutor.java:167) ~[?:?] {re:computing_frames,pl:accesstransformer:B,xf:OptiFine:default,re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,xf:OptiFine:default}
    at net.minecraft.server.MinecraftServer.func_213202_o(MinecraftServer.java:697) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:betterendforge.mixins.json:MinecraftServerMixin,pl:mixin:A}
    at net.minecraft.server.MinecraftServer.func_240802_v_(MinecraftServer.java:646) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:betterendforge.mixins.json:MinecraftServerMixin,pl:mixin:A}
    at net.minecraft.server.MinecraftServer.func_240783_a_(MinecraftServer.java:232) ~[?:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:betterendforge.mixins.json:MinecraftServerMixin,pl:mixin:A}
    at java.lang.Thread.run(Thread.java:829) [?:?] {}
RuggedTime commented 2 years ago

Same here, with same log. image

Mysteryem commented 2 years ago

I have investigated this issue happening on my server. This happens when a ChickenEntity/CowEntity/PigEntity/RabbitEntity/SheepEntity is riding an Entity which has a PathNavigator that is neither a GroundPathNavigator or FlyingPathNavigator. The issue comes from the fact that MobEntity::getNavigator will return the PathNavigator of the Entity it is riding when that Entity is a MobEntity. TemptGoal (the superclass of MoreTemptation) checks that getNavigator() is either an instance of GroundPathNavigator or FlyingPathNavigator in its constructor and if it isn't, you get the llegalArgumentException seen here.

My server was crashing because a Pig was riding a Crocodile from Alex's Mobs, which can have a custom PathNavigator. Likely because when crocodiles attack mobs they are forced into riding the crocodile. I guess the chunk unloaded before the Pig had been killed, then whenever the chunk got loaded again, it crashed the server.

As a quick and dirty workaround I compiled an edited version of this mod that changes TemptationTask::onEntityspawn to initially call Entity::dismount if getNavigator doesn't return one of the expected PathNavigator subclasses. (I tried Entity::stopRiding first, but that froze the server for some reason).

This issue is also present in the Pam's Harvestcraft 2 Trees mod, I haven't checked any of the others Pam's mods.

Awec4 commented 2 years ago

This bug is causing my server to crash. Hopefully we can get an update to fix this?

iggyvilla commented 2 years ago

As a quick and dirty workaround I compiled an edited version of this mod that changes TemptationTask::onEntityspawn to initially call Entity::dismount if getNavigator doesn't return one of the expected PathNavigator subclasses. (I tried Entity::stopRiding first, but that froze the server for some reason).

Would it be possible for you @Mysteryem to share your patched build while there is still no official fix? This crash is frustrating some players on my server and I'm unfortunately not very good at Java.

Mysteryem commented 2 years ago

As a quick and dirty workaround I compiled an edited version of this mod that changes TemptationTask::onEntityspawn to initially call Entity::dismount if getNavigator doesn't return one of the expected PathNavigator subclasses. (I tried Entity::stopRiding first, but that froze the server for some reason).

Would it be possible for you @Mysteryem to share your patched build while there is still no official fix? This crash is frustrating some players on my server and I'm unfortunately not very good at Java.

Unfortunately, this project's license prohibits sharing any such files, regardless of whether it's a compiled build or edited source code. The source code is visible (which helps with finding the cause of bugs like this), but this is not an open source project by any means.

JuicyCosmos commented 2 years ago

@Mysteryem Since I'm not familiar with Java, could you please elaborate on a detailed guide? I wonder why Pam's mod wants to getPathNavigator since there's no need for Pam's mod, a farming mod, to modify or read mob data. If this is something that can be done by simply extracting the jar file, edit the code, recompile it in zip format and rename it to jar I would be very much grateful. It's a little disappointing that the two authors wouldn't collaborate on this.

Mysteryem commented 2 years ago

@JuicyCosmos In order for mobs like pigs and sheep to follow players when they hold fruit/veg/seeds from Pam's mods an AI task is added to pigs/sheep/etc. that makes them follow after players when they hold out the correct fruit/veg/seeds for that animal. This AI task is built on top of the AI task that vanilla Minecraft uses for making mobs follow you when you hold out wheat/carrots/etc. which has the check that getNavigator() returns a PathNavigator of a valid type. You might wonder why then that same vanilla AI task doesn't crash on its own and that's because, as far as I can tell, the vanilla AI tasks get added before the entity they're riding gets set so it avoids the issue entirely since there is no ridden entity at that time.

To make the modifications you would need to edit the source code in this repository and recompile the mod from the source code yourself, which would require a basic understanding of programming and Java and how to set your choice of IDE for minecraft mod development, my previous comment should already be enough for someone who knows what they're doing to make. It would be too much work for me to teach someone up to that level

As a quick and dirty workaround I compiled an edited version of this mod that changes TemptationTask::onEntityspawn to initially call Entity::dismount if getNavigator doesn't return one of the expected PathNavigator subclasses. (I tried Entity::stopRiding first, but that froze the server for some reason).

A better solution, which would fix more mods than this would be to either work with Forge to alter the vanilla TemptGoal class that is the cause of all these problems or find a modder who knows how to use mixin to make a mod to modify the vanilla code for the TemptGoal class.

JuicyCosmos commented 2 years ago

@Mysteryem Thanks for shedding more light on the issue! I had minimal programming experience only with the surface level Python they taught in the uni, though I aim to learn more about programming in the future. Based on your description of the cause of the crash, I suppose any mod that forces those animals to ride a modded modded entity with a custom pathNavigator would result in a crash when paired with pam's? That would be a lot of mods incompatible. If that's the case this should really be up to forge to better implement, like you've said. I may want to remove pam's mods in favor of small but more polished farming mods. The best I can do for now is do some testing and see. (Wait, how do those mod, given they have the crop tempting feature, avoid causing crashes? Do they all use mixins?) Thank you for your generous info again.

Mysteryem commented 2 years ago

@JuicyCosmos Yes, when paired with Alex's Mobs (or another mod that brings this issue to the surface), SimpleFarming used to run into the same issue, as did Quark. SimpleFarming added checks that getNavigator() returns a valid PathNavigator and only adds the AI goal if it's valid: https://github.com/cweckerl/simplefarming/commit/238307d602adb11099d6e68884086b2ed7c2537c And Quark added a Try-Catch block for the exception that gets thrown when the PathNavigator is of an invalid type, ignoring whenever adding the AI goal would fail and throw an IllegalArgumentException: https://github.com/VazkiiMods/Quark/commit/0a7e2eddd3b5b4fd132b4e19f04ea5a261949ce0

Both I would describe as workarounds, since in both cases, the entity that would have caused the crash never gets given the AI goal it's supposed to have, though it's unlikely to be noticeable in most circumstances.

Using mixins to alter the vanilla TempGoal class in mods like SimpleFarming and Quark would probably not be a very good idea, because then you'd have a bunch of mods all modifying the same vanilla code (Mixin may be designed to handle this better than everyone writing their own coremods, but I still wouldn't advise it), it would be more suited for a mod made specifically for performing that fix or a mod designed to fix a whole bunch of vanilla issues.

As most of these mods are adding the AI goal in the EntityJoinWorldEvent event it may be a decent workaround to make a mod that also listens to the EntityJoinWorldEvent event, but on a HIGH or HIGHEST priority (most mods probably don't specify a priority, meaning they use NORMAL priority). That way, the mod can check if getNavigator() returns a valid PathNavigator and call dismount() in advance of the other mods adding their AI goals. This does then have the problem that even mobs that aren't going to be given custom AI goals are going to dismount whatever they're riding if their mount doesn't have a valid type of PathNavigator, though it may be possible to fix this by keeping track of the Entity that dismounted and its mount in the HIGH/HIGHEST priority EntityJoinWorldEvent listener and then remount that same Entity in a second EntityJoinWorldEvent listener set to LOW/LOWEST priority which would likely happen after any mods have added their extra AI goals.