Skip to content

Commit

Permalink
Merge branch '1.18.2' into 1.19.1
Browse files Browse the repository at this point in the history
# Conflicts:
#	buildscript/src/main/java/Buildscript.java
#	src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java
#	src/sodiumCompatibility/java/net/coderbot/iris/compat/sodium/impl/options/IrisSodiumOptions.java
  • Loading branch information
IMS212 committed Nov 22, 2023
2 parents 3d5c6e7 + a972c91 commit 23edd63
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 151 deletions.
2 changes: 1 addition & 1 deletion buildscript/src/main/java/Buildscript.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void getModDependencies(ModDependencyCollector d) {

jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("io.github.douira:glsl-transformer:2.0.0-pre13"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME));
jij(d.addMaven(Maven.MAVEN_CENTRAL, new MavenId("org.antlr:antlr4-runtime:4.11.1"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME));
d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.19.2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME);
d.addMaven("https://api.modrinth.com/maven", new MavenId("maven.modrinth", "distanthorizons", "2.0.0-a-1.19.2"), ModDependencyFlag.COMPILE);

if (SODIUM) {
d.addMaven(FabricMaven.URL, new MavenId(FabricMaven.GROUP_ID + ".fabric-api", "fabric-api-base", "0.4.3+d7c144a8d2"), ModDependencyFlag.COMPILE, ModDependencyFlag.RUNTIME);
Expand Down
30 changes: 0 additions & 30 deletions src/main/java/net/coderbot/iris/Iris.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,6 @@ public class Iris {

private static ShaderPack currentPack;
private static String currentPackName;
private static boolean sodiumInvalid;
private static boolean hasNEC;
private static boolean sodiumInstalled;
private static boolean initialized;

private static PipelineManager pipelineManager;
Expand Down Expand Up @@ -107,21 +104,6 @@ public class Iris {
* <p>This is called right before options are loaded, so we can add key bindings here.</p>
*/
public void onEarlyInitialize() {
FabricLoader.getInstance().getModContainer("sodium").ifPresent(
modContainer -> {
sodiumInstalled = true;
String versionString = modContainer.getMetadata().getVersion().getFriendlyString();

// This makes it so that if we don't have the right version of Sodium, it will show the user a
// nice warning, and prevent them from playing the game with a wrong version of Sodium.
if (!SodiumVersionCheck.isAllowedVersion(versionString)) {
sodiumInvalid = true;
}
}
);

hasNEC = FabricLoader.getInstance().isModLoaded("notenoughcrashes");

ModContainer iris = FabricLoader.getInstance().getModContainer(MODID)
.orElseThrow(() -> new IllegalStateException("Couldn't find the mod container for Iris"));

Expand Down Expand Up @@ -727,18 +709,6 @@ public static String getFormattedVersion() {
return color + version;
}

public static boolean isSodiumInvalid() {
return sodiumInvalid;
}

public static boolean isSodiumInstalled() {
return sodiumInstalled;
}

public static boolean hasNotEnoughCrashes() {
return hasNEC;
}

public static Path getShaderpacksDirectory() {
if (shaderpacksDirectory == null) {
shaderpacksDirectory = FabricLoader.getInstance().getGameDir().resolve("shaderpacks");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,19 +59,19 @@ public abstract class MixinDebugScreenOverlay {

messages.add(3, "Direct Buffers: +" + iris$humanReadableByteCountBin(iris$directPool.getMemoryUsed()));

if (!Iris.isSodiumInstalled()) {
messages.add(3, "Native Memory: +" + iris$humanReadableByteCountBin(iris$getNativeMemoryUsage()));
}
//if (!Iris.isSodiumInstalled()) {
// messages.add(3, "Native Memory: +" + iris$humanReadableByteCountBin(iris$getNativeMemoryUsage()));
//}
}

@Inject(method = "getGameInformation", at = @At("RETURN"))
private void iris$appendShadowDebugText(CallbackInfoReturnable<List<String>> cir) {
List<String> messages = cir.getReturnValue();

if (!Iris.isSodiumInstalled() && Iris.getCurrentPack().isPresent()) {
messages.add(1, ChatFormatting.YELLOW + "[" + Iris.MODNAME + "] Sodium isn't installed; you will have poor performance.");
messages.add(2, ChatFormatting.YELLOW + "[" + Iris.MODNAME + "] Install Sodium if you want to run benchmarks or get higher FPS!");
}
//if (!Iris.isSodiumInstalled() && Iris.getCurrentPack().isPresent()) {
// messages.add(1, ChatFormatting.YELLOW + "[" + Iris.MODNAME + "] Sodium isn't installed; you will have poor performance.");
// messages.add(2, ChatFormatting.YELLOW + "[" + Iris.MODNAME + "] Install Sodium if you want to run benchmarks or get higher FPS!");
//}

Iris.getPipelineManager().getPipeline().ifPresent(pipeline -> pipeline.addDebugText(messages));
}
Expand Down
5 changes: 0 additions & 5 deletions src/main/java/net/coderbot/iris/mixin/MixinLevelRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ public class MixinLevelRenderer {
private void iris$setupPipeline(PoseStack poseStack, float tickDelta, long startTime, boolean renderBlockOutline,
Camera camera, GameRenderer gameRenderer, LightTexture lightTexture,
Matrix4f projection, CallbackInfo callback) {
if (Iris.isSodiumInvalid()) {
throw new IllegalStateException("An invalid version of Sodium is installed, and the warning screen somehow" +
" didn't work. This is a bug! Please report it to the Iris developers.");
}

IrisTimeUniforms.updateTime();
CapturedRenderingState.INSTANCE.setGbufferModelView(poseStack.last().pose());
CapturedRenderingState.INSTANCE.setGbufferProjection(projection);
Expand Down
8 changes: 0 additions & 8 deletions src/main/java/net/coderbot/iris/mixin/MixinSystemReport.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,5 @@ private void fillSystemDetails(CallbackInfo ci) {
});
return sb.toString();
});

this.setDetail("NEC status", () -> {
if (Iris.hasNotEnoughCrashes()) {
return "Has NEC: INVALID";
} else {
return "No NEC detected";
}
});
}
}
71 changes: 4 additions & 67 deletions src/main/java/net/coderbot/iris/mixin/MixinTitleScreen.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,14 @@
package net.coderbot.iris.mixin;

import com.google.common.collect.ImmutableList;
import net.coderbot.iris.Iris;
import net.coderbot.iris.compat.sodium.SodiumVersionCheck;
import net.fabricmc.loader.api.FabricLoader;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.client.GraphicsStatus;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.AlertScreen;
import net.minecraft.client.gui.screens.ConfirmScreen;
import net.minecraft.client.gui.screens.PopupScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;

import net.minecraft.network.chat.Component;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.net.URI;
import java.net.URISyntaxException;

@Mixin(TitleScreen.class)
public class MixinTitleScreen extends Screen {
private static boolean iris$hasFirstInit;
Expand All @@ -32,61 +18,12 @@ protected MixinTitleScreen(Component arg) {
}

@Inject(method = "init", at = @At("RETURN"))
public void iris$showSodiumIncompatScreen(CallbackInfo ci) {
if (iris$hasFirstInit) return;

String reason;

if (!Iris.isSodiumInstalled() && !FabricLoader.getInstance().isDevelopmentEnvironment()) {
reason = "iris.sodium.failure.reason.notFound";
} else if (Iris.isSodiumInvalid()) {
reason = "iris.sodium.failure.reason.incompatible";
} else if (Iris.hasNotEnoughCrashes()) {
Minecraft.getInstance().setScreen(new ConfirmScreen(
bool -> {
if (bool) {
if (!iris$hasFirstInit) {
Iris.onLoadingComplete();
}

iris$hasFirstInit = true;

Minecraft.getInstance().setScreen(this);
} else {
Minecraft.getInstance().stop();
}
},
Component.translatable("iris.nec.failure.title", Iris.MODNAME).withStyle(ChatFormatting.BOLD, ChatFormatting.RED),
Component.translatable("iris.nec.failure.description"),
Component.translatable("options.graphics.warning.accept").withStyle(ChatFormatting.RED),
Component.translatable("menu.quit").withStyle(ChatFormatting.BOLD)));
return;
} else {
if (!iris$hasFirstInit) {
Iris.onLoadingComplete();
}

iris$hasFirstInit = true;

return;
public void iris$firstInit(CallbackInfo ci) {
if (!iris$hasFirstInit) {
Iris.onLoadingComplete();
}

iris$hasFirstInit = true;

Minecraft.getInstance().setScreen(new ConfirmScreen(
(boolean accepted) -> {
if (accepted) {
try {
Util.getPlatform().openUri(new URI(SodiumVersionCheck.getDownloadLink()));
} catch (URISyntaxException e) {
throw new IllegalStateException(e);
}
} else {
Minecraft.getInstance().stop();
}
},
Component.translatable("iris.sodium.failure.title").withStyle(ChatFormatting.RED),
Component.translatable(reason),
Component.translatable("iris.sodium.failure.download"),
Component.translatable("menu.quit")));
}
}
27 changes: 0 additions & 27 deletions src/main/java/net/coderbot/iris/mixin/gui/MixinGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,6 @@ public class MixinGui {
}
}

// TODO: Move this to a more appropriate mixin
@Inject(method = "render", at = @At("RETURN"))
public void iris$displayBigSodiumWarning(PoseStack poseStack, float tickDelta, CallbackInfo ci) {
if (Iris.isSodiumInstalled()
|| Minecraft.getInstance().options.renderDebug
|| !Iris.getCurrentPack().isPresent()) {
return;
}

Font font = Minecraft.getInstance().font;

List<String> warningLines = new ArrayList<>();
warningLines.add("[" + Iris.MODNAME + "] Sodium isn't installed; you will have poor performance.");
warningLines.add("[" + Iris.MODNAME + "] Install Sodium if you want to run benchmarks or get higher FPS!");

for (int i = 0; i < warningLines.size(); ++i) {
String string = warningLines.get(i);

final int lineHeight = 9;
final int lineWidth = font.width(string);
final int y = 2 + lineHeight * i;

GuiComponent.fill(poseStack, 1, y - 1, 2 + lineWidth + 1, y + lineHeight - 1, 0x9050504E);
font.draw(poseStack, string, 2.0F, y, 0xFFFF55);
}
}

@Inject(method = "renderVignette", at = @At("HEAD"), cancellable = true)
private void iris$disableVignetteRendering(Entity entity, CallbackInfo ci) {
WorldRenderingPipeline pipeline = Iris.getPipelineManager().getPipelineNullable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ public static void transform(
VanillaParameters parameters) {

if (parameters.inputs.hasOverlay()) {
AttributeTransformer.patchOverlayColor(t, tree, root, parameters);
if (!parameters.inputs.isText()) {
AttributeTransformer.patchOverlayColor(t, tree, root, parameters);
}
AttributeTransformer.patchEntityId(t, tree, root, parameters);
}

CommonTransformer.transform(t, tree, root, parameters, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ private ShaderProperties() {
// TODO: Is there a better solution than having ShaderPack pass a root path to ShaderProperties to be able to read textures?
public ShaderProperties(String contents, ShaderPackOptions shaderPackOptions, Iterable<StringPair> environmentDefines, Iterable<StringPair> replacements) {
for (StringPair pair : replacements) {
contents = contents.replace(pair.getKey(), pair.getValue());
contents = contents.replaceAll("\\b" + pair.getKey() + "\\b", pair.getValue());
}

String preprocessedContents = PropertiesPreprocessor.preprocessSource(contents, shaderPackOptions, environmentDefines);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void addVariable(String type, String name, String expression, boolean isU
ExpressionElement ast = Parser.parse(expression, IrisOptions.options);
variables.put(name, new Variable(parsedType, name, ast, isUniform));
} catch (Exception e) {
Iris.logger.warn("Failed to parse custom variable/uniform", e);
Iris.logger.warn("Failed to parse custom variable/uniform " + name + " with expression " + expression, e);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"schemaVersion": 1,
"id": "iris",
"version": "1.6.10-development-environment",
"version": "1.6.11-development-environment",

"name": "Iris",
"description": "A modern shaders mod for Minecraft intended to be compatible with existing OptiFine shader packs",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static OptionImpl<Options, Integer> createMaxShadowDistanceSlider(Minecra
OptionImpl<Options, Integer> maxShadowDistanceSlider = OptionImpl.createBuilder(int.class, vanillaOpts)
.setName(Component.translatable("options.iris.shadowDistance"))
.setTooltip(Component.translatable("options.iris.shadowDistance.sodium_tooltip"))
.setControl(option -> new SliderControl(option, 0, 32, 1, ControlValueFormatter.quantityOrDisabled("Chunks", "Disabled")))
.setControl(option -> new SliderControl(option, 0, 32, 1, translateVariableOrDisabled("options.chunks", "Disabled")))
.setBinding((options, value) -> {
IrisVideoSettings.shadowDistance = value;
try {
Expand Down Expand Up @@ -64,13 +64,19 @@ public static OptionImpl<Options, ColorSpace> createColorSpaceButton(MinecraftOp
return colorSpace;
}

static ControlValueFormatter translateVariableOrDisabled(String key, String disabled) {
return (v) -> {
return v == 0 ? disabled : (Component.translatable(key, v)).getString();
};
}

public static OptionImpl<Options, SupportedGraphicsMode> createLimitedVideoSettingsButton(MinecraftOptionsStorage vanillaOpts) {
return OptionImpl.createBuilder(SupportedGraphicsMode.class, vanillaOpts)
.setName(Component.translatable("options.graphics"))
// TODO: State that Fabulous Graphics is incompatible with Shader Packs in the tooltip
.setTooltip(Component.translatable("sodium.options.graphics_quality.tooltip"))
.setControl(option -> new CyclingControl<>(option, SupportedGraphicsMode.class,
new Component[] { Component.literal("Fast"), Component.literal("Fancy") }))
new Component[] { Component.translatable("options.graphics.fast"), Component.translatable("options.graphics.fancy") }))
.setBinding(
(opts, value) -> opts.graphicsMode().set(value.toVanilla()),
opts -> SupportedGraphicsMode.fromVanilla(opts.graphicsMode().get()))
Expand Down

0 comments on commit 23edd63

Please sign in to comment.