Deeper and Darker

Deeper and Darker

25M Downloads

ClassCastException on zoglin

sabrael opened this issue ยท 2 comments

commented

Mod Version: deeperdarker-forge-1.20.1-1.2.0.jar
Mod Loader: Forge 47.1.3

Description:
Server crashed when entering nether. Stack trace:

Caused by: java.lang.ClassCastException: class net.minecraft.world.entity.monster.Zoglin cannot be cast to class net.minecraft.server.level.ServerPlayer (net.minecraft.world.entity.monster.Zoglin and net.minecraft.server.level.ServerPlayer are in module [email protected] of loader 'TRANSFORMER' @183ef89a)at com.kyanite.deeperdarker.content.enchantments.CatalysisEnchantment.m7677(CatalysisEnchantment.java:33) ~[deeperdarker-forge-1.20.1-1.2.0.jar%23507!/:1.2.0] {re:classloading}at net.minecraft.world.item.enchantment.EnchantmentHelper.m44826(EnchantmentHelper.java:194) ~[server-1.20.1-20230612.114412-srg.jar%23727!/:?] {re:mixin,re:classloading,pl:mixin:A}at net.minecraft.world.item.enchantment.EnchantmentHelper.m44850(EnchantmentHelper.java:132) ~[server-1.20.1-20230612.114412-srg.jar%23727!/:?] {re:mixin,re:classloading,pl:mixin:A}

To Reproduce:
Steps to reproduce the behavior:

  1. Enter nether
  2. Walk around until a zoglin spawns
  3. Server crashes
  4. See error

Additional context:
This is on an ATM9 server (ver 0.0.63)

commented

I have encountered the same issue, thought I would include a full crash log in case it helps.

https://api.mclo.gs/1/raw/wu81Axq
crash-2023-09-25_20.58.12-server.txt

commented

This is the issue:

CriteriaTriggers.KILL_MOB_NEAR_SCULK_CATALYST.trigger((ServerPlayer) pAttacker, pTarget, pTarget.damageSources().playerAttack((Player) pAttacker));

It assumes the attacker will always be a player entity but if you add custom mods that enable enchantments for hostile entities that hold equipment it will cause a crash if they attack another enemy. The reason I think this is happening with Zoglins is because you obviously have Piglins which will attack zoglins at sight and they can carry quite high-powered weapons.

To fix this you need to remove the cast that assumes the living entity will be a player or exit early if this happens