Skip to content

Commit

Permalink
Work around a crash when the client abruptly exits a world without co…
Browse files Browse the repository at this point in the history
…mpleting world rendering

This is generally caused by NotEnoughCrashes
  • Loading branch information
coderbot16 committed Mar 7, 2021
1 parent a0a8542 commit fa7b293
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/main/java/net/coderbot/iris/pipeline/ShaderPipeline.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,18 @@ public ShaderPipeline(ProgramSet programs) {
this.compositeRenderer = new CompositeRenderer(programs, renderTargets, shadowMapRenderer);
}

private void checkWorld() {
// If we're not in a world, then obviously we cannot possibly be rendering a world.
if (MinecraftClient.getInstance().world == null) {
isRenderingWorld = false;
programStackLog.clear();
programStack.clear();
}
}

public void pushProgram(GbufferProgram program) {
checkWorld();

if (!isRenderingWorld) {
// don't mess with non-world rendering
return;
Expand All @@ -125,6 +136,8 @@ public void pushProgram(GbufferProgram program) {
}

public void popProgram(GbufferProgram expected) {
checkWorld();

if (!isRenderingWorld) {
// don't mess with non-world rendering
return;
Expand Down Expand Up @@ -444,6 +457,12 @@ public static GbufferProgram getProgramForSheet(ParticleTextureSheet sheet) {
public void beginWorldRender() {
isRenderingWorld = true;

checkWorld();

if (!isRenderingWorld) {
Iris.logger.warn("beginWorldRender was called but we are not currently rendering a world?");
}

if (!programStack.isEmpty()) {
throw new IllegalStateException("Program stack before the start of rendering, something has gone very wrong!");
}
Expand All @@ -454,6 +473,12 @@ public void beginWorldRender() {
}

public void finalizeWorldRendering() {
checkWorld();

if (!isRenderingWorld) {
Iris.logger.warn("finalizeWorldRendering was called but we are not currently rendering a world?");
}

popProgram(GbufferProgram.BASIC);

if (!programStack.isEmpty()) {
Expand Down

0 comments on commit fa7b293

Please sign in to comment.