commit ada872ad6cb41f94c843a28cc87746e7dd212010
parent 06dbd410d097f52645ced94280dc7e67836d44c8
Author: Amb0s <ambos@disroot.org>
Date: Sun, 21 Jan 2024 09:40:55 +0100
Updates fixes and improvements
Diffstat:
6 files changed, 51 insertions(+), 52 deletions(-)
diff --git a/src/main/java/turniplabs/vanillafixes/mixin/FogManagerMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/FogManagerMixin.java
@@ -0,0 +1,37 @@
+package turniplabs.vanillafixes.mixin;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.option.enums.RenderDistance;
+import net.minecraft.client.render.FogManager;
+
+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.ModifyArgs;
+import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
+
+@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)
+ 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) {
+ 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)
+ 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) {
+ args.set(1, Float.valueOf(RenderDistance.EXTREME.chunks * 16));
+ }
+ }
+}
diff --git a/src/main/java/turniplabs/vanillafixes/mixin/GuiMainMenuMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/GuiMainMenuMixin.java
@@ -9,18 +9,16 @@ import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
@Mixin(value = GuiMainMenu.class, remap = false)
final class GuiMainMenuMixin extends GuiScreen {
- @Inject(method = "initGui", at = @At("RETURN"), require = 0)
+ @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 */);
}
- @Inject(method = "initGui", at = @At("RETURN"), require = 0)
+ @Inject(method = "init", at = @At("RETURN"), require = 0)
private void removeButtons(CallbackInfo ci) {
- controlList.removeIf(button ->
- button.id == 3 /* Texture packs */ || button.id == 8 /* Languages */ ||
- button.id == 100 /* Mod menu */);
+ controlList.removeIf(button -> button.id == 8 /* Languages */);
}
@ModifyArgs(method = "drawScreen", at = @At(value = "INVOKE",
diff --git a/src/main/java/turniplabs/vanillafixes/mixin/GuiTooltipMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/GuiTooltipMixin.java
@@ -23,17 +23,15 @@ final class GuiTooltipMixin extends Gui {
private Slot hoveredSlot;
- @Inject(method = "getTooltipText", at = @At("HEAD"))
- private void getSlot(ItemStack itemStack, boolean showDescription, Slot slot, CallbackInfoReturnable cir) {
+ @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;
}
- @Redirect(method = "getTooltipText", at = @At(value = "INVOKE",
- target = "Ljava/lang/StringBuilder;append(Ljava/lang/String;)Ljava/lang/StringBuilder;", ordinal = 2))
+ @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) {
- // The first calls to 'append' in the original method come from translateKey params.
- // Target: text.append(itemName)
stringBuilder.append(str);
if (mc.gameSettings.heldItemCountOverlay.value) {
diff --git a/src/main/java/turniplabs/vanillafixes/mixin/RenderGlobalMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/RenderGlobalMixin.java
@@ -31,9 +31,13 @@ final class RenderGlobalMixin {
@Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0))
- private void cancelCallglEnable(int cap) {}
+ private void cancelCallglEnable(int cap) {
+ // Fix fog rendering underwater.
+ }
@Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE",
target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0))
- private void cancelCallglDisable(int cap) {}
+ private void cancelCallglDisable(int cap) {
+ // Fix fog rendering underwater.
+ }
}
diff --git a/src/main/java/turniplabs/vanillafixes/mixin/WorldRendererMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/WorldRendererMixin.java
@@ -1,36 +0,0 @@
-package turniplabs.vanillafixes.mixin;
-
-import net.minecraft.client.Minecraft;
-import net.minecraft.client.render.WorldRenderer;
-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.ModifyArgs;
-import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
-
-@Mixin(value = WorldRenderer.class, remap = false)
-public class WorldRendererMixin {
- @Shadow
- private Minecraft mc;
-
- @Shadow
- private float farPlaneDistance = 0.0F;
-
- @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE",
- target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V", ordinal = 2), require = 0)
- private void changeFogStart(Args args) {
- if (!(Boolean)this.mc.gameSettings.fog.value) {
- // https://legacy.lwjgl.org/javadoc/constant-values.html
- args.set(1, farPlaneDistance * 16);
- }
- }
-
- @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE",
- target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V", ordinal = 3), require = 0)
- private void changeFogEnd(Args args) {
- if (!(Boolean)this.mc.gameSettings.fog.value) {
- // https://legacy.lwjgl.org/javadoc/constant-values.html
- args.set(1, farPlaneDistance * 32);
- }
- }
-}
diff --git a/src/main/resources/vanillafixes.mixins.json b/src/main/resources/vanillafixes.mixins.json
@@ -8,11 +8,9 @@
"GuiIngameMixin",
"GuiTooltipMixin",
"MinecraftMixin",
- "PlayerControllerMixin",
"RenderGlobalMixin",
"SoundManagerMixin",
- "ToolMaterialMixin",
- "WorldRendererMixin"
+ "FogManagerMixin"
],
"client": [
"DisplayListMixin",