Mob Scarecrows

Mob Scarecrows

2M Downloads

Fabric 1.18.2 Crash

spoorn opened this issue ยท 3 comments

commented

Happened in my modpack on version 2.1.4: https://www.curseforge.com/minecraft/modpacks/spoornpack-fabric

I believe mixinInitGoals is from MobScarecrow. I was just typing stuff into the REI and it crashed, then I couldn't rejoin the server until I removed the mod

Minecraft 1.18.2
Fabric 0.14.7
MobScarecrow 2.0.0

---- Minecraft Crash Report ----
// You're mean.

Time: 6/13/22, 1:03 AM
Description: Ticking entity

java.lang.ClassCastException: class net.minecraft.class_1627 cannot be cast to class net.minecraft.class_1613 (net.minecraft.class_1627 and net.minecraft.class_1613 are in unnamed module of loader net.fabricmc.loader.impl.launch.knot.KnotClassLoader @42e26948)
	at net.minecraft.class_1547.handler$edg011$mixinInitGoals(class_1547.java:524)
	at net.minecraft.class_1547.method_5959(class_1547.java)
	at net.minecraft.class_1308.<init>(class_1308.java:144)
	at net.minecraft.class_1314.<init>(class_1314.java:14)
	at net.minecraft.class_1588.<init>(class_1588.java:30)
	at net.minecraft.class_1547.<init>(class_1547.java:67)
	at net.minecraft.class_1627.<init>(class_1627.java:23)
	at net.minecraft.class_1299.method_5883(class_1299.java:478)
	at net.minecraft.class_1308.method_29243(class_1308.java:1216)
	at net.minecraft.class_1613.method_33591(class_1613.java:97)
	at net.minecraft.class_1613.method_5773(class_1613.java:56)
	at net.minecraft.class_3218.method_18762(class_3218.java:702)
	at net.minecraft.class_1937.method_18472(class_1937.java:485)
	at net.minecraft.class_3218.method_31420(class_3218.java:363)
	at net.minecraft.class_5574.method_31791(class_5574.java:54)
	at net.minecraft.class_3218.method_18765(class_3218.java:331)
	at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:907)
	at net.minecraft.class_3176.method_3813(class_3176.java:322)
	at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:851)
	at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:697)
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:273)
	at java.base/java.lang.Thread.run(Thread.java:833)
commented

Just came to report a similar crash but found this issue. I think I might have an insight on the matter.

Here is the log:

[23:59:38] [Server thread/ERROR]: Encountered an unexpected exception
net.minecraft.class_148: Ticking entity
	at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:911) ~[client-intermediary.jar:?]
	at net.minecraft.server.MinecraftServer.method_3748(MinecraftServer.java:851) ~[client-intermediary.jar:?]
	at net.minecraft.class_1132.method_3748(class_1132.java:97) ~[client-intermediary.jar:?]
	at net.minecraft.server.MinecraftServer.method_29741(MinecraftServer.java:697) ~[client-intermediary.jar:?]
	at net.minecraft.server.MinecraftServer.method_29739(MinecraftServer.java:273) ~[client-intermediary.jar:?]
	at java.lang.Thread.run(Thread.java:833) [?:?]
Caused by: java.lang.ClassCastException: class net.minecraft.class_1639 cannot be cast to class net.minecraft.class_1613 (net.minecraft.class_1639 and net.minecraft.class_1613 are in unnamed module of loader net.fabricmc.loader.impl.launch.knot.KnotClassLoader @2473b9ce)
	at net.minecraft.class_1547.handler$ggn011$mixinInitGoals(class_1547.java:524) ~[client-intermediary.jar:?]
	at net.minecraft.class_1547.method_5959(class_1547.java) ~[client-intermediary.jar:?]
	at net.minecraft.class_1639.method_5959(class_1639.java:41) ~[client-intermediary.jar:?]
	at net.minecraft.class_1308.<init>(class_1308.java:144) ~[client-intermediary.jar:?]
	at net.minecraft.class_1314.<init>(class_1314.java:14) ~[client-intermediary.jar:?]
	at net.minecraft.class_1588.<init>(class_1588.java:30) ~[client-intermediary.jar:?]
	at net.minecraft.class_1547.<init>(class_1547.java:67) ~[client-intermediary.jar:?]
	at net.minecraft.class_1639.<init>(class_1639.java:33) ~[client-intermediary.jar:?]
	at net.minecraft.class_1299.method_5883(class_1299.java:478) ~[client-intermediary.jar:?]
	at net.minecraft.class_1308.method_29243(class_1308.java:1216) ~[client-intermediary.jar:?]
	at net.minecraft.class_1613.convertToWitherSkeleton(class_1613.java:531) ~[client-intermediary.jar:?]
	at net.minecraft.class_1613.handler$gka00f$tick(class_1613.java:526) ~[client-intermediary.jar:?]
	at net.minecraft.class_1613.method_5773(class_1613.java) ~[client-intermediary.jar:?]
	at net.minecraft.class_3218.method_18762(class_3218.java:702) ~[client-intermediary.jar:?]
	at net.minecraft.class_1937.method_18472(class_1937.java:485) ~[client-intermediary.jar:?]
	at net.minecraft.class_3218.method_31420(class_3218.java:363) ~[client-intermediary.jar:?]
	at net.minecraft.class_5574.method_31791(class_5574.java:54) ~[client-intermediary.jar:?]
	at net.minecraft.class_3218.method_18765(class_3218.java:331) ~[client-intermediary.jar:?]
	at net.minecraft.server.MinecraftServer.method_3813(MinecraftServer.java:907) ~[client-intermediary.jar:?]
	... 5 more

In this case the crash comes from interop problem with the Nether Expanded mod. It has a mixin that transforms a usual Skeleton into a Wither Skeleton. Afterwards Mob Scarecrow fails in its Skeleton mixin.

As I see it, it happens because of two things:

  1. Nether Expanded converts an entity between two diverging class hierarchies. Because in Minecraft class WitherSkeletonEntity extends AbstractSkeletonEntity and class SkeletonEntity extends AbstractSkeletonEntity but otherwise they are unrelated.
  2. Mob Scarecrow makes a too strong assumption in its mentioned mixin that the entity still belongs to the same class. Hence the crash when the cast fails.

The OPs log has no mention of Nether Expanded intervention but I think that the origin of the problem is the same, just coming from another mod or even vanilla. It's a weird happening from the POV of regular Java since you usually don't expect the class of this to change, but apparently it's one of those mixin magic things.

A resolution I can think of:

  • Mob Scarecrow at any time should not rely on an entity being of the same class as it was originally. Since the routine used by Nether Expanded here, namely MobEntity.convertTo(EntityType<T> entityType, boolean keepEquipment) is a vanilla Minecraft feature, it means that it should be assumed that an entity might change its class anytime. The only guarantee that the vanilla method gives is that the entity is going to remain being a descendant of MobEntity.
commented

Thanks for the insight. I have fixed this issue, and in fixing this I ended up making scarecrows compatible with modded entities.

commented

Could you provide the full crash log. I am trying to re create the crash but am unable to. And does your pack have any mods that also modify existing mobs or their AI?