Sanity: Descent Into Madness

Sanity: Descent Into Madness

2M Downloads

Incompatability with AlexsMobs

JustS-js opened this issue ยท 0 comments

commented

Game version: 1.19.2
Incompatability issue with AlexsMobs

The problem is more general but let's just dive into the topic.
When a player's sanity level drops to the specified value, the mod invokes TargetInsanePlayerGoal for mobs around.
If the mob in question has flag m_alertSameType (i.e. Zombified Piglin), they also invoke TargetInsanePlayerGoal.alertOthers() method.
Inside of alertOthers() method the mod calls Entity.isAlliedTo() and as a parameter for that method it sends the result of this.mob.getTarget().
In general this should return PlayerEntity. But with AlexsMobs installed, you can obtain Unsettling Kimono, which sets mob's target field to null.
Thus, TargetInsanePlayerGoal.mob.getTarget() returns null, which then propagates as a parameter for Entity.isAlliedTo(null), which produces NullPointerException.

Crash Report:

java.lang.NullPointerException: Cannot invoke "net.minecraft.world.entity.Entity.getTeam()" because "p_20355_" is null
	at net.minecraft.world.entity.Entity.isAlliedTo(Entity.java:2084) 
	at croissantnova.sanitydim.entity.goal.TargetInsanePlayerGoal.alertOthers(TargetInsanePlayerGoal.java:91)
	at croissantnova.sanitydim.entity.goal.TargetInsanePlayerGoal.start(TargetInsanePlayerGoal.java:54)
	at net.minecraft.world.entity.ai.goal.WrappedGoal.start(WrappedGoal.java:41)
	at net.minecraft.world.entity.ai.goal.GoalSelector.tick(GoalSelector.java:106)
	at net.minecraft.world.entity.Mob.serverAiStep(Mob.java:722)
	at net.minecraft.world.entity.LivingEntity.aiStep(LivingEntity.java:2546)
	at net.minecraft.world.entity.Mob.aiStep(Mob.java:517)
	at net.minecraft.world.entity.monster.Monster.aiStep(Monster.java:42)
	at net.minecraft.world.entity.monster.Zombie.aiStep(Zombie.java:235)
	...