Skip to content

Commit

Permalink
Fix crash when binding HTTP variable, Closes #25
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed May 6, 2023
1 parent 9292b54 commit 34e2b9f
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
12 changes: 8 additions & 4 deletions src/main/java/org/cyclops/integratedrest/IntegratedRest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -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();

Expand All @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ protected Component getProxyTooltip() {
@Override
public void addModelOverlay(IVariableModelBaked variableModelBaked, List<BakedQuad> 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));
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"parent": "builtin/generated",
"parent": "item/generated",
"textures": {
"layer0": "integratedrest:customoverlay/http"
}
Expand Down

0 comments on commit 34e2b9f

Please sign in to comment.