commit f7ff171083aa31999cdecdd90429809fb42a02e4
parent 68226e4ba364f3c799b8607d99d01b847dc9ed44
Author: Amb0s <ambos@disroot.org>
Date: Mon, 12 Feb 2024 16:07:51 +0100
Added config support and changed formatting
Diffstat:
12 files changed, 157 insertions(+), 65 deletions(-)
diff --git a/build.gradle b/build.gradle
@@ -81,6 +81,10 @@ dependencies {
modRuntimeOnly "objects:client:43db9b498cb67058d2e12d394e6507722e71bb45" // https://piston-data.mojang.com/v1/objects/43db9b498cb67058d2e12d394e6507722e71bb45/client.jar
modImplementation "fabric-loader:fabric-loader:${project.loader_version}"
+ // Helper library
+ // If you do not need Halplibe you can comment this line out or delete this line
+ modImplementation "com.github.Turnip-Labs:bta-halplibe:${project.halplibe_version}"
+
modImplementation "ModMenu:ModMenu:2.0.3"
implementation "org.slf4j:slf4j-api:1.8.0-beta4"
diff --git a/gradle.properties b/gradle.properties
@@ -6,6 +6,9 @@ bta_version=7.1-pre1a
# Loader
loader_version=0.14.19-babric.3-bta
+# HalpLibe
+halplibe_version=3.3.5
+
# Mod
mod_version=5.0.0
mod_group=ambos
diff --git a/src/main/java/ambos/vanillafixes/VanillaFixes.java b/src/main/java/ambos/vanillafixes/VanillaFixes.java
@@ -1,6 +1,9 @@
package ambos.vanillafixes;
import net.fabricmc.api.ModInitializer;
+import turniplabs.halplibe.util.TomlConfigHandler;
+import turniplabs.halplibe.util.toml.Toml;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -8,6 +11,33 @@ public class VanillaFixes implements ModInitializer {
public static final String MOD_ID = "vanillafixes";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
+ public static final TomlConfigHandler CONFIG;
+ public static final boolean JITERRING;
+ public static final boolean FOG;
+ public static final boolean F3_MENU;
+ public static final boolean MOD_RESOURCES_PATH;
+ public static final boolean SIMPLE_MAIN_MENU;
+ public static final boolean IMPROVED_TOOLTIP;
+ static {
+ Toml toml = new Toml();
+ toml.addCategory("Fixes");
+ toml.addEntry("Fixes.jittering", "Fixes jitter at high coordinates", true);
+ toml.addEntry("Fixes.fog", "Properly disables fog and fix underwater rendering", true);
+ toml.addEntry("Fixes.mod_resources_path", "Changes mod resources path to '.minecraft/resources/mod'", true);
+ toml.addCategory("Settings");
+ toml.addEntry("Settings.f3_menu", "Deobfuscates debug menu", true);
+ toml.addEntry("Settings.simple_main_menu", "Removes buttons, links and text on the main menu", true);
+ toml.addEntry("Settings.improved_tooltip", "Shows item durability and/or damage value in the tooltip", true);
+
+ CONFIG = new TomlConfigHandler(MOD_ID, toml);
+ JITERRING = CONFIG.getBoolean("Fixes.jittering");
+ FOG = CONFIG.getBoolean("Fixes.fog");
+ MOD_RESOURCES_PATH = CONFIG.getBoolean("Fixes.mod_resources_path");
+ F3_MENU = CONFIG.getBoolean("Settings.f3_menu");
+ SIMPLE_MAIN_MENU = CONFIG.getBoolean("Settings.simple_main_menu");
+ IMPROVED_TOOLTIP = CONFIG.getBoolean("Settings.improved_tooltip");
+ }
+
@Override
public void onInitialize() {
LOGGER.info("Vanilla Fixes initialized");
diff --git a/src/main/java/ambos/vanillafixes/mixin/ChunkProviderStaticMixin.java b/src/main/java/ambos/vanillafixes/mixin/ChunkProviderStaticMixin.java
@@ -5,10 +5,16 @@ import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
+import ambos.vanillafixes.VanillaFixes;
+
@Mixin(value = ChunkProviderStatic.class, remap = false)
final class ChunkProviderStaticMixin {
@ModifyConstant(method = "getInfoString", constant = @Constant(stringValue = "ChunkCache: "))
private String reformatChunkCache(String value) {
- return "Chunk Cache: ";
+ if (VanillaFixes.F3_MENU) {
+ return "Chunk Cache: ";
+ }
+
+ return value;
}
}
diff --git a/src/main/java/ambos/vanillafixes/mixin/DisplayListMixin.java b/src/main/java/ambos/vanillafixes/mixin/DisplayListMixin.java
@@ -9,6 +9,8 @@ import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
+import ambos.vanillafixes.VanillaFixes;
+
@Mixin(value = DisplayList.class, remap = false)
final class DisplayListMixin {
private double offsetX;
@@ -26,17 +28,20 @@ final class DisplayListMixin {
@Inject(method = "setToPos", at = @At("RETURN"), require = 0)
private void onSetToPos(int blockX, int blockY, int blockZ, double offsetX, double offsetY, double offsetZ,
- CallbackInfo ci) {
- this.offsetX = offsetX;
- this.offsetY = offsetY;
- this.offsetZ = offsetZ;
+ CallbackInfo ci) {
+ if (VanillaFixes.JITERRING) {
+ this.offsetX = offsetX;
+ this.offsetY = offsetY;
+ this.offsetZ = offsetZ;
+ }
}
- @ModifyArgs(method = "call", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glTranslatef(FFF)V"),
- require = 0)
+ @ModifyArgs(method = "call", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glTranslatef(FFF)V"), require = 0)
private void changeType(Args args) {
- args.set(0, (float) ((double) this.posX - this.offsetX));
- args.set(1, (float) ((double) this.posY - this.offsetY));
- args.set(2, (float) ((double) this.posZ - this.offsetZ));
+ if (VanillaFixes.JITERRING) {
+ args.set(0, (float) ((double) this.posX - this.offsetX));
+ args.set(1, (float) ((double) this.posY - this.offsetY));
+ args.set(2, (float) ((double) this.posZ - this.offsetZ));
+ }
}
}
diff --git a/src/main/java/ambos/vanillafixes/mixin/FogManagerMixin.java b/src/main/java/ambos/vanillafixes/mixin/FogManagerMixin.java
@@ -10,27 +10,29 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
+import ambos.vanillafixes.VanillaFixes;
+
@Mixin(value = FogManager.class, remap = false)
public class FogManagerMixin {
@Shadow
private Minecraft mc;
- @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE",
- target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V"), require = 0)
+ @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V"), require = 0)
private void changeFogStart(Args args) {
- if (!(Boolean)this.mc.gameSettings.fog.value
- && args.get(0).equals(2915) // https://legacy.lwjgl.org/javadoc/constant-values.html
- && this.mc.gameSettings.renderDistance.value.chunks == RenderDistance.EXTREME.chunks) {
+ if (VanillaFixes.FOG
+ && !(Boolean) this.mc.gameSettings.fog.value
+ && args.get(0).equals(2915) // https://legacy.lwjgl.org/javadoc/constant-values.html
+ && this.mc.gameSettings.renderDistance.value.chunks == RenderDistance.EXTREME.chunks) {
args.set(1, Float.valueOf(RenderDistance.EXTREME.chunks * 12));
}
}
- @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE",
- target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V"), require = 0)
+ @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V"), require = 0)
private void changeFogEnd(Args args) {
- if (!(Boolean)this.mc.gameSettings.fog.value
- && args.get(0).equals(2916) // https://legacy.lwjgl.org/javadoc/constant-values.html
- && this.mc.gameSettings.renderDistance.value.chunks == RenderDistance.EXTREME.chunks) {
+ if (VanillaFixes.FOG
+ && !(Boolean) this.mc.gameSettings.fog.value
+ && args.get(0).equals(2916) // https://legacy.lwjgl.org/javadoc/constant-values.html
+ && this.mc.gameSettings.renderDistance.value.chunks == RenderDistance.EXTREME.chunks) {
args.set(1, Float.valueOf(RenderDistance.EXTREME.chunks * 16));
}
}
diff --git a/src/main/java/ambos/vanillafixes/mixin/GuiIngameMixin.java b/src/main/java/ambos/vanillafixes/mixin/GuiIngameMixin.java
@@ -4,15 +4,25 @@ import net.minecraft.client.gui.GuiIngame;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.*;
+import ambos.vanillafixes.VanillaFixes;
+
@Mixin(value = GuiIngame.class, remap = false)
final class GuiIngameMixin {
@ModifyConstant(method = "renderGameOverlay", constant = @Constant(stringValue = "s I: "))
private String deobfuscateWeatherIntensity(String value) {
- return "s, Intensity: ";
+ if (VanillaFixes.F3_MENU) {
+ return "s, Intensity: ";
+ }
+
+ return value;
}
@ModifyConstant(method = "renderGameOverlay", constant = @Constant(stringValue = "% P: "))
private String deobfuscateWeatherPower(String value) {
- return "%, Power: ";
+ if (VanillaFixes.F3_MENU) {
+ return "%, Power: ";
+ }
+
+ return value;
}
}
diff --git a/src/main/java/ambos/vanillafixes/mixin/GuiMainMenuMixin.java b/src/main/java/ambos/vanillafixes/mixin/GuiMainMenuMixin.java
@@ -7,24 +7,29 @@ import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
+import ambos.vanillafixes.VanillaFixes;
+
@Mixin(value = GuiMainMenu.class, remap = false)
final class GuiMainMenuMixin extends GuiScreen {
@Inject(method = "init", at = @At("RETURN"), require = 0)
private void removeLinks(CallbackInfo ci) {
- controlList.removeIf(button ->
- button.id == 5 /* Discord */ || button.id == 6 /* Minecraft Forums */ ||
- button.id == 7 /* Youtube */);
+ if (VanillaFixes.SIMPLE_MAIN_MENU) {
+ controlList.removeIf(button -> button.id == 5 /* Discord */ || button.id == 6 /* Minecraft Forums */ ||
+ button.id == 7 /* Youtube */);
+ }
}
@Inject(method = "init", at = @At("RETURN"), require = 0)
private void removeButtons(CallbackInfo ci) {
- controlList.removeIf(button -> button.id == 8 /* Languages */);
+ if (VanillaFixes.SIMPLE_MAIN_MENU) {
+ controlList.removeIf(button -> button.id == 8 /* Languages */);
+ }
}
- @ModifyArgs(method = "drawScreen", at = @At(value = "INVOKE",
- target = "Lnet/minecraft/client/render/FontRenderer;drawCenteredString(Ljava/lang/String;III)V",
- ordinal = 0), require = 0)
+ @ModifyArgs(method = "drawScreen", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/render/FontRenderer;drawCenteredString(Ljava/lang/String;III)V", ordinal = 0), require = 0)
private void removeDownloadingResourcesString(Args args) {
- args.set(0, "");
+ if (VanillaFixes.SIMPLE_MAIN_MENU) {
+ args.set(0, "");
+ }
}
}
diff --git a/src/main/java/ambos/vanillafixes/mixin/GuiTooltipMixin.java b/src/main/java/ambos/vanillafixes/mixin/GuiTooltipMixin.java
@@ -1,5 +1,13 @@
package ambos.vanillafixes.mixin;
+import org.spongepowered.asm.mixin.Mixin;
+import org.spongepowered.asm.mixin.Shadow;
+import org.spongepowered.asm.mixin.injection.At;
+import org.spongepowered.asm.mixin.injection.Inject;
+import org.spongepowered.asm.mixin.injection.Redirect;
+import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+
+import ambos.vanillafixes.VanillaFixes;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiTooltip;
@@ -9,12 +17,6 @@ import net.minecraft.core.item.tool.ItemToolSword;
import net.minecraft.core.net.command.TextFormatting;
import net.minecraft.core.player.inventory.InventoryPlayer;
import net.minecraft.core.player.inventory.slot.Slot;
-import org.spongepowered.asm.mixin.Mixin;
-import org.spongepowered.asm.mixin.Shadow;
-import org.spongepowered.asm.mixin.injection.At;
-import org.spongepowered.asm.mixin.injection.Inject;
-import org.spongepowered.asm.mixin.injection.Redirect;
-import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
@Mixin(value = GuiTooltip.class, remap = false)
final class GuiTooltipMixin extends Gui {
@@ -25,15 +27,20 @@ final class GuiTooltipMixin extends Gui {
@Inject(method = "getTooltipText(Lnet/minecraft/core/item/ItemStack;ZLnet/minecraft/core/player/inventory/slot/Slot;)Ljava/lang/String;", at = @At("HEAD"))
private void getSlot(ItemStack itemStack, boolean showDescription, Slot slot, CallbackInfoReturnable<Object> cir) {
- // Stores hovered inventory slot.
- hoveredSlot = slot;
+ if (VanillaFixes.IMPROVED_TOOLTIP) {
+ // Stores hovered inventory slot.
+ hoveredSlot = slot;
+ }
}
- @Redirect(method = "getTooltipText(Lnet/minecraft/core/item/ItemStack;ZLnet/minecraft/core/player/inventory/slot/Slot;)Ljava/lang/String;", at = @At(value = "INVOKE",
- target = "Ljava/lang/StringBuilder;append(Ljava/lang/String;)Ljava/lang/StringBuilder;", ordinal = 0))
+ @Redirect(method = "getTooltipText(Lnet/minecraft/core/item/ItemStack;ZLnet/minecraft/core/player/inventory/slot/Slot;)Ljava/lang/String;", at = @At(value = "INVOKE", target = "Ljava/lang/StringBuilder;append(Ljava/lang/String;)Ljava/lang/StringBuilder;", ordinal = 0))
private StringBuilder addStats(StringBuilder stringBuilder, String str) {
stringBuilder.append(str);
+ if (!VanillaFixes.IMPROVED_TOOLTIP) {
+ return stringBuilder;
+ }
+
if (mc.gameSettings.heldItemCountOverlay.value) {
// Gets player inventory.
InventoryPlayer inventory = mc.thePlayer.inventory;
diff --git a/src/main/java/ambos/vanillafixes/mixin/MinecraftMixin.java b/src/main/java/ambos/vanillafixes/mixin/MinecraftMixin.java
@@ -7,6 +7,8 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.*;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import ambos.vanillafixes.VanillaFixes;
+
@Mixin(value = Minecraft.class, remap = false)
final class MinecraftMixin {
@Shadow
@@ -14,6 +16,8 @@ final class MinecraftMixin {
@Inject(method = "getEntityCountsInfoString", at = @At("HEAD"), require = 0, cancellable = true)
private void changeFormatting(CallbackInfoReturnable<String> cir) {
- cir.setReturnValue("Particles: " + this.effectRenderer.getNumParticlesString());
+ if (VanillaFixes.F3_MENU) {
+ cir.setReturnValue("Particles: " + this.effectRenderer.getNumParticlesString());
+ }
}
}
diff --git a/src/main/java/ambos/vanillafixes/mixin/RenderGlobalMixin.java b/src/main/java/ambos/vanillafixes/mixin/RenderGlobalMixin.java
@@ -1,6 +1,6 @@
package ambos.vanillafixes.mixin;
-import net.minecraft.client.render.RenderGlobal;
+import org.lwjgl.opengl.GL11;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@@ -8,6 +8,9 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
+import ambos.vanillafixes.VanillaFixes;
+import net.minecraft.client.render.RenderGlobal;
+
@Mixin(value = RenderGlobal.class, remap = false)
final class RenderGlobalMixin {
@Shadow
@@ -21,23 +24,31 @@ final class RenderGlobalMixin {
@Inject(method = "getRendererDebugInfo", at = @At("HEAD"), require = 0, cancellable = true)
private void changeFormatting(CallbackInfoReturnable<String> cir) {
- cir.setReturnValue("Renderers: " + this.renderersBeingRendered + "/" + this.renderersLoaded);
+ if (VanillaFixes.F3_MENU) {
+ cir.setReturnValue("Renderers: " + this.renderersBeingRendered + "/" + this.renderersLoaded);
+ }
}
@Inject(method = "getEntityDebugInfo", at = @At("HEAD"), require = 0, cancellable = true)
private void changeFormatting2(CallbackInfoReturnable<String> cir) {
- cir.setReturnValue("Entities: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal);
+ if (VanillaFixes.F3_MENU) {
+ cir.setReturnValue("Entities: " + this.countEntitiesRendered + "/" + this.countEntitiesTotal);
+ }
}
- @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE",
- target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0))
+ @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0))
private void cancelCallglEnable(int cap) {
// Fix fog rendering underwater.
+ if (!VanillaFixes.FOG) {
+ GL11.glEnable(cap);
+ }
}
- @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE",
- target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0))
+ @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0))
private void cancelCallglDisable(int cap) {
// Fix fog rendering underwater.
+ if (!VanillaFixes.FOG) {
+ GL11.glDisable(cap);
+ }
}
}
diff --git a/src/main/java/ambos/vanillafixes/mixin/SoundManagerMixin.java b/src/main/java/ambos/vanillafixes/mixin/SoundManagerMixin.java
@@ -8,32 +8,37 @@ import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
+import ambos.vanillafixes.VanillaFixes;
+
import java.io.File;
@Mixin(value = SoundManager.class, remap = false)
final class SoundManagerMixin {
- @Redirect(method = "loadModAudio", at = @At(value = "INVOKE",
- target = "Lnet/minecraft/client/Minecraft;getAppDir(Ljava/lang/String;)Ljava/io/File;", ordinal = 0))
+ @Redirect(method = "loadModAudio", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getAppDir(Ljava/lang/String;)Ljava/io/File;", ordinal = 0))
private static File doNotGetAppDir(String s) {
- return new File(s);
+ if (VanillaFixes.MOD_RESOURCES_PATH) {
+ return new File(s);
+ }
+
+ return Minecraft.getAppDir(s);
}
- @ModifyArgs(method = "loadSoundSettings", at = @At(value = "INVOKE",
- target = "Lnet/minecraft/client/sound/SoundManager;loadModAudio(Ljava/lang/String;Lnet/minecraft/client/sound/SoundPool;)V"),
- require = 0)
+ @ModifyArgs(method = "loadSoundSettings", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/sound/SoundManager;loadModAudio(Ljava/lang/String;Lnet/minecraft/client/sound/SoundPool;)V"), require = 0)
private void changeModResourcesPath(Args args) {
- // Note: "mod" directory is now inside .minecraft/resources instead of $HOME/.minecraft-bta/resources
- // (MultiMC users should be happy)
- Minecraft mc = Minecraft.getMinecraft(Minecraft.class);
+ if (VanillaFixes.MOD_RESOURCES_PATH) {
+ // Note: "mod" directory is now inside .minecraft/resources instead of
+ // $HOME/.minecraft-bta/resources (MultiMC users should be happy)
+ Minecraft mc = Minecraft.getMinecraft(Minecraft.class);
- if (args.get(0).equals("minecraft-bta/resources/mod/sound")) {
- args.set(0, mc.getMinecraftDir() + "/resources/mod/sound");
- } else if (args.get(0).equals("minecraft-bta/resources/mod/streaming")) {
- args.set(0, mc.getMinecraftDir() + "/resources/mod/streaming");
- } else if (args.get(0).equals("minecraft-bta/resources/mod/music")) {
- args.set(0, mc.getMinecraftDir() + "/resources/mod/music");
- } else {
- args.set(0, mc.getMinecraftDir() + "/resources/mod/cavemusic");
+ if (args.get(0).equals("minecraft-bta/resources/mod/sound")) {
+ args.set(0, mc.getMinecraftDir() + "/resources/mod/sound");
+ } else if (args.get(0).equals("minecraft-bta/resources/mod/streaming")) {
+ args.set(0, mc.getMinecraftDir() + "/resources/mod/streaming");
+ } else if (args.get(0).equals("minecraft-bta/resources/mod/music")) {
+ args.set(0, mc.getMinecraftDir() + "/resources/mod/music");
+ } else {
+ args.set(0, mc.getMinecraftDir() + "/resources/mod/cavemusic");
+ }
}
}
}