Botania

Botania

133M Downloads

Getting Brew registry from BotaniaBrews crashes loading

Prunoideae opened this issue ยท 0 comments

commented

Mod Loader

Forge

Minecraft Version

1.19.2

Botania version

1.19.2-436

Modloader version

43.1.65

Modpack info

No response

The latest.log file

https://pastebin.com/5bpFHcr9

Issue description

In 1.19.2, Forge changed getEffect in MobEffectInstance, which now checks if an effect in MobEffectInstance is registered or not, and when not registered, it throws an exception and crashes the loading.

    public MobEffect getEffect() {
        return this.effect == null ? null : (MobEffect)ForgeRegistries.MOB_EFFECTS.getDelegateOrThrow(this.effect).get();
    }

This will crash the game if the brew registry is retrieved before Botania's own effects are registered. As in BotaniaBrews :

public class BotaniaBrews {

	public static final Registry<Brew> registry = XplatAbstractions.INSTANCE.createBrewRegistry();
        //...
        public static final Brew allure = make(2000, new MobEffectInstance(BotaniaMobEffects.allure, 4800, 0));
	public static final Brew soulCross = make(10000, new MobEffectInstance(BotaniaMobEffects.soulCross, 1800, 0));
        //...
}

Botania's effects are not registered at this time if the class is loaded earlier than BotaniaMobEffects, which means that mods must have their brew registry event fired after Botania's registry event to correctly register brews, and it's hard to ensure such a thing.

It would be better to move the registry to somewhere else, or change the createBrewRegistry to getOrCreateBrewRegistry so mods can get the brew registry without touching BotaniaBrews.

Steps to reproduce

  1. Get ResourceKey of Brew registry by calling BotaniaBrews.registry.key() somewhere.

Other information

No response