Implemented Custom Screens

This commit is contained in:
ChampClient 2024-01-03 12:13:38 -05:00
parent 5509f7f69c
commit 79cd452876
31 changed files with 174 additions and 154 deletions

1
.idea/.name Normal file
View File

@ -0,0 +1 @@
SilentClient

View File

@ -5,7 +5,7 @@
<option name="linkedExternalProjectsSettings"> <option name="linkedExternalProjectsSettings">
<GradleProjectSettings> <GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" /> <option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="" /> <option name="gradleJvm" value="zulu-17" />
<option name="modules"> <option name="modules">
<set> <set>
<option value="$PROJECT_DIR$" /> <option value="$PROJECT_DIR$" />

View File

@ -1,6 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" /> <component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="graalvm-ce-17" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="zulu-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

View File

@ -2,7 +2,7 @@ plugins {
id 'java' id 'java'
} }
group = 'dev.refactoring' group = 'net.silentclient'
version = '1.0-SNAPSHOT' version = '1.0-SNAPSHOT'
repositories { repositories {

View File

@ -1,6 +1,6 @@
package dev.refactoring.bridge.client; package net.silentclient.client;
import dev.refactoring.bridge.client.gui.GuiScreenBridge; import net.silentclient.client.gui.GuiScreenBridge;
import java.io.File; import java.io.File;

View File

@ -1,4 +1,4 @@
package dev.refactoring.bridge.client.gui; package net.silentclient.client.gui;
/** /**
* @author refactoring * @author refactoring

View File

@ -1,4 +1,4 @@
package dev.refactoring.bridge.client.gui; package net.silentclient.client.gui;
/** /**
* @author refactoring * @author refactoring

View File

@ -1,11 +1,8 @@
package dev.refactoring.bridge.client.gui; package net.silentclient.client.gui;
/** /**
* @author refactoring * @author refactoring
*/ */
import java.io.IOException;
import java.net.URI;
import java.util.List;
public interface GuiScreenBridge extends GuiBridge { public interface GuiScreenBridge extends GuiBridge {
void bridge$drawScreen(int mouseX, int mouseY, float pTicks); void bridge$drawScreen(int mouseX, int mouseY, float pTicks);

View File

@ -1,4 +1,4 @@
package dev.refactoring.bridge.client.gui; package net.silentclient.client.gui;
/** /**
* @author refactoring * @author refactoring

View File

@ -1,4 +1,4 @@
package dev.refactoring.bridge.client.input; package net.silentclient.client.input;
import java.util.List; import java.util.List;

View File

@ -1,9 +1,9 @@
package dev.refactoring.bridge.core; package net.silentclient.core;
import dev.refactoring.bridge.client.gui.CustomScreen; import net.silentclient.client.gui.CustomScreen;
import dev.refactoring.bridge.client.gui.WrappedGuiScreenBridge; import net.silentclient.client.gui.WrappedGuiScreenBridge;
import dev.refactoring.bridge.client.input.KeyBindingBridge; import net.silentclient.client.input.KeyBindingBridge;
/** /**
* Has helper methods. * Has helper methods.

View File

@ -1,7 +1,8 @@
package dev.refactoring.bridge.core; package net.silentclient.core;
import dev.refactoring.bridge.client.MinecraftBridge; import net.silentclient.client.MinecraftBridge;
import dev.refactoring.bridge.core.util.MinecraftVersion; import net.silentclient.client.gui.CustomScreen;
import net.silentclient.core.util.MinecraftVersion;
import lombok.Getter; import lombok.Getter;
import lombok.Setter; import lombok.Setter;
@ -21,4 +22,6 @@ public class BridgeManager {
// Other // Other
private String windowTitle = "Silent Client | Initializing"; private String windowTitle = "Silent Client | Initializing";
private MinecraftVersion version; private MinecraftVersion version;
private CustomScreen currentScreen;
} }

View File

@ -1,4 +1,4 @@
package dev.refactoring.bridge.core.util; package net.silentclient.core.util;
import lombok.Getter; import lombok.Getter;

View File

@ -1,7 +1,7 @@
package dev.refactoring.bridge.core.util; package net.silentclient.core.util;
import dev.refactoring.bridge.client.MinecraftBridge; import net.silentclient.client.MinecraftBridge;
import dev.refactoring.bridge.core.BridgeManager; import net.silentclient.core.BridgeManager;
/** /**
* The Ref class has commonly used bridges to make code shorter and cleaner. * The Ref class has commonly used bridges to make code shorter and cleaner.

View File

@ -2,7 +2,7 @@ plugins {
id 'java' id 'java'
} }
group = 'dev.refactoring' group = 'net.silentclient'
version = '1.0-SNAPSHOT' version = '1.0-SNAPSHOT'
sourceCompatibility = JavaVersion.VERSION_17 sourceCompatibility = JavaVersion.VERSION_17

View File

@ -2,7 +2,7 @@ package net.silentclient.client;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.GsonBuilder; import com.google.gson.GsonBuilder;
import dev.refactoring.bridge.core.util.Ref; import net.silentclient.core.util.Ref;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.gui.ScaledResolution; import net.minecraft.client.gui.ScaledResolution;
import net.minecraft.client.multiplayer.ServerData; import net.minecraft.client.multiplayer.ServerData;

View File

@ -1,6 +1,5 @@
package net.silentclient.client.gui; package net.silentclient.client.gui;
import dev.refactoring.bridge.client.gui.CustomScreen;
import net.silentclient.client.Client; import net.silentclient.client.Client;
import net.silentclient.client.gui.elements.Button; import net.silentclient.client.gui.elements.Button;
import net.silentclient.client.gui.elements.Input; import net.silentclient.client.gui.elements.Input;

View File

@ -1,6 +1,6 @@
package net.silentclient.client.gui.multiplayer; package net.silentclient.client.gui.multiplayer;
import dev.refactoring.bridge.client.gui.GuiScreenBridge; import net.silentclient.client.gui.GuiScreenBridge;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;

View File

@ -1,7 +1,7 @@
package net.silentclient.client.gui.resourcepacks; package net.silentclient.client.gui.resourcepacks;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import dev.refactoring.bridge.client.gui.GuiScreenBridge; import net.silentclient.client.gui.GuiScreenBridge;
import net.minecraft.client.gui.GuiButton; import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;

View File

@ -1,6 +1,6 @@
package net.silentclient.client.gui.util; package net.silentclient.client.gui.util;
import dev.refactoring.bridge.client.MinecraftBridge; import net.silentclient.client.MinecraftBridge;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.GlStateManager; import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.renderer.Tessellator; import net.minecraft.client.renderer.Tessellator;

View File

@ -1,6 +1,6 @@
package net.silentclient.client.mods.hud; package net.silentclient.client.mods.hud;
import dev.refactoring.bridge.core.util.Ref; import net.silentclient.core.util.Ref;
import net.silentclient.client.mods.HudMod; import net.silentclient.client.mods.HudMod;
import net.silentclient.client.mods.ModCategory; import net.silentclient.client.mods.ModCategory;

View File

@ -4,7 +4,7 @@ plugins {
id "io.freefair.lombok" version '6.6.+' apply false id "io.freefair.lombok" version '6.6.+' apply false
} }
group = 'dev.refactoring' group = 'net.silentclient'
version = '1.0-SNAPSHOT' version = '1.0-SNAPSHOT'
subprojects { subprojects {

View File

@ -7,5 +7,5 @@ loader_version = 0.15.2
fabric_version = 1.9.1+1.8.9 fabric_version = 1.9.1+1.8.9
mod_version = 1.0.0 mod_version = 1.0.0
maven_group = dev.refactoring maven_group = net.silentclient
archives_base_name = TestClient189 archives_base_name = SilentClient189

View File

@ -1,24 +0,0 @@
package dev.refactoring.bridge;
import dev.refactoring.bridge.client.gui.CustomScreen;
import dev.refactoring.bridge.client.gui.WrappedGuiScreenBridge;
import dev.refactoring.bridge.client.input.KeyBindingBridge;
import dev.refactoring.bridge.core.Bridge;
import dev.refactoring.bridge.impl.WrappedGuiScreen;
import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.option.KeyBinding;
/**
* @author refactoring
*/
public class BridgeImpl implements Bridge {
@Override
public KeyBindingBridge initKeyBinding(String name, int keyCode, String cat) {
return (KeyBindingBridge) KeyBindingHelper.registerKeyBinding(new KeyBinding(name, keyCode, cat));
}
@Override
public WrappedGuiScreenBridge initCustomScreen(CustomScreen screen) {
return new WrappedGuiScreen(screen);
}
}

View File

@ -1,90 +0,0 @@
package dev.refactoring.bridge.impl;
/**
* @author refactoring
*/
import dev.refactoring.bridge.client.gui.CustomScreen;
import dev.refactoring.bridge.client.gui.WrappedGuiScreenBridge;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import org.lwjgl.input.Mouse;
import java.io.IOException;
import java.net.URI;
public class WrappedGuiScreen extends GuiScreen implements WrappedGuiScreenBridge {
public final CustomScreen customScreen;
public void bridge$drawScreen(int var1, int var2, float var3) {
this.drawScreen(var1, var2, var3);
}
public void bridge$mouseClicked(int var1, int var2, int var3) {
this.mouseClicked(var1, var2, var3);
}
public void bridge$mouseReleased(int var1, int var2, int var3) {
this.mouseReleased(var1, var2, var3);
}
public void bridge$onGuiClosed() {
this.onGuiClosed();
}
public void bridge$updateScreen() {
this.updateScreen();
}
public void bridge$keyTyped(char var1, int var2) {
this.keyTyped(var1, var2);
}
public void bridge$handleMouseInput() {
this.handleMouseInput();
}
public void bridge$setClickedLinkURI(URI var1) {
}
public boolean bridge$allowUserInput() {
return false;
}
public boolean bridge$doesGuiPauseGame() {
return true;
}
public void drawScreen(int var1, int var2, float var3) {
this.customScreen.drawScreen(var1, var2, var3);
}
public void mouseClicked(int var1, int var2, int var3) {
this.customScreen.mouseClicked(var1, var2, var3);
}
public void mouseReleased(int var1, int var2, int var3) {
this.customScreen.mouseReleased(var1, var2, var3);
}
public void onGuiClosed() {
this.customScreen.onGuiClosed();
}
public void updateScreen() {
this.customScreen.updateScreen();
}
public void keyTyped(char var1, int var2) {
super.keyTyped(var1, var2);
this.customScreen.keyTyped(var1, var2);
}
public CustomScreen getCustomScreen() {
return this.customScreen;
}
public WrappedGuiScreen(CustomScreen var1) {
this.customScreen = var1;
}
}

View File

@ -1,6 +1,8 @@
package net.silentclient; package net.silentclient;
import net.fabricmc.api.ClientModInitializer; import net.fabricmc.api.ClientModInitializer;
import net.silentclient.bridge.BridgeImpl;
import net.silentclient.core.BridgeManager;
/** /**
* @author refactoring * @author refactoring
@ -8,7 +10,9 @@ import net.fabricmc.api.ClientModInitializer;
public class SCEntrypoint implements ClientModInitializer { public class SCEntrypoint implements ClientModInitializer {
@Override @Override
public void onInitializeClient() { public void onInitializeClient() {
// Things like rescources are not initialized yet. // Things like resources are not initialized yet.
// Proceed with caution. // Proceed with caution.
BridgeManager.INSTANCE.setBridge(new BridgeImpl());
} }
} }

View File

@ -0,0 +1,21 @@
package net.silentclient.bridge;
import net.legacyfabric.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.minecraft.client.settings.KeyBinding;
import net.silentclient.bridge.impl.WrappedGuiScreenImpl;
import net.silentclient.client.gui.CustomScreen;
import net.silentclient.client.gui.WrappedGuiScreenBridge;
import net.silentclient.client.input.KeyBindingBridge;
import net.silentclient.core.Bridge;
public class BridgeImpl implements Bridge {
@Override
public KeyBindingBridge initKeyBinding(String name, int keyCode, String cat) {
return (KeyBindingBridge) KeyBindingHelper.registerKeyBinding(new KeyBinding(name, keyCode, cat));
}
@Override
public WrappedGuiScreenBridge initCustomScreen(CustomScreen screen) {
return new WrappedGuiScreenImpl(screen);
}
}

View File

@ -0,0 +1,108 @@
package net.silentclient.bridge.impl;
import net.minecraft.client.gui.GuiScreen;
import net.silentclient.client.gui.CustomScreen;
import net.silentclient.client.gui.WrappedGuiScreenBridge;
import net.silentclient.core.BridgeManager;
public class WrappedGuiScreenImpl extends GuiScreen implements WrappedGuiScreenBridge {
public CustomScreen customScreen;
public WrappedGuiScreenImpl(CustomScreen customScreen) {
this.customScreen = customScreen;
}
@Override
public void bridge$drawScreen(int mouseX, int mouseY, float pTicks) {
this.drawScreen(mouseX, mouseX, pTicks);
}
@Override
public void bridge$mouseClicked(int mouseX, int mouseY, int mouseButton) {
this.mouseClicked(mouseX, mouseY, mouseButton);
}
@Override
public void bridge$mouseReleased(int mouseX, int mouseY, int mouseButton) {
this.mouseReleased(mouseX, mouseY, mouseButton);
}
@Override
public void bridge$onGuiClosed() {
this.onGuiClosed();
}
@Override
public void bridge$updateScreen() {
this.updateScreen();
}
@Override
public void bridge$keyTyped(char keyChar, int keyCode) {
this.keyTyped(keyChar, keyCode);
}
@Override
public void bridge$handleMouseInput() {
this.handleMouseInput();
}
@Override
public boolean bridge$allowUserInput() {
return this.allowUserInput;
}
@Override
public boolean bridge$doesGuiPauseGame() {
return this.doesGuiPauseGame();
}
@Override
public void drawScreen(int mx, int my, float delta) {
super.drawScreen(mx, my, delta);
this.customScreen.drawScreen(mx, my, delta);
BridgeManager.INSTANCE.setCurrentScreen(customScreen);
}
@Override
protected void mouseClicked(int mx, int my, int btn) {
super.mouseClicked(mx, my, btn);
this.customScreen.mouseClicked(mx, my, btn);
}
@Override
protected void mouseReleased(int mx, int my, int btn) {
super.mouseReleased(mx, my, btn);
this.customScreen.mouseReleased(mx, my, btn);
}
@Override
public void onGuiClosed() {
super.onGuiClosed();
this.customScreen.onGuiClosed();
}
@Override
public void updateScreen() {
super.updateScreen();
this.customScreen.updateScreen();
}
@Override
protected void keyTyped(char typedChar, int key) {
super.keyTyped(typedChar, key);
this.customScreen.keyTyped(typedChar, key);
}
@Override
public void handleMouseInput() {
super.handleMouseInput();
}
@Override
public CustomScreen getCustomScreen() {
return customScreen;
}
}

View File

@ -1,6 +1,6 @@
package net.silentclient.client.mixin.injection.mixins; package net.silentclient.client.mixin.injection.mixins;
import dev.refactoring.bridge.client.gui.GuiScreenBridge; import net.silentclient.client.gui.GuiScreenBridge;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.Gui; import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.GuiScreen;

View File

@ -1,9 +1,9 @@
package net.silentclient.client.mixin.injection.mixins; package net.silentclient.client.mixin.injection.mixins;
import dev.refactoring.bridge.client.MinecraftBridge; import net.silentclient.client.MinecraftBridge;
import dev.refactoring.bridge.client.gui.GuiScreenBridge; import net.silentclient.client.gui.GuiScreenBridge;
import dev.refactoring.bridge.client.gui.WrappedGuiScreenBridge; import net.silentclient.client.gui.WrappedGuiScreenBridge;
import dev.refactoring.bridge.core.BridgeManager; import net.silentclient.core.BridgeManager;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.*; import net.minecraft.client.gui.*;
import net.minecraft.client.multiplayer.WorldClient; import net.minecraft.client.multiplayer.WorldClient;