vanilla-fixes

Minecraft: Better than Adventure! mod that fixes some issues
git clone git://memoryshards.xyz/vanilla-fixes.git
Log | Files | Refs | README | LICENSE

commit a922e334608719fbbfc154c44db51abfd7e9e7c6
parent b604d043da03f7d9504c9696205187f9bfb3e5ac
Author: Amb0s <ambos@disroot.org>
Date:   Sun, 20 Aug 2023 16:27:56 +0200

Changed HUD formatting again and fixed fog

Diffstat:
Asrc/main/java/turniplabs/vanillafixes/mixin/RenderGlobalMixin.java | 39+++++++++++++++++++++++++++++++++++++++
Asrc/main/java/turniplabs/vanillafixes/mixin/WorldRendererMixin.java | 32++++++++++++++++++++++++++++++++
2 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/src/main/java/turniplabs/vanillafixes/mixin/RenderGlobalMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/RenderGlobalMixin.java @@ -0,0 +1,39 @@ +package turniplabs.vanillafixes.mixin; + +import net.minecraft.client.render.RenderGlobal; +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 = RenderGlobal.class, remap = false) +final class RenderGlobalMixin { + @Shadow + private int countEntitiesTotal; + @Shadow + private int countEntitiesRendered; + @Shadow + private int renderersLoaded; + @Shadow + private int renderersBeingRendered; + + @Inject(method = "getRendererDebugInfo", at = @At("HEAD"), require = 0, cancellable = true) + private void changeFormatting(CallbackInfoReturnable<String> cir) { + 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); + } + + @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glEnable(I)V", ordinal = 0)) + private void cancelCallglEnable(int cap) {} + + @Redirect(method = "renderSortedRenderers", at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glDisable(I)V", ordinal = 0)) + private void cancelCallglDisable(int cap) {} +} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/WorldRendererMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/WorldRendererMixin.java @@ -0,0 +1,32 @@ +package turniplabs.vanillafixes.mixin; + +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 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 fixFogStart(Args args) { + 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 fixFogEnd(Args args) { + args.set(1, farPlaneDistance * 32); + } + + @ModifyArgs(method = "setupFog", at = @At(value = "INVOKE", + target = "Lorg/lwjgl/opengl/GL11;glFogf(IF)V", ordinal = 4), require = 0) + private void fixFogDensity(Args args) { + args.set(1, 0.0f); + } +}