From 34e2b9f791eb8e5e5e53b14ceeb5b45f9ef89fe8 Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Sat, 6 May 2023 17:17:21 +0200 Subject: [PATCH] Fix crash when binding HTTP variable, Closes #25 --- .../org/cyclops/integratedrest/IntegratedRest.java | 12 ++++++++---- .../client/model/HttpVariableModelProviders.java | 2 +- .../integratedrest/item/HttpVariableFacade.java | 2 +- .../integratedrest/models/customoverlay/http.json | 2 +- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/cyclops/integratedrest/IntegratedRest.java b/src/main/java/org/cyclops/integratedrest/IntegratedRest.java index 2db630f0..0098ec3b 100644 --- a/src/main/java/org/cyclops/integratedrest/IntegratedRest.java +++ b/src/main/java/org/cyclops/integratedrest/IntegratedRest.java @@ -4,6 +4,7 @@ import net.minecraft.world.item.ItemStack; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; +import net.minecraftforge.client.event.ModelEvent; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.event.server.ServerStartedEvent; import net.minecraftforge.event.server.ServerStoppingEvent; @@ -55,6 +56,9 @@ public IntegratedRest() { MinecraftForge.EVENT_BUS.addListener(this::onApiServerStarted); MinecraftForge.EVENT_BUS.addListener(this::onApiServerStopping); FMLJavaModLoadingContext.get().getModEventBus().addListener(this::afterSetup); + if (MinecraftHelpers.isClientSide()) { + FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onModelLoading); + } } @Override @@ -69,10 +73,6 @@ protected void setup(FMLCommonSetupEvent event) { protected void afterSetup(FMLLoadCompleteEvent event) { IntegratedDynamics._instance.getRegistryManager().getRegistry(IVariableFacadeHandlerRegistry.class).registerHandler(HttpVariableFacadeHandler.getInstance()); - if (MinecraftHelpers.isClientSide()) { - HttpVariableModelProviders.load(); - } - RequestHandlers.load(); ValueTypeJsonHandlers.load(); @@ -83,6 +83,10 @@ protected void afterSetup(FMLLoadCompleteEvent event) { "/data/" + Reference.MOD_ID + "/info/rest_info.xml"); } + protected void onModelLoading(ModelEvent.RegisterAdditional event) { + HttpVariableModelProviders.load(); + } + /** * Register the things that are related to server starting. * @param event The Forge event required for this. diff --git a/src/main/java/org/cyclops/integratedrest/client/model/HttpVariableModelProviders.java b/src/main/java/org/cyclops/integratedrest/client/model/HttpVariableModelProviders.java index c25d8d07..c5e7e7ae 100644 --- a/src/main/java/org/cyclops/integratedrest/client/model/HttpVariableModelProviders.java +++ b/src/main/java/org/cyclops/integratedrest/client/model/HttpVariableModelProviders.java @@ -13,7 +13,7 @@ public class HttpVariableModelProviders { public static final IVariableModelProviderRegistry REGISTRY = IntegratedDynamics._instance.getRegistryManager().getRegistry(IVariableModelProviderRegistry.class); - public static final SingleVariableModelProvider HTTP = REGISTRY.addProvider(new SingleVariableModelProvider(new ResourceLocation(Reference.MOD_ID + ":customoverlay/http"))); + public static final SingleVariableModelProvider HTTP = REGISTRY.addProvider(new SingleVariableModelProvider(new ResourceLocation(Reference.MOD_ID, "customoverlay/http"))); public static void load() {} diff --git a/src/main/java/org/cyclops/integratedrest/item/HttpVariableFacade.java b/src/main/java/org/cyclops/integratedrest/item/HttpVariableFacade.java index b48aceb5..acc76869 100644 --- a/src/main/java/org/cyclops/integratedrest/item/HttpVariableFacade.java +++ b/src/main/java/org/cyclops/integratedrest/item/HttpVariableFacade.java @@ -57,7 +57,7 @@ protected Component getProxyTooltip() { @Override public void addModelOverlay(IVariableModelBaked variableModelBaked, List quads, RandomSource rand, ModelData modelData) { if(isValid()) { - quads.addAll(variableModelBaked.getSubModels(HttpVariableModelProviders.HTTP).getBakedModel().getQuads(null, null, rand)); + quads.addAll(variableModelBaked.getSubModels(HttpVariableModelProviders.HTTP).getBakedModel().getQuads(null, null, rand, modelData, null)); } } } diff --git a/src/main/resources/assets/integratedrest/models/customoverlay/http.json b/src/main/resources/assets/integratedrest/models/customoverlay/http.json index f50203dc..a43121a4 100644 --- a/src/main/resources/assets/integratedrest/models/customoverlay/http.json +++ b/src/main/resources/assets/integratedrest/models/customoverlay/http.json @@ -1,5 +1,5 @@ { - "parent": "builtin/generated", + "parent": "item/generated", "textures": { "layer0": "integratedrest:customoverlay/http" }