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 b604d043da03f7d9504c9696205187f9bfb3e5ac
parent d1225aa57b37aac6c1d4f037315d6130ade34f0c
Author: Amb0s <ambos@disroot.org>
Date:   Sun, 20 Aug 2023 16:27:34 +0200

Changed HUD formatting

Diffstat:
Asrc/main/java/turniplabs/vanillafixes/mixin/ChunkProviderStaticMixin.java | 14++++++++++++++
Asrc/main/java/turniplabs/vanillafixes/mixin/GuiIngameMixin.java | 68++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/java/turniplabs/vanillafixes/mixin/MinecraftMixin.java | 19+++++++++++++++++++
3 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/src/main/java/turniplabs/vanillafixes/mixin/ChunkProviderStaticMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/ChunkProviderStaticMixin.java @@ -0,0 +1,14 @@ +package turniplabs.vanillafixes.mixin; + +import net.minecraft.client.world.chunk.provider.ChunkProviderStatic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.Constant; +import org.spongepowered.asm.mixin.injection.ModifyConstant; + +@Mixin(value = ChunkProviderStatic.class, remap = false) +final class ChunkProviderStaticMixin { + @ModifyConstant(method = "getInfoString", constant = @Constant(stringValue = "ChunkCache: ")) + private String reformatChunkCache(String value) { + return "Chunk Cache: "; + } +} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/GuiIngameMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/GuiIngameMixin.java @@ -0,0 +1,68 @@ +package turniplabs.vanillafixes.mixin; + +import net.minecraft.client.gui.GuiIngame; +import org.lwjgl.opengl.GL11; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.invoke.arg.Args; + +@Mixin(value = GuiIngame.class, remap = false) +final class GuiIngameMixin { + @Shadow + private void drawDebugScreenLineRight(String string) { + + } + + @ModifyConstant(method = "renderGameOverlay", constant = @Constant(stringValue = "s I: ")) + private String deobfuscateWeatherIntensity(String value) { + return "s, Intensity: "; + } + + @ModifyConstant(method = "renderGameOverlay", constant = @Constant(stringValue = "% P: ")) + private String deobfuscateWeatherPower(String value) { + return "%, Power: "; + } + + @Inject(method = "renderGameOverlay", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/gui/GuiIngame;drawDebugScreenLineRight(Ljava/lang/String;)V", ordinal = 5), + require = 0) + private void displayVRAM(float partialTicks, boolean flag, int mouseX, int mouseY, CallbackInfo ci) { + // https://developer.download.nvidia.com/opengl/specs/GL_NVX_gpu_memory_info.txt + /* GPU_MEMORY_INFO_DEDICATED_VIDMEM_NVX */ + long maxVRAM = GL11.glGetInteger(36935); + + /* GPU_MEMORY_INFO_TOTAL_AVAILABLE_MEMORY_NVX */ + long totalAvailableVRAM = GL11.glGetInteger(36936); + + /* GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX */ + long availableVRAM = GL11.glGetInteger(36937); + + long usedVRAM = maxVRAM - availableVRAM; + + drawDebugScreenLineRight("VRAM: " + usedVRAM * 100L / maxVRAM + "% ("+ usedVRAM / 1024L + + "/" + maxVRAM / 1024L + "MB)"); + } + + @ModifyArgs(method = "renderGameOverlay", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/gui/GuiIngame;drawDebugScreenLineRight(Ljava/lang/String;)V", ordinal = 0), + require = 0) + private void changeRAMDisplay(Args args) { + // https://stackoverflow.com/questions/3571203/what-are-runtime-getruntime-totalmemory-and-freememory + long maxRAM = Runtime.getRuntime().maxMemory(); + long totalRAM = Runtime.getRuntime().totalMemory(); + long freeRAM = Runtime.getRuntime().freeMemory(); + long usedRAM = totalRAM - freeRAM; + + args.set(0, "RAM: " + usedRAM * 100L / maxRAM + "% (" + usedRAM / 1024L / 1024L + "/" + + maxRAM / 1024L / 1024L + "MB)"); + } + + @ModifyArgs(method = "renderGameOverlay", at = @At(value = "INVOKE", + target = "Lnet/minecraft/client/gui/GuiIngame;drawDebugScreenLineRight(Ljava/lang/String;)V", ordinal = 1), + require = 0) + private void changeRAMDisplay2(Args args) { + args.set(0, Runtime.getRuntime().totalMemory() / 1024L / 1024L + "MB allocated"); + } +} diff --git a/src/main/java/turniplabs/vanillafixes/mixin/MinecraftMixin.java b/src/main/java/turniplabs/vanillafixes/mixin/MinecraftMixin.java @@ -0,0 +1,19 @@ +package turniplabs.vanillafixes.mixin; + +import net.minecraft.client.Minecraft; +import net.minecraft.client.render.EffectRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.*; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Mixin(value = Minecraft.class, remap = false) +final class MinecraftMixin { + @Shadow + public EffectRenderer effectRenderer; + + @Inject(method = "getEntityCountsInfoString", at = @At("HEAD"), require = 0, cancellable = true) + private void changeFormatting(CallbackInfoReturnable<String> cir) { + cir.setReturnValue("Particles: " + this.effectRenderer.getNumParticlesString()); + } +}