Skip to content

Commit

Permalink
Fix emissive texture Z-fighting with shaders, Fix crashing without Iris
Browse files Browse the repository at this point in the history
  • Loading branch information
Motschen committed Jan 2, 2022
1 parent 8e86674 commit c0abca5
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 32 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/use
minecraft_version=1.18.1
yarn_mappings=1.18.1+build.12
yarn_mappings=1.18.1+build.14
loader_version=0.12.12

# Mod Properties
mod_version = 1.0.0-pre3
mod_version = 1.0.0-pre4
maven_group = net.puzzlemc
archives_base_name = puzzle

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ private void onRender(T entity, float yaw, float tickDelta, MatrixStack matrices
if (PuzzleConfig.emissiveTextures && PuzzleEmissiveTextures.emissiveTextures.containsKey(this.getTexture(entity))) {
VertexConsumer vertexConsumer = vertexConsumers.getBuffer(RenderLayer.getBeaconBeam(PuzzleEmissiveTextures.emissiveTextures.get(this.getTexture(entity)),true));

matrices.scale(1.015f,1.015f,1.015f);
this.getModel().render(matrices, vertexConsumer, 15728640, OverlayTexture.DEFAULT_UV, 1.0F, 1.0F, 1.0F, 1.0F);
matrices.scale(1f,1f,1f);
}
}
}
42 changes: 42 additions & 0 deletions puzzle-gui/src/main/java/net/puzzlemc/gui/IrisCompat.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
package net.puzzlemc.gui;

import net.coderbot.iris.Iris;
import net.coderbot.iris.config.IrisConfig;
import net.coderbot.iris.gui.screen.ShaderPackScreen;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.client.MinecraftClient;
import net.minecraft.text.Text;
import net.minecraft.text.TranslatableText;
import net.puzzlemc.gui.screen.widget.PuzzleWidget;

import java.io.IOException;

public class IrisCompat {
public static void init() {
if (FabricLoader.getInstance().isModLoaded("iris")) {
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.of("Iris")));
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.of("Enable Shaders"), (button) -> button.setMessage(Iris.getIrisConfig().areShadersEnabled() ? PuzzleClient.YES : PuzzleClient.NO), (button) -> {
IrisConfig irisConfig = Iris.getIrisConfig();
irisConfig.setShadersEnabled(!irisConfig.areShadersEnabled());
try {
Iris.getIrisConfig().save();
} catch (IOException e) {
Iris.logger.error("Error saving configuration file!");
Iris.logger.catching(e);
}

try {
Iris.reload();
} catch (IOException e) {
Iris.logger.error("Error reloading shader pack while applying changes!");
Iris.logger.catching(e);
}
}));
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(new TranslatableText("options.iris.shaderPackSelection.title"), (button) -> button.setMessage(Text.of("OPEN")), (button) -> {
MinecraftClient client = MinecraftClient.getInstance();
ShaderPackScreen shaderPackPage = new ShaderPackScreen(client.currentScreen);
client.setScreen(shaderPackPage);
}));
}
}
}
30 changes: 1 addition & 29 deletions puzzle-gui/src/main/java/net/puzzlemc/gui/PuzzleClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,9 @@
import dev.lambdaurora.lambdynlights.LambDynLights;
import eu.midnightdust.cullleaves.config.CullLeavesConfig;
import me.pepperbell.continuity.client.config.ContinuityConfig;
import net.coderbot.iris.Iris;
import net.coderbot.iris.config.IrisConfig;
import net.coderbot.iris.gui.screen.ShaderPackScreen;
import net.dorianpb.cem.internal.config.CemConfig;
import net.dorianpb.cem.internal.config.CemConfigFairy;
import net.dorianpb.cem.internal.config.CemOptions;
import net.minecraft.client.gui.screen.ScreenTexts;
import net.puzzlemc.core.config.PuzzleConfig;
import net.puzzlemc.gui.mixin.CemConfigAccessor;
import net.puzzlemc.gui.screen.widget.PuzzleWidget;
Expand All @@ -26,8 +22,6 @@
import shcm.shsupercm.fabric.citresewn.CITResewn;
import shcm.shsupercm.fabric.citresewn.config.CITResewnConfig;

import java.io.IOException;

public class PuzzleClient implements ClientModInitializer {

public final static String id = "puzzle";
Expand Down Expand Up @@ -90,29 +84,7 @@ public void onInitializeClient() {
}));
}
if (FabricLoader.getInstance().isModLoaded("iris")) {
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.of("Iris")));
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(Text.of("Enable Shaders"), (button) -> button.setMessage(Iris.getIrisConfig().areShadersEnabled() ? YES : NO), (button) -> {
IrisConfig irisConfig = Iris.getIrisConfig();
irisConfig.setShadersEnabled(!irisConfig.areShadersEnabled());
try {
Iris.getIrisConfig().save();
} catch (IOException var6) {
Iris.logger.error("Error saving configuration file!");
Iris.logger.catching(var6);
}

try {
Iris.reload();
} catch (IOException var5) {
Iris.logger.error("Error reloading shader pack while applying changes!");
Iris.logger.catching(var5);
}
}));
PuzzleApi.addToGraphicsOptions(new PuzzleWidget(new TranslatableText("options.iris.shaderPackSelection.title"), (button) -> button.setMessage(Text.of("OPEN")), (button) -> {
MinecraftClient client = MinecraftClient.getInstance();
ShaderPackScreen shaderPackPage = new ShaderPackScreen(client.currentScreen);
client.setScreen(shaderPackPage);
}));
IrisCompat.init();
}

if (FabricLoader.getInstance().isModLoaded("continuity")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private void modifyBackgroundColor3(MatrixStack matrices, int mouseX, int mouseY
GlStateManager._clear(16384, MinecraftClient.IS_SYSTEM_MAC);
}
}
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableBlend()V", shift = At.Shift.AFTER))
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;enableBlend()V", shift = At.Shift.AFTER), remap = false)
private void disableBlend(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (PuzzleConfig.disableSplashScreenBlend) RenderSystem.disableBlend();
}
Expand Down

0 comments on commit c0abca5

Please sign in to comment.