MinecraftModDevelopmentMods / Extra-Golems

Forge mod that adds dozens of golems to Minecraft
Other
19 stars 6 forks source link

Crash w/ Apotheosis #109

Closed Shadows-of-Fire closed 1 year ago

Shadows-of-Fire commented 1 year ago

https://github.com/Shadows-of-Fire/Apotheosis/issues/685

Apotheosis applies a number of stats to all living entities via EntityAttributeModificationEvent, but I've been reported missing attribute crashes from this mod. That particular crash can only happen if the entity type in question does not have attributes setup properly via EntityAttributeCreationEvent.

Interestingly, I see you have a handler for that event here https://github.com/MinecraftModDevelopmentMods/Extra-Golems/blob/master-1.19/src/main/java/com/mcmoddev/golems/EGRegistry.java#L93

and I was able to debug that my event handler does fire for that entity type. which means that I successfully add my attributes to golems:golem

The code responsible for that is here https://github.com/Shadows-of-Fire/Apotheosis/blob/1.19/src/main/java/shadows/apotheosis/adventure/AdventureModule.java#L227

Yet despite all that, this crash still occurs, which means that the attribute does not actually get applied to the entity. I'm not sure what the cause of that might be, but it has to be something with the golem entity and the attribute handling.

skyjay1 commented 1 year ago

Thanks for the detailed information. I remembered that golem attributes are re-created based on the datapack here: https://github.com/MinecraftModDevelopmentMods/Extra-Golems/blob/master-1.19/src/main/java/com/mcmoddev/golems/entity/GolemBase.java#L142

This is necessary to update health, attack damage, armor, etc. for the different golems (since all golems share the same entity type, they don't actually use the ones registered in EntityAttributeCreationEvent)

To fix this, I will likely need to fire EntityAttributeModificationEvent somewhere and store the results, but I'm not sure if that is allowed by Forge.

Shadows-of-Fire commented 1 year ago

I think it would be fine if you refired it with only your golem entity types and only used the results of your refiring for the golem attributes

Shadows-of-Fire commented 1 year ago

However, you mentioned a datapack, and this is a mod bus event. So you may not be able to fire it that late.

skyjay1 commented 1 year ago

If not, maybe I can find a way to copy the registered attributes and merge them with the datapack values.

skyjay1 commented 1 year ago

Does Apotheosis alone use the attributes? Or do I need to download one of the modules to test my fix?

Shadows-of-Fire commented 1 year ago

There is only one Apotheosis - the modules are configurable internal submods.

skyjay1 commented 1 year ago

Fixed in Extra Golems 19.2.4 (pending approval on CF). Thank you for the help :)

PhweeDev commented 1 year ago

I should note this also happened with 1.18.2 and Apotheosis. Will you also be making a patch for 1.18.2 to fix the issue there?