Some needed features

This commit is contained in:
astatin3
2024-07-22 14:52:25 -06:00
parent 7b1b607b3d
commit b442bc02e7
19 changed files with 89 additions and 28 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+3 -3
View File
@@ -1,10 +1,10 @@
commonProperties
fabric.development=true
fabric.remapClasspathFile=/home/astatin3/Documents/GitHub/no-more-render/.gradle/loom-cache/remapClasspath.txt
log4j.configurationFile=/home/astatin3/Documents/GitHub/no-more-render/.gradle/loom-cache/log4j.xml
fabric.remapClasspathFile=/home/astatin3/GitHub/no-more-render/.gradle/loom-cache/remapClasspath.txt
log4j.configurationFile=/home/astatin3/GitHub/no-more-render/.gradle/loom-cache/log4j.xml
log4j2.formatMsgNoLookups=true
fabric.gameJarPath=/home/astatin3/.gradle/caches/fabric-loom/minecraftMaven/net/minecraft/minecraft-common/1.21-net.fabricmc.yarn.1_21.1.21+build.2-v2/minecraft-common-1.21-net.fabricmc.yarn.1_21.1.21+build.2-v2.jar
fabric.classPathGroups=/home/astatin3/Documents/GitHub/no-more-render/build/classes/java/main:/home/astatin3/Documents/GitHub/no-more-render/build/resources/main:/home/astatin3/Documents/GitHub/no-more-render/build/classes/java/client:/home/astatin3/Documents/GitHub/no-more-render/build/resources/client
fabric.classPathGroups=/home/astatin3/GitHub/no-more-render/build/classes/java/main:/home/astatin3/GitHub/no-more-render/build/resources/main:/home/astatin3/GitHub/no-more-render/build/classes/java/client:/home/astatin3/GitHub/no-more-render/build/resources/client
fabric.log.disableAnsi=false
clientArgs
--assetIndex
+1
View File
@@ -2,6 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/modules/com.astatin3.no-more-render.client.iml" filepath="$PROJECT_DIR$/.idea/modules/com.astatin3.no-more-render.client.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/com.astatin3.no-more-render.main.iml" filepath="$PROJECT_DIR$/.idea/modules/com.astatin3.no-more-render.main.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/no-more-render.client.iml" filepath="$PROJECT_DIR$/.idea/modules/no-more-render.client.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/modules/no-more-render.main.iml" filepath="$PROJECT_DIR$/.idea/modules/no-more-render.main.iml" />
+2 -5
View File
@@ -6,16 +6,13 @@
<autoDetectTypes>
<platformType>FABRIC</platformType>
<platformType>MIXIN</platformType>
<platformType>MCP</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
<component name="McpModuleSettings">
<option name="srgType" value="SRG" />
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<orderEntry type="sourceFolder" forTests="false" />
<option name="minecraftVersion" value="1.21" />
</component>
</module>
+2 -1
View File
@@ -6,12 +6,13 @@
<autoDetectTypes>
<platformType>FABRIC</platformType>
<platformType>MIXIN</platformType>
<platformType>MCP</platformType>
</autoDetectTypes>
<projectReimportVersion>1</projectReimportVersion>
</configuration>
</facet>
</component>
<component name="McpModuleSettings">
<option name="srgType" value="SRG" />
<option name="minecraftVersion" value="1.21" />
</component>
</module>
+10 -10
View File
@@ -1,14 +1,14 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="Minecraft Client" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="/usr/lib/jvm/temurin-22-jdk-amd64" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<option name="MAIN_CLASS_NAME" value="net.fabricmc.devlaunchinjector.Main" />
<module name="no-more-render.main" />
<shortenClasspath name="ARGS_FILE" />
<option name="VM_PARAMETERS" value="-Dfabric.dli.config=$USER_HOME$/GitHub/no-more-render/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=client -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotClient" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/run/" />
<configuration default="false" factoryName="Application" name="Minecraft Client" type="Application">
<option name="ALTERNATIVE_JRE_PATH" value="/usr/lib/jvm/temurin-22-jdk-amd64"/>
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true"/>
<option name="MAIN_CLASS_NAME" value="net.fabricmc.devlaunchinjector.Main"/>
<module name="no-more-render.main"/>
<shortenClasspath name="ARGS_FILE"/>
<option name="VM_PARAMETERS" value="-Dfabric.dli.config=$USER_HOME$/GitHub/no-more-render/.gradle/loom-cache/launch.cfg -Dfabric.dli.env=client -Dfabric.dli.main=net.fabricmc.loader.impl.launch.knot.KnotClient"/>
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/run/"/>
<method v="2">
<option name="Make" enabled="true" />
<option enabled="true" name="Make"/>
</method>
</configuration>
<classpathModifications/></configuration>
</component>
+1 -1
View File
@@ -12,5 +12,5 @@
</envs>
<shortenClasspath name="ARGS_FILE"/>
<classpathModifications><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.16.0/4e3eb3d79888d76b54e28b350915b5dc3919c9de/commons-codec-1.16.0.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-opengl/3.3.3/2f6b0147078396a58979125a4c947664e98293a/lwjgl-opengl-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.16/51cf043c87253c9f58b539c9f7e44c8894223850/httpcore-4.4.16.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl/3.3.3/29589b5f87ed335a6c7e7ee6a5775f81f97ecb84/lwjgl-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-openal/3.3.3/daada81ceb5fc0c291fbfdd4433cb8d9423577f2/lwjgl-openal-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/com.ibm.icu/icu4j/73.2/61ad4ef7f9131fcf6d25c34b817f90d6da06c9e9/icu4j-73.2.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-tinyfd/3.3.3/82d755ca94b102e9ca77283b9e2dc46d1b15fbe5/lwjgl-tinyfd-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/com.mojang/text2speech/1.17.9/3cad216e3a7f0c19b4b394388bc9ffc446f13b14/text2speech-1.17.9.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/com.mojang/blocklist/1.0.10/5c685c5ffa94c4cd39496c7184c1d122e515ecef/blocklist-1.0.10.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-freetype/3.3.3/a0db6c84a8becc8ca05f9dbfa985edc348a824c7/lwjgl-freetype-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/com.mojang/patchy/2.2.10/da05971b07cbb379d002cf7eaec6a2048211fefc/patchy-2.2.10.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-compress/1.26.0/659feffdd12280201c8aacb8f7be94f9a883c824/commons-compress-1.26.0.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.jcraft/jorbis/0.0.17/8872d22b293e8f5d7d56ff92be966e6dc28ebdc6/jorbis-0.0.17.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.5.13/e5f6cae5ca7ecaac1ec2827a9e2d65ae2869cada/httpclient-4.5.13.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-stb/3.3.3/25dd6161988d7e65f71d5065c99902402ee32746/lwjgl-stb-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.2/4bfc12adfe4842bf07b657f0369c4cb522955686/commons-logging-1.2.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-glfw/3.3.3/efa1eb78c5ccd840e9f329717109b5e892d72f8e/lwjgl-glfw-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-jemalloc/3.3.3/b543467b7ff3c6920539a88ee602d34098628be5/lwjgl-jemalloc-3.3.3.jar"/></classpathModifications></configuration>
<classpathModifications><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-opengl/3.3.3/2f6b0147078396a58979125a4c947664e98293a/lwjgl-opengl-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl/3.3.3/29589b5f87ed335a6c7e7ee6a5775f81f97ecb84/lwjgl-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/com.mojang/blocklist/1.0.10/5c685c5ffa94c4cd39496c7184c1d122e515ecef/blocklist-1.0.10.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/com.mojang/patchy/2.2.10/da05971b07cbb379d002cf7eaec6a2048211fefc/patchy-2.2.10.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-glfw/3.3.3/efa1eb78c5ccd840e9f329717109b5e892d72f8e/lwjgl-glfw-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpcore/4.4.16/51cf043c87253c9f58b539c9f7e44c8894223850/httpcore-4.4.16.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-tinyfd/3.3.3/82d755ca94b102e9ca77283b9e2dc46d1b15fbe5/lwjgl-tinyfd-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.apache.commons/commons-compress/1.26.0/659feffdd12280201c8aacb8f7be94f9a883c824/commons-compress-1.26.0.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/com.mojang/text2speech/1.17.9/3cad216e3a7f0c19b4b394388bc9ffc446f13b14/text2speech-1.17.9.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-jemalloc/3.3.3/b543467b7ff3c6920539a88ee602d34098628be5/lwjgl-jemalloc-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.jcraft/jorbis/0.0.17/8872d22b293e8f5d7d56ff92be966e6dc28ebdc6/jorbis-0.0.17.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/com.ibm.icu/icu4j/73.2/61ad4ef7f9131fcf6d25c34b817f90d6da06c9e9/icu4j-73.2.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.apache.httpcomponents/httpclient/4.5.13/e5f6cae5ca7ecaac1ec2827a9e2d65ae2869cada/httpclient-4.5.13.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-stb/3.3.3/25dd6161988d7e65f71d5065c99902402ee32746/lwjgl-stb-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/commons-logging/commons-logging/1.2/4bfc12adfe4842bf07b657f0369c4cb522955686/commons-logging-1.2.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.16.0/4e3eb3d79888d76b54e28b350915b5dc3919c9de/commons-codec-1.16.0.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-freetype/3.3.3/a0db6c84a8becc8ca05f9dbfa985edc348a824c7/lwjgl-freetype-3.3.3.jar"/><entry exclude="true" path="/home/astatin3/.gradle/caches/modules-2/files-2.1/org.lwjgl/lwjgl-openal/3.3.3/daada81ceb5fc0c291fbfdd4433cb8d9423577f2/lwjgl-openal-3.3.3.jar"/></classpathModifications></configuration>
</component>
+19
View File
@@ -1,3 +1,22 @@
# no-more-render
A Fabric mod that removes Minecraft's window rendering code, to create a headless CLI version
## Usage
This mod runs a tcp server locally that allows for a command line interface
The mod runs on the port 65000, and increments this value by 1 if it cannot access that port.
You can connect to it via running `ncat localhost 65000` or other similar command
### Comamnds:
```
listelements/elems - List widgets on the screen
clickelement/celem <elem index> - Click an element on the screen
writeelement/welem <elem index> <text> - Write text into a compatable element
key <key> - Press and release a key
keydown <key> - Press a key
keyup <key> - Release a key
connect <Addr>:[Port] - Forcibly connect to a server
quit/exit - Close the game
```
@@ -7,10 +7,14 @@ import net.minecraft.client.gl.WindowFramebuffer;
import net.minecraft.client.gui.Drawable;
import net.minecraft.client.gui.Element;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.client.gui.screen.multiplayer.ConnectScreen;
import net.minecraft.client.gui.screen.world.WorldListWidget;
import net.minecraft.client.gui.widget.*;
import net.minecraft.client.render.GameRenderer;
import org.jetbrains.annotations.Nullable;
import org.lwjgl.glfw.GLFW;
import net.minecraft.client.network.ServerAddress;
import net.minecraft.client.network.ServerInfo;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
@@ -20,6 +24,7 @@ import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import java.io.*;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.ArrayList;
@@ -41,11 +46,20 @@ public class HeadlessMinecraftClient {
@Shadow private Thread thread;
@Unique final MinecraftClient self = (MinecraftClient)(Object)this;
@Inject(method = "<init>", at = @At("TAIL"))
private void onGameLoaded(RunArgs args, CallbackInfo ci) {
// AddonTemplate.LOG.info("Hello from ExampleMixin!");
System.out.println("#########################################");
System.out.println("#########################################");
System.out.println("(no-more-render) This client is running a mod that disables Minecraft from opening a window!");
System.out.println("#########################################");
System.out.println("#########################################");
startCommandThread();
self.gameRenderer.onResized(10, 10);
}
@@ -53,9 +67,19 @@ public class HeadlessMinecraftClient {
Thread commandThread = new Thread(() -> {
// BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String line;
int i = 0;
try {
ServerSocket serverSocket = new ServerSocket(65000);
System.out.println("Server is listening on port " + 65000);
ServerSocket serverSocket;
while(true){
try {
serverSocket = new ServerSocket(65000+i, 50, InetAddress.getByName("127.0.0.1"));
System.out.println("Server is listening on port " + (65000+i));
break;
} catch (java.net.BindException e){
System.out.println("port " + (65000+i) + " failed, trying another");
i++;
}
}
while (true) {
Socket socket = serverSocket.accept();
@@ -90,10 +114,8 @@ public class HeadlessMinecraftClient {
commandThread.start();
}
@Unique final MinecraftClient self = (MinecraftClient)(Object)this;
private void parseCommand(String command) {
if(command == null) return;
String[] split = command.split(" ");
try {
switch (split[0].toLowerCase()) {
@@ -101,9 +123,6 @@ public class HeadlessMinecraftClient {
case "exit":
self.stop();
break;
case "tick":
self.tick();
break;
case "listelements":
case "elems":
listElements();
@@ -131,6 +150,23 @@ public class HeadlessMinecraftClient {
simulateKeyUp(split[1]);
}
break;
case "connect":
if (split.length == 1)
writer.println("You must specify a server address!");
if (split.length > 3)
writer.println("Too many arguments!");
else {
int port = 25565;
if (split.length == 3)
port = Integer.parseInt(split[2]);
writer.println("Connecting to: " + split[1] + ":" + port);
connect_to_serv(new ServerAddress(split[1], port));
}
break;
default:
writer.println("Unknown command: " + command);
}
@@ -311,4 +347,11 @@ public class HeadlessMinecraftClient {
return GLFW.GLFW_KEY_UNKNOWN;
}
public void connect_to_serv(ServerAddress addr){
self.execute(() -> {
ConnectScreen.connect(self.currentScreen, self, addr, new ServerInfo("Test", addr.getAddress(), ServerInfo.ServerType.OTHER), true, null);
});
}
}