MohistMC / Mohist

Minecraft Forge Hybrid server implementing the Spigot/Bukkit API, formerly known as Thermos/Cauldron/MCPC+
https://mohistmc.com
GNU General Public License v3.0
1.3k stars 213 forks source link

[1.20.1] Mob EntityType null error #2937

Closed rafucuk closed 1 month ago

rafucuk commented 8 months ago

Mythicmobs returns a null EntityType:

[04:12:29] [Server thread/WARN] []: java.lang.NullPointerException: Cannot invoke "org.bukkit.entity.EntityType.getEntityClass()" because "entityType" is null
[04:12:29] [Server thread/WARN] []:     at TRANSFORMER/forge@47.2.20/org.bukkit.craftbukkit.v1_20_R1.CraftRegionAccessor.spawnEntity(CraftRegionAccessor.java:420)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.bukkit.adapters.BukkitEntityType.spawnEntity(BukkitEntityType.java:70)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.bukkit.entities.BukkitCustom.spawn(BukkitCustom.java:37)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.bukkit.adapters.BukkitEntityType.spawn(BukkitEntityType.java:39)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.core.mobs.MobType.spawn(MobType.java:894)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.core.mobs.MobExecutor.spawnMob(MobExecutor.java:563)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.core.mobs.MobExecutor.spawnMob(MobExecutor.java:556)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.bukkit.commands.mobs.SpawnCommand.onCommand(SpawnCommand.java:161)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.bukkit.utils.commands.Command.onCommand(Command.java:64)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.bukkit.utils.commands.Command.onCommand(Command.java:55)
[04:12:29] [Server thread/WARN] []:     at io.lumine.mythic.bukkit.utils.commands.Command.onCommand(Command.java:55)
rafucuk commented 8 months ago

Well I have a lot of information right now, tested & source checked mythicmobs. image issue is right here, spawnEntity does not returning forge mob types.

I've checked mythicmobs source code and there is spawnEntity function. image

And no the issue is not with mythicmobs only, mythicmobs uses their custom entity types; image BUT there is also a custom entity type which if entity_type is not one of their custom entity types it will get bukkit entity type and use that. image

So the only issue is the CraftRegionAccessor.java returning null entitytype

@Mgazul

rafucuk commented 8 months ago

I've used recaf to get source code of mythicmobs for only searching purposes

rafucuk commented 8 months ago

It is not only a mythicmobs problem, every plugin that uses CraftRegionAccessor's spawnEntity will error if used with forged entity, for example denizen uses that too it shows that it registered in "server.list_entity_types" (a variable that shows custom entities registered on server) image image

REINAPACK_KITSUNE is my custom mob and it gives similar issue in the console image

rafucuk commented 8 months ago

I hope this will be enough, if any additional information needed, I will try my best.

rafucuk commented 8 months ago

image also denizen returns entity type UNKNOWN

rafucuk commented 8 months ago

Changed title because it seems it is not only with mythicmobs.

rafucuk commented 8 months ago

2895 & #2896 says fixed issues but they throwing similar errors.

AlwaysReadyWBY commented 1 month ago

Still not fixed yet. This is how modded entity types are added in mohist: And this is how CraftRegionAccessor.spawnEntity creates an entity: It seems that CraftRegionAccessor.spawnEntity simply won't work for mod entity types.

AlwaysReadyWBY commented 1 month ago

I wonder if it is possible to fix CraftRegionAccessor.spawnEntity for mod entity types with ForgeRegistries.ENTITY_TYPES.getValue(resourcelocation) .spawn(level,pos,mobspawntype); or the like?