always show voxy version in f3
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
package me.cortex.voxy.client;
|
package me.cortex.voxy.client;
|
||||||
|
|
||||||
|
import me.cortex.voxy.client.core.IGetVoxyRenderSystem;
|
||||||
|
import me.cortex.voxy.client.core.VoxyRenderSystem;
|
||||||
import me.cortex.voxy.client.core.gl.Capabilities;
|
import me.cortex.voxy.client.core.gl.Capabilities;
|
||||||
import me.cortex.voxy.client.core.model.bakery.BudgetBufferRenderer;
|
import me.cortex.voxy.client.core.model.bakery.BudgetBufferRenderer;
|
||||||
import me.cortex.voxy.client.core.rendering.util.SharedIndexBuffer;
|
import me.cortex.voxy.client.core.rendering.util.SharedIndexBuffer;
|
||||||
@@ -8,8 +10,16 @@ import me.cortex.voxy.commonImpl.VoxyCommon;
|
|||||||
import net.fabricmc.api.ClientModInitializer;
|
import net.fabricmc.api.ClientModInitializer;
|
||||||
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
|
import net.fabricmc.fabric.api.client.command.v2.ClientCommandRegistrationCallback;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
import net.minecraft.ChatFormatting;
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.gui.components.debug.DebugScreenDisplayer;
|
||||||
import net.minecraft.client.gui.components.debug.DebugScreenEntries;
|
import net.minecraft.client.gui.components.debug.DebugScreenEntries;
|
||||||
|
import net.minecraft.client.gui.components.debug.DebugScreenEntry;
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
|
import net.minecraft.world.level.Level;
|
||||||
|
import net.minecraft.world.level.chunk.LevelChunk;
|
||||||
|
import org.jspecify.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -43,6 +53,27 @@ public class VoxyClient implements ClientModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
|
DebugScreenEntries.register(Identifier.fromNamespaceAndPath("voxy", "version"), new DebugScreenEntry() {
|
||||||
|
@Override
|
||||||
|
public void display(DebugScreenDisplayer lines, @Nullable Level level, @Nullable LevelChunk levelChunk, @Nullable LevelChunk levelChunk2) {
|
||||||
|
if (!VoxyCommon.isAvailable()) {
|
||||||
|
lines.addLine(ChatFormatting.RED + "voxy-"+VoxyCommon.MOD_VERSION);//Voxy installed, not avalible
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var instance = VoxyCommon.getInstance();
|
||||||
|
if (instance == null) {
|
||||||
|
lines.addLine(ChatFormatting.YELLOW + "voxy-" + VoxyCommon.MOD_VERSION);//Voxy avalible, no instance active
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
VoxyRenderSystem vrs = null;
|
||||||
|
var wr = Minecraft.getInstance().levelRenderer;
|
||||||
|
if (wr != null) vrs = ((IGetVoxyRenderSystem) wr).getVoxyRenderSystem();
|
||||||
|
|
||||||
|
//Voxy instance active
|
||||||
|
lines.addLine((vrs==null?ChatFormatting.DARK_GREEN:ChatFormatting.GREEN)+"voxy-"+VoxyCommon.MOD_VERSION);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
DebugScreenEntries.register(Identifier.fromNamespaceAndPath("voxy","debug"), new VoxyDebugScreenEntry());
|
DebugScreenEntries.register(Identifier.fromNamespaceAndPath("voxy","debug"), new VoxyDebugScreenEntry());
|
||||||
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
|
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
|
||||||
if (VoxyCommon.isAvailable()) {
|
if (VoxyCommon.isAvailable()) {
|
||||||
|
|||||||
@@ -19,21 +19,18 @@ public class VoxyDebugScreenEntry implements DebugScreenEntry {
|
|||||||
@Override
|
@Override
|
||||||
public void display(DebugScreenDisplayer lines, @Nullable Level world, @Nullable LevelChunk clientChunk, @Nullable LevelChunk chunk) {
|
public void display(DebugScreenDisplayer lines, @Nullable Level world, @Nullable LevelChunk clientChunk, @Nullable LevelChunk chunk) {
|
||||||
if (!VoxyCommon.isAvailable()) {
|
if (!VoxyCommon.isAvailable()) {
|
||||||
lines.addLine(ChatFormatting.RED + "voxy-"+VoxyCommon.MOD_VERSION);//Voxy installed, not avalible
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var instance = VoxyCommon.getInstance();
|
var instance = VoxyCommon.getInstance();
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
lines.addLine(ChatFormatting.YELLOW + "voxy-" + VoxyCommon.MOD_VERSION);//Voxy avalible, no instance active
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
VoxyRenderSystem vrs = null;
|
VoxyRenderSystem vrs = null;
|
||||||
var wr = Minecraft.getInstance().levelRenderer;
|
var wr = Minecraft.getInstance().levelRenderer;
|
||||||
if (wr != null) vrs = ((IGetVoxyRenderSystem) wr).getVoxyRenderSystem();
|
if (wr != null) vrs = ((IGetVoxyRenderSystem) wr).getVoxyRenderSystem();
|
||||||
|
|
||||||
//Voxy instance active
|
|
||||||
lines.addLine((vrs==null?ChatFormatting.DARK_GREEN:ChatFormatting.GREEN)+"voxy-"+VoxyCommon.MOD_VERSION);
|
|
||||||
|
|
||||||
//lines.addLineToSection();
|
//lines.addLineToSection();
|
||||||
List<String> instanceLines = new ArrayList<>();
|
List<String> instanceLines = new ArrayList<>();
|
||||||
instance.addDebug(instanceLines);
|
instance.addDebug(instanceLines);
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package me.cortex.voxy.client.mixin.minecraft;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.components.debug.DebugScreenEntryList;
|
||||||
|
import net.minecraft.resources.Identifier;
|
||||||
|
import org.spongepowered.asm.mixin.Final;
|
||||||
|
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.callback.CallbackInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mixin(DebugScreenEntryList.class)
|
||||||
|
public abstract class MixinDebugScreenEntryList {
|
||||||
|
@Shadow @Final private List<Identifier> currentlyEnabled;
|
||||||
|
@Shadow public abstract boolean isOverlayVisible();
|
||||||
|
|
||||||
|
@Inject(method = "rebuildCurrentList", at = @At(value = "INVOKE", target = "Ljava/util/List;sort(Ljava/util/Comparator;)V"))
|
||||||
|
private void voxy$injectVersionDisplay(CallbackInfo cir) {
|
||||||
|
if (this.isOverlayVisible()) {
|
||||||
|
var id = Identifier.fromNamespaceAndPath("voxy", "version");
|
||||||
|
if (!this.currentlyEnabled.contains(id)) {
|
||||||
|
this.currentlyEnabled.add(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -21,6 +21,7 @@
|
|||||||
"minecraft.MixinClientCommonPacketListenerImpl",
|
"minecraft.MixinClientCommonPacketListenerImpl",
|
||||||
"minecraft.MixinClientLevel",
|
"minecraft.MixinClientLevel",
|
||||||
"minecraft.MixinClientPacketListener",
|
"minecraft.MixinClientPacketListener",
|
||||||
|
"minecraft.MixinDebugScreenEntryList",
|
||||||
"minecraft.MixinFogRenderer",
|
"minecraft.MixinFogRenderer",
|
||||||
"minecraft.MixinGlDebug",
|
"minecraft.MixinGlDebug",
|
||||||
"minecraft.MixinLevelRenderer",
|
"minecraft.MixinLevelRenderer",
|
||||||
|
|||||||
Reference in New Issue
Block a user