|
| 1 | +package net.vulkanmod.mixin.debug; |
| 2 | + |
| 3 | +import com.mojang.blaze3d.platform.GLX; |
| 4 | +import com.mojang.blaze3d.systems.GpuDevice; |
| 5 | +import com.mojang.blaze3d.systems.RenderSystem; |
| 6 | +import net.minecraft.client.Minecraft; |
| 7 | +import net.minecraft.client.gui.components.debug.DebugEntrySystemSpecs; |
| 8 | +import net.minecraft.client.gui.components.debug.DebugScreenDisplayer; |
| 9 | +import net.minecraft.resources.ResourceLocation; |
| 10 | +import net.minecraft.world.level.Level; |
| 11 | +import net.minecraft.world.level.chunk.LevelChunk; |
| 12 | +import net.vulkanmod.Initializer; |
| 13 | +import org.spongepowered.asm.mixin.Final; |
| 14 | +import org.spongepowered.asm.mixin.Mixin; |
| 15 | +import org.spongepowered.asm.mixin.Shadow; |
| 16 | +import org.spongepowered.asm.mixin.injection.At; |
| 17 | +import org.spongepowered.asm.mixin.injection.Inject; |
| 18 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; |
| 19 | + |
| 20 | +import java.util.List; |
| 21 | +import java.util.Locale; |
| 22 | + |
| 23 | +@Mixin(DebugEntrySystemSpecs.class) |
| 24 | +public class DebugEntrySystemSpecsM { |
| 25 | + |
| 26 | + @Shadow @Final private static ResourceLocation GROUP; |
| 27 | + |
| 28 | + @Inject(method = "display", at = @At("HEAD"), cancellable = true) |
| 29 | + private void display(DebugScreenDisplayer debugScreenDisplayer, Level level, LevelChunk levelChunk, |
| 30 | + LevelChunk levelChunk2, CallbackInfo ci) { |
| 31 | + GpuDevice gpuDevice = RenderSystem.getDevice(); |
| 32 | + debugScreenDisplayer.addToGroup( |
| 33 | + GROUP, |
| 34 | + List.of( |
| 35 | + String.format(Locale.ROOT, "Java: %s", System.getProperty("java.version")), |
| 36 | + String.format(Locale.ROOT, "CPU: %s", GLX._getCpuInfo()), |
| 37 | + String.format( |
| 38 | + Locale.ROOT, "Display: %dx%d (%s)", Minecraft.getInstance().getWindow().getWidth(), Minecraft.getInstance().getWindow().getHeight(), gpuDevice.getVendor() |
| 39 | + ), |
| 40 | + gpuDevice.getRenderer(), |
| 41 | + String.format(Locale.ROOT, "%s %s", gpuDevice.getBackendName(), gpuDevice.getVersion()), |
| 42 | + String.format(Locale.ROOT, "VulkanMod %s", Initializer.getVersion()) |
| 43 | + ) |
| 44 | + ); |
| 45 | + |
| 46 | + ci.cancel(); |
| 47 | + } |
| 48 | + |
| 49 | +} |
0 commit comments