mirror of
https://github.com/GTNewHorizons/Botania.git
synced 2026-11-17 02:45:13 +00:00
Check if models were registered to avoid misleading NPE crashes
This happens if an error occurs earlier, causing Forge to start aborting loading. Not all things are stopped and not all exceptions are caught gracefully, and if something throws one that crashes the game, a crash report will be generated instead of an error screen appearing.
This commit is contained in:
1 parent
4bb46ef9ec
commit
76f116dc90
2 files changed
+10
No files matched your search
@@ -31,6 +31,7 @@ import vazkii.botania.client.model.LexiconModel;
|
||||
import vazkii.botania.client.model.PlatformModel;
|
||||
import vazkii.botania.client.render.tile.RenderTileCorporeaCrystalCube;
|
||||
import vazkii.botania.client.render.tile.RenderTilePump;
|
||||
import vazkii.botania.common.Botania;
|
||||
import vazkii.botania.common.item.ModItems;
|
||||
import vazkii.botania.common.item.equipment.bauble.ItemFlightTiara;
|
||||
import vazkii.botania.common.item.relic.ItemKingKey;
|
||||
@@ -90,6 +91,11 @@ public class MiscellaneousIcons {
|
||||
|
||||
@SubscribeEvent
|
||||
public void onModelBake(ModelBakeEvent evt) {
|
||||
if (!ModelHandler.registeredModels) {
|
||||
Botania.LOGGER.error("Additional models failed to register! Aborting baking models to avoid early crashing.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Water bowl
|
||||
ModelDynBucket bowl = new ModelDynBucket(prefix("items/waterbowl_base"), prefix("items/waterbowl_fluid"), prefix("items/waterbowl_cover"), Fluids.WATER, false, true);
|
||||
IModelState transform = ForgeBlockStateV1.Transforms.get("forge:default-item").get();
|
||||
|
||||
@@ -78,8 +78,12 @@ import static vazkii.botania.common.lib.ResourceLocationHelper.prefix;
|
||||
|
||||
@Mod.EventBusSubscriber(value = Dist.CLIENT, modid = LibMisc.MOD_ID, bus = Mod.EventBusSubscriber.Bus.MOD)
|
||||
public final class ModelHandler {
|
||||
static boolean registeredModels = false;
|
||||
|
||||
@SubscribeEvent
|
||||
public static void registerModels(ModelRegistryEvent evt) {
|
||||
registeredModels = true;
|
||||
|
||||
ModelLoaderRegistry.registerLoader(FloatingFlowerModel.Loader.INSTANCE);
|
||||
ModelLoader.addSpecialModel(new ModelResourceLocation(LibMisc.MOD_ID + ":mana_gun_clip", "inventory"));
|
||||
ModelLoader.addSpecialModel(new ModelResourceLocation(LibMisc.MOD_ID + ":desu_gun", "inventory"));
|
||||
|
||||
Reference in new issue
Block a user