Iris Shaders

Iris Shaders

36M Downloads

Iris: Pipeline is not initialised when rendering entities from the main menu

Sollace opened this issue ยท 4 comments

commented

What happened?

A bug happened!

Iris and Minecraft Version

1.1.0 / 1.17

Are you running Sodium along with Iris?

No

Operating System

Windows 10

What is your GPU?

Um... AMD?

Java Version

Java 16

Additional context

Currently if any mods attempt to render an entity outside of an active game (i.e. from the main menu, or sub-menu thereof) without loading a client world first, the game will imemdiately crash with a NullPointerException with the message the return value of "net.coderbot.iris.pipeline.PipelineManager.getPipeline()" is null.

I've been able to trace this problem to this line in particular:

pipeline = Iris.getPipelineManager().preparePipeline(Iris.getCurrentDimension());

Specifically that this is only being called when a world is loaded, and there doesn't appear to be any safeguards in place to protect against render calls happening prior to this event.

Now I am able to create a workaround for this, however it's messy and prone to causing more issues in the future, not to mention there could be other mods out there doing something very simliar to what we do in HDSkins that would be facing this exact same problem, so I believe it would be best if Iris were to change their code to lazy-init the pipeline PipelineManager#getPipeline rather than relying on a mixin event to ensure your system is in the correct state.

Related issue: MineLittlePony/HDSkins#45
Related commit in HDSkins: MineLittlePony/HDSkins@ee78ad6

commented

Sorry for the delay in fixing this, but this should be resolved once Iris 1.1.4 releases. Hopefully you'll be able to remove the hacky workaround (and add an appropriate breaks clause for old Iris) in future versions of HDSkins.

commented

So this actually likely is using sodium, as anything from curseforge, or modrinth has sodium bundled, try downloading a mod called indium from github actions and seeing if that solves the issue

commented

I highly doubt that this has anything to do with Sodium as the error in question is occuring in Iris' code, however I will disable my fix and test like that anyway.

commented

The error is still occurring after removing Sodium. See below:

[15:10:52] [Render thread/ERROR] (HDSkins) Exception whilst rendering player preview.
net.minecraft.util.crash.CrashException: Rendering entity in world
	at net.minecraft.client.render.entity.EntityRenderDispatcher.render(EntityRenderDispatcher.java:159) ~[minecraft-1.17-mapped-net.fabricmc.yarn-1.17+build.5-v2.jar:?]
	at com.minelittlepony.hdskins.client.dummy.PlayerPreview.renderPlayerEntity(PlayerPreview.java:265) ~[main/:?]
	at com.minelittlepony.hdskins.client.dummy.PlayerPreview.renderPlayerModel(PlayerPreview.java:194) ~[main/:?]
	at com.minelittlepony.hdskins.client.dummy.PlayerPreview.lambda$7(PlayerPreview.java:141) ~[main/:?]
	at com.minelittlepony.common.util.render.ClippingSpace.renderClipped(ClippingSpace.java:28) ~[kirin-1.9.1.jar:?]
	at com.minelittlepony.hdskins.client.dummy.PlayerPreview.renderWorldAndPlayer(PlayerPreview.java:135) ~[main/:?]
	at com.minelittlepony.hdskins.client.dummy.PlayerPreview.lambda$6(PlayerPreview.java:120) ~[main/:?]
	at com.minelittlepony.hdskins.client.dummy.DummyPlayerRenderer.wrap(DummyPlayerRenderer.java:88) [main/:?]
	at com.minelittlepony.hdskins.client.dummy.PlayerPreview.render(PlayerPreview.java:110) [main/:?]
	at com.minelittlepony.hdskins.client.gui.GuiSkins.render(GuiSkins.java:397) [main/:?]
	at net.minecraft.client.render.GameRenderer.render(GameRenderer.java:885) [minecraft-1.17-mapped-net.fabricmc.yarn-1.17+build.5-v2.jar:?]
	at net.minecraft.client.MinecraftClient.render(MinecraftClient.java:1149) [minecraft-1.17-mapped-net.fabricmc.yarn-1.17+build.5-v2.jar:?]
	at net.minecraft.client.MinecraftClient.run(MinecraftClient.java:746) [minecraft-1.17-mapped-net.fabricmc.yarn-1.17+build.5-v2.jar:?]
	at net.minecraft.client.main.Main.main(Main.java:191) [minecraft-1.17-mapped-net.fabricmc.yarn-1.17+build.5-v2.jar:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:78) ~[?:?]
	at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
	at java.lang.reflect.Method.invoke(Method.java:567) ~[?:?]
	at net.fabricmc.loader.game.MinecraftGameProvider.launch(MinecraftGameProvider.java:226) [fabric-loader-0.11.3.jar:?]
	at net.fabricmc.loader.launch.knot.Knot.launch(Knot.java:146) [fabric-loader-0.11.3.jar:?]
	at net.fabricmc.loader.launch.knot.KnotClient.main(KnotClient.java:28) [fabric-loader-0.11.3.jar:?]
	at net.fabricmc.devlaunchinjector.Main.main(Main.java:86) [dev-launch-injector-0.2.1+build.8.jar:?]
Caused by: java.lang.NullPointerException: Cannot invoke "net.coderbot.iris.pipeline.WorldRenderingPipeline.shouldDisableVanillaEntityShadows()" because the return value of "net.coderbot.iris.pipeline.PipelineManager.getPipeline()" is null
	at net.minecraft.client.render.entity.EntityRenderDispatcher.handler$zzk000$iris$maybeSuppressEntityShadow(EntityRenderDispatcher.java:528) ~[minecraft-1.17-mapped-net.fabricmc.yarn-1.17+build.5-v2.jar:?]
	at net.minecraft.client.render.entity.EntityRenderDispatcher.renderShadow(EntityRenderDispatcher.java) ~[minecraft-1.17-mapped-net.fabricmc.yarn-1.17+build.5-v2.jar:?]
	at net.minecraft.client.render.entity.EntityRenderDispatcher.render(EntityRenderDispatcher.java:141) ~[minecraft-1.17-mapped-net.fabricmc.yarn-1.17+build.5-v2.jar:?]
	... 21 more

This is fixed by adding the relevant call to client.gameRenderer.renderWorld(0, 0, new MatrixStack()); at the beginning before rendering the screen. i.e. By doing this:

    public static void initialiseWorldRenderConditions() {
        MinecraftClient client = MinecraftClient.getInstance();
        boolean inGame = client.player != null;

        try {
            if (!inGame) {
                client.player = NULL_PLAYER.get();

                if (!worldReady) {
                    worldReady = true;

                    // Hack to ensure mods like Iris don't crash the game
                    // https://github.com/IrisShaders/Iris/issues/492
                    client.world = DummyWorld.INSTANCE.get();
                    client.interactionManager = new ClientPlayerInteractionManager(client, NULL_PLAYER.get().networkHandler);
                    client.worldRenderer.setWorld(client.world);
                    client.particleManager.setWorld(client.world);
                    OutsideWorldRenderer.configure(client.world);

                    client.gameRenderer.renderWorld(0, 0, new MatrixStack());
                } else {
                    OutsideWorldRenderer.configure(DummyWorld.INSTANCE.get());
                }
            }
        } catch (Exception ignored) {} finally {
            if (!inGame) {
                client.world = null;
                client.player = null;
                client.interactionManager = null;
                client.cameraEntity = null;
            }
        }
    }