Added client config. Added config option for screen text gui.
This commit is contained in:
@ -4,6 +4,7 @@ import com.mojang.blaze3d.systems.RenderSystem;
|
|||||||
import com.mojang.blaze3d.vertex.PoseStack;
|
import com.mojang.blaze3d.vertex.PoseStack;
|
||||||
import dev.micle.loginprotection.data.ProtectedPlayer;
|
import dev.micle.loginprotection.data.ProtectedPlayer;
|
||||||
import dev.micle.loginprotection.proxy.Proxy;
|
import dev.micle.loginprotection.proxy.Proxy;
|
||||||
|
import dev.micle.loginprotection.setup.Config;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.gui.Font;
|
import net.minecraft.client.gui.Font;
|
||||||
import net.minecraft.client.gui.GuiGraphics;
|
import net.minecraft.client.gui.GuiGraphics;
|
||||||
@ -20,6 +21,11 @@ import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
|||||||
public class GuiRenderTickMixin {
|
public class GuiRenderTickMixin {
|
||||||
@Inject(method = "render", at = @At(value = "HEAD"))
|
@Inject(method = "render", at = @At(value = "HEAD"))
|
||||||
private void onClientTick(GuiGraphics guiGraphics, float partialTick, CallbackInfo ci) {
|
private void onClientTick(GuiGraphics guiGraphics, float partialTick, CallbackInfo ci) {
|
||||||
|
// Check if enabled
|
||||||
|
if (!Config.Client.GUI_SCREEN_TEXT_ENABLED.get()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup
|
// Setup
|
||||||
PoseStack poseStack = guiGraphics.pose();
|
PoseStack poseStack = guiGraphics.pose();
|
||||||
poseStack.pushPose();
|
poseStack.pushPose();
|
||||||
|
|||||||
@ -14,14 +14,34 @@ import java.util.List;
|
|||||||
public final class Config {
|
public final class Config {
|
||||||
public static final Server SERVER;
|
public static final Server SERVER;
|
||||||
public static final ForgeConfigSpec SERVER_SPEC;
|
public static final ForgeConfigSpec SERVER_SPEC;
|
||||||
|
public static final Client CLIENT;
|
||||||
|
public static final ForgeConfigSpec CLIENT_SPEC;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
Pair<Server, ForgeConfigSpec> spec_pair = new ForgeConfigSpec.Builder().configure(Server::new);
|
Pair<Server, ForgeConfigSpec> specPairServer = new ForgeConfigSpec.Builder().configure(Server::new);
|
||||||
SERVER = spec_pair.getLeft();
|
SERVER = specPairServer.getLeft();
|
||||||
SERVER_SPEC = spec_pair.getRight();
|
SERVER_SPEC = specPairServer.getRight();
|
||||||
|
|
||||||
|
Pair<Client, ForgeConfigSpec> specPairClient = new ForgeConfigSpec.Builder().configure(Client::new);
|
||||||
|
CLIENT = specPairClient.getLeft();
|
||||||
|
CLIENT_SPEC = specPairClient.getRight();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_SPEC);
|
ModLoadingContext.get().registerConfig(ModConfig.Type.SERVER, SERVER_SPEC);
|
||||||
|
ModLoadingContext.get().registerConfig(ModConfig.Type.CLIENT, CLIENT_SPEC);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Client {
|
||||||
|
public static ForgeConfigSpec.BooleanValue GUI_SCREEN_TEXT_ENABLED;
|
||||||
|
|
||||||
|
Client(ForgeConfigSpec.Builder builder) {
|
||||||
|
builder.comment("GUI settings.").push("GUI");
|
||||||
|
GUI_SCREEN_TEXT_ENABLED = builder
|
||||||
|
.comment("Whether current protection status is displayed as text on screen.")
|
||||||
|
.define("guiScreenTextEnabled", true);
|
||||||
|
builder.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Server {
|
public static class Server {
|
||||||
|
|||||||
Reference in New Issue
Block a user