Disable voxy if on unsupported system
This commit is contained in:
@@ -1,15 +1,30 @@
|
|||||||
package me.cortex.voxy.client;
|
package me.cortex.voxy.client;
|
||||||
|
|
||||||
|
import me.cortex.voxy.client.core.gl.Capabilities;
|
||||||
|
import me.cortex.voxy.common.Logger;
|
||||||
import me.cortex.voxy.commonImpl.VoxyCommon;
|
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.fabric.api.client.event.lifecycle.v1.ClientLifecycleEvents;
|
||||||
|
|
||||||
public class VoxyClient implements ClientModInitializer {
|
public class VoxyClient implements ClientModInitializer {
|
||||||
@Override
|
@Override
|
||||||
public void onInitializeClient() {
|
public void onInitializeClient() {
|
||||||
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
|
|
||||||
dispatcher.register(VoxyCommands.register());
|
ClientLifecycleEvents.CLIENT_STARTED.register(client->{
|
||||||
});
|
boolean systemSupported = Capabilities.INSTANCE.compute && Capabilities.INSTANCE.indirectParameters;
|
||||||
|
if (systemSupported) {
|
||||||
VoxyCommon.setInstanceFactory(VoxyClientInstance::new);
|
VoxyCommon.setInstanceFactory(VoxyClientInstance::new);
|
||||||
|
} else {
|
||||||
|
Logger.error("Voxy is unsupported on your system.");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
ClientCommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> {
|
||||||
|
if (VoxyCommon.isAvailable()) {
|
||||||
|
dispatcher.register(VoxyCommands.register());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,14 @@ package me.cortex.voxy.client.config;
|
|||||||
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
import com.terraformersmc.modmenu.api.ConfigScreenFactory;
|
||||||
import com.terraformersmc.modmenu.api.ModMenuApi;
|
import com.terraformersmc.modmenu.api.ModMenuApi;
|
||||||
import me.cortex.voxy.common.Logger;
|
import me.cortex.voxy.common.Logger;
|
||||||
|
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
|
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||||
|
|
||||||
public class ModMenuIntegration implements ModMenuApi {
|
public class ModMenuIntegration implements ModMenuApi {
|
||||||
@Override
|
@Override
|
||||||
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
public ConfigScreenFactory<?> getModConfigScreenFactory() {
|
||||||
return parent -> {
|
return parent -> {
|
||||||
|
if (VoxyCommon.isAvailable()) {
|
||||||
var screen = (SodiumOptionsGUI) SodiumOptionsGUI.createScreen(parent);
|
var screen = (SodiumOptionsGUI) SodiumOptionsGUI.createScreen(parent);
|
||||||
//Sorry jelly and douira, please dont hurt me
|
//Sorry jelly and douira, please dont hurt me
|
||||||
try {
|
try {
|
||||||
@@ -22,6 +24,9 @@ public class ModMenuIntegration implements ModMenuApi {
|
|||||||
Logger.error("Failed to set the current page to voxy", e);
|
Logger.error("Failed to set the current page to voxy", e);
|
||||||
}
|
}
|
||||||
return screen;
|
return screen;
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,6 +4,7 @@ import com.google.gson.FieldNamingPolicy;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
import me.cortex.voxy.common.Logger;
|
import me.cortex.voxy.common.Logger;
|
||||||
|
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.storage.OptionStorage;
|
import net.caffeinemc.mods.sodium.client.gui.options.storage.OptionStorage;
|
||||||
import net.fabricmc.loader.api.FabricLoader;
|
import net.fabricmc.loader.api.FabricLoader;
|
||||||
|
|
||||||
@@ -32,6 +33,7 @@ public class VoxyConfig implements OptionStorage<VoxyConfig> {
|
|||||||
public boolean renderStatistics = false;
|
public boolean renderStatistics = false;
|
||||||
|
|
||||||
public static VoxyConfig loadOrCreate() {
|
public static VoxyConfig loadOrCreate() {
|
||||||
|
if (VoxyCommon.isAvailable()) {
|
||||||
var path = getConfigPath();
|
var path = getConfigPath();
|
||||||
if (Files.exists(path)) {
|
if (Files.exists(path)) {
|
||||||
try (FileReader reader = new FileReader(path.toFile())) {
|
try (FileReader reader = new FileReader(path.toFile())) {
|
||||||
@@ -43,12 +45,18 @@ public class VoxyConfig implements OptionStorage<VoxyConfig> {
|
|||||||
Logger.error("Failed to load voxy config, resetting");
|
Logger.error("Failed to load voxy config, resetting");
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Logger.error("Could not parse config",e);
|
Logger.error("Could not parse config", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var config = new VoxyConfig();
|
var config = new VoxyConfig();
|
||||||
config.save();
|
config.save();
|
||||||
return config;
|
return config;
|
||||||
|
} else {
|
||||||
|
var config = new VoxyConfig();
|
||||||
|
config.enabled = false;
|
||||||
|
config.enableRendering = false;
|
||||||
|
return config;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save() {
|
public void save() {
|
||||||
|
|||||||
@@ -20,8 +20,12 @@ public class Capabilities {
|
|||||||
public final boolean canQueryGpuMemory;
|
public final boolean canQueryGpuMemory;
|
||||||
public final long totalDedicatedMemory;//Bytes, dedicated memory
|
public final long totalDedicatedMemory;//Bytes, dedicated memory
|
||||||
public final long totalDynamicMemory;//Bytes, total allocation memory - dedicated memory
|
public final long totalDynamicMemory;//Bytes, total allocation memory - dedicated memory
|
||||||
|
public final boolean compute;
|
||||||
|
public final boolean indirectParameters;
|
||||||
public Capabilities() {
|
public Capabilities() {
|
||||||
var cap = GL.getCapabilities();
|
var cap = GL.getCapabilities();
|
||||||
|
this.compute = cap.glDispatchComputeIndirect != 0;
|
||||||
|
this.indirectParameters = cap.glMultiDrawElementsIndirectCountARB != 0;
|
||||||
this.meshShaders = cap.GL_NV_mesh_shader && cap.GL_NV_representative_fragment_test;
|
this.meshShaders = cap.GL_NV_mesh_shader && cap.GL_NV_representative_fragment_test;
|
||||||
this.canQueryGpuMemory = cap.GL_NVX_gpu_memory_info;
|
this.canQueryGpuMemory = cap.GL_NVX_gpu_memory_info;
|
||||||
//this.INT64_t = cap.GL_ARB_gpu_shader_int64 || cap.GL_AMD_gpu_shader_int64;
|
//this.INT64_t = cap.GL_ARB_gpu_shader_int64 || cap.GL_AMD_gpu_shader_int64;
|
||||||
|
|||||||
@@ -22,9 +22,11 @@ import java.util.function.Consumer;
|
|||||||
public class MixinClientLoginNetworkHandler {
|
public class MixinClientLoginNetworkHandler {
|
||||||
@Inject(method = "<init>", at = @At(value = "TAIL"))
|
@Inject(method = "<init>", at = @At(value = "TAIL"))
|
||||||
private void voxy$init(ClientConnection connection, MinecraftClient client, ServerInfo serverInfo, Screen parentScreen, boolean newWorld, Duration worldLoadTime, Consumer statusConsumer, CookieStorage cookieStorage, CallbackInfo ci) {
|
private void voxy$init(ClientConnection connection, MinecraftClient client, ServerInfo serverInfo, Screen parentScreen, boolean newWorld, Duration worldLoadTime, Consumer statusConsumer, CookieStorage cookieStorage, CallbackInfo ci) {
|
||||||
|
if (VoxyCommon.isAvailable()) {
|
||||||
VoxyClientInstance.isInGame = true;
|
VoxyClientInstance.isInGame = true;
|
||||||
if (VoxyConfig.CONFIG.enabled) {
|
if (VoxyConfig.CONFIG.enabled) {
|
||||||
VoxyCommon.createInstance();
|
VoxyCommon.createInstance();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,9 +16,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
public class MixinMinecraftClient {
|
public class MixinMinecraftClient {
|
||||||
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;Z)V", at = @At("TAIL"))
|
@Inject(method = "disconnect(Lnet/minecraft/client/gui/screen/Screen;Z)V", at = @At("TAIL"))
|
||||||
private void voxy$injectWorldClose(CallbackInfo ci) {
|
private void voxy$injectWorldClose(CallbackInfo ci) {
|
||||||
|
if (VoxyCommon.isAvailable()) {
|
||||||
VoxyCommon.shutdownInstance();
|
VoxyCommon.shutdownInstance();
|
||||||
VoxyClientInstance.isInGame = false;
|
VoxyClientInstance.isInGame = false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Inject(method = "joinWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setWorld(Lnet/minecraft/client/world/ClientWorld;)V", shift = At.Shift.BEFORE))
|
@Inject(method = "joinWorld", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/MinecraftClient;setWorld(Lnet/minecraft/client/world/ClientWorld;)V", shift = At.Shift.BEFORE))
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package me.cortex.voxy.client.mixin.sodium;
|
package me.cortex.voxy.client.mixin.sodium;
|
||||||
|
|
||||||
import me.cortex.voxy.client.config.VoxyConfigScreenPages;
|
import me.cortex.voxy.client.config.VoxyConfigScreenPages;
|
||||||
|
import me.cortex.voxy.commonImpl.VoxyCommon;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
|
import net.caffeinemc.mods.sodium.client.gui.SodiumOptionsGUI;
|
||||||
import net.caffeinemc.mods.sodium.client.gui.options.OptionPage;
|
import net.caffeinemc.mods.sodium.client.gui.options.OptionPage;
|
||||||
import net.minecraft.client.gui.screen.Screen;
|
import net.minecraft.client.gui.screen.Screen;
|
||||||
@@ -19,6 +20,8 @@ public class MixinSodiumOptionsGUI {
|
|||||||
|
|
||||||
@Inject(method = "<init>", at = @At("TAIL"))
|
@Inject(method = "<init>", at = @At("TAIL"))
|
||||||
private void voxy$addConfigPage(Screen prevScreen, CallbackInfo ci) {
|
private void voxy$addConfigPage(Screen prevScreen, CallbackInfo ci) {
|
||||||
|
if (VoxyCommon.isAvailable()) {
|
||||||
this.pages.add(VoxyConfigScreenPages.voxyOptionPage = VoxyConfigScreenPages.page());
|
this.pages.add(VoxyConfigScreenPages.voxyOptionPage = VoxyConfigScreenPages.page());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,12 +66,18 @@ public class VoxyCommon implements ModInitializer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void createInstance() {
|
public static void createInstance() {
|
||||||
|
if (FACTORY == null) {
|
||||||
|
//Logger.info("Voxy factory");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (INSTANCE != null) {
|
if (INSTANCE != null) {
|
||||||
throw new IllegalStateException("Cannot create multiple instances");
|
throw new IllegalStateException("Cannot create multiple instances");
|
||||||
}
|
}
|
||||||
if (FACTORY == null) {
|
|
||||||
throw new IllegalStateException("Instance factory null");
|
|
||||||
}
|
|
||||||
INSTANCE = FACTORY.create();
|
INSTANCE = FACTORY.create();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Is voxy available in any capacity
|
||||||
|
public static boolean isAvailable() {
|
||||||
|
return FACTORY != null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user