module system

This commit is contained in:
FatalEagler 2023-08-29 09:18:34 +00:00
parent 6185e12153
commit 8834e133bd
10 changed files with 336 additions and 2 deletions

View File

@ -0,0 +1,27 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/java
{
"name": "Java",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/java:1-11-bullseye",
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "none",
"installMaven": "false",
"installGradle": "false"
}
}
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "java -version",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}

View File

@ -0,0 +1,12 @@
package net.FatalCodes.shadow;
import net.FatalCodes.shadow.module.ModuleManager;
public class Shadow {
public static ModuleManager moduleManager;
public static void ShadowClientStartup() {
moduleManager = new ModuleManager();
}
}

View File

@ -0,0 +1,5 @@
package net.FatalCodes.shadow.module;
public enum Category {
HUD, ADMIN
}

View File

@ -0,0 +1,104 @@
package net.FatalCodes.shadow.module;
import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.multiplayer.PlayerControllerMP;
import net.minecraft.client.multiplayer.WorldClient;
import net.minecraft.network.Packet;
public class Module {
protected Minecraft mc = Minecraft.getMinecraft();
private String name;
private int key;
private boolean toggled;
private Category category;
public Module(String nm, int k, Category c) {
name = nm;
key = k;
category = c;
toggled = false;
setup();
}
public void toggle() {
toggled = !toggled;
if(toggled) {
onEnable();
}else {
onDisable();
}
}
public void onEnable() {}
public void onDisable() {}
public void onUpdate() {}
public void onRender() {}
public void setup() {}
public Minecraft getMc() {
return mc;
}
public void setMc(Minecraft mc) {
this.mc = mc;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getKey() {
return key;
}
public void setKey(int key) {
this.key = key;
}
public boolean isToggled() {
return toggled;
}
public void setToggled(boolean toggled) {
this.toggled = toggled;
}
public Category getCategory() {
return category;
}
public void setCategory(Category category) {
this.category = category;
}
protected EntityPlayerSP player() {
return mc.thePlayer;
}
protected PlayerControllerMP playerController() {
return mc.playerController;
}
protected WorldClient world() {
return mc.theWorld;
}
@SuppressWarnings("rawtypes")
protected void sendPacket(Packet p) {
player().sendQueue.addToSendQueue(p);
}
}

View File

@ -0,0 +1,51 @@
package net.FatalCodes.shadow.module;
import java.util.ArrayList;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ChatComponentText;
public class ModuleManager {
private static ArrayList<Module> mods;
public ModuleManager() {
mods = new ArrayList<Module>();
}
public static void newMod(Module m) {
mods.add(m);
}
public static ArrayList<Module> getModules(){
return mods;
}
public static void onUpdate() {
for(Module m : mods) {
m.onUpdate();
}
}
public static void onRender() {
for(Module m : mods) {
m.onRender();
}
}
public static void onKey(int k) {
for(Module m : mods) {
if(m.getKey() == k) {
m.toggle();
}
}
}
public static void addChatMessage(String message) {
message = "\2479" + "Shadow Client" + "\2477: " + message;
Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(message));
}
}

View File

@ -0,0 +1,128 @@
package net.FatalCodes.shadow.module;
import net.lax1dude.eaglercraft.v1_8.Mouse;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.GuiScreen;
public class RenderModule extends Module {
public boolean dragging = false;
public RenderModule(String name, int k, Category cat, int x, int y, int width, int height) {
super(name, k, cat);
this.x = x;
this.y = y;
this.width = width;
this.height = height;
}
public int x,y,width,height;
public int lastX;
public int lastY;
public void draw() {
}
public void Resize() {
if((getX() + getWidth()) > GuiScreen.width) {
this.x = GuiScreen.width - getWidth();
dragging = false;
} else if ((getY() + getHeight()) > GuiScreen.height) {
this.y = GuiScreen.height - getHeight();
dragging = false;
} else if ((getX()) < 0) {
this.x = 0;
dragging = false;
} else if ((getY()) < 0) {
this.y = 0;
dragging = false;
} else if (getX() <= 0 && getY() < 0) {
this.y = 0;
this.x = 0;
dragging = false;
} else if (getX() + getWidth() > GuiScreen.width && getY() < 0) {
this.x = GuiScreen.width - getWidth();
this.y = 0;
dragging = false;
} else if (getX() + getWidth() > GuiScreen.width && getY() + getHeight() > GuiScreen.height) {
this.x = GuiScreen.width - getWidth();
this.y = GuiScreen.height - getHeight();
dragging = false;
} else if (getY() + getHeight() > GuiScreen.height && getX() < 0) {
this.x = GuiScreen.width - getWidth();
this.y = GuiScreen.height - getHeight();
dragging = false;
}
}
private void draggingFix(int mouseX, int mouseY) {
if (this.dragging) {
this.x = mouseX + this.lastX;
this.y = mouseY + this.lastY;
if(!Mouse.isButtonDown(0)) this.dragging = false;
if(this.x >= GuiScreen.width - getWidth()) {
this.dragging = false;
}
if(this.y >= GuiScreen.height - getHeight()) {
this.dragging = false;
}
}
}
public void renderLayout(int mouseX, int mouseY) {
Resize();
boolean mouseOver = mouseX >= getX() && mouseY >= getY() && mouseX < getX() + getWidth() && mouseY < getY() + this.getHeight();
boolean mouseOverX = (mouseX >= this.x && mouseX <= this.x+this.getWidth());
boolean mouseOverY = (mouseY >= this.y && mouseY <= this.y+this.getHeight());
boolean drag = (mouseOverX && mouseOverY && Mouse.isButtonDown(0));
draggingFix(mouseX, mouseY);
if(drag) {
if (!this.dragging) {
this.lastX = x - mouseX;
this.lastY = y - mouseY;
this.dragging = true;
}
}
draw();
Gui.drawRect(this.x, this.y, this.x + this.getWidth(), this.y+this.getHeight(), 0x50FFFFFF);
Gui.drawRect(this.x, this.y, this.x+this.getWidth(), this.y+1, 0xFFFFFFFF);
Gui.drawRect(this.x, this.y, this.x+1, this.y+getHeight(), 0xFFFFFFFF);
Gui.drawRect(this.x+this.getWidth()-1, this.y, this.x+getWidth(), this.y+this.getHeight(), 0xFFFFFFFF);
Gui.drawRect(this.x, this.y+this.getHeight()-1, this.x+getWidth(), this.y+this.getHeight(), 0xFFFFFFFF);
}
public int getX() {
return x;
}
public int getY() {
return y;
}
public void setX(int x) {
this.x = x;
}
public void setY(int y) {
this.y = y;
}
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public void setWidth(int width) {
this.width = width;
}
public void setHeight(int height) {
this.height = height;
}
}

View File

@ -18,6 +18,7 @@ import org.apache.commons.lang3.Validate;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.FatalCodes.shadow.Shadow;
import net.lax1dude.eaglercraft.v1_8.Display; import net.lax1dude.eaglercraft.v1_8.Display;
import net.lax1dude.eaglercraft.v1_8.EagRuntime; import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.HString; import net.lax1dude.eaglercraft.v1_8.HString;
@ -455,6 +456,7 @@ public class Minecraft implements IThreadListener {
SkinPreviewRenderer.initialize(); SkinPreviewRenderer.initialize();
this.checkGLError("Post startup"); this.checkGLError("Post startup");
this.ingameGUI = new GuiIngame(this); this.ingameGUI = new GuiIngame(this);
Shadow.ShadowClientStartup();
ServerList.initServerList(this); ServerList.initServerList(this);
EaglerProfile.read(); EaglerProfile.read();
@ -1377,6 +1379,7 @@ public class Minecraft implements IThreadListener {
if (this.currentScreen != null) { if (this.currentScreen != null) {
this.currentScreen.handleKeyboardInput(); this.currentScreen.handleKeyboardInput();
} else { } else {
Shadow.moduleManager.onKey(k);
if (k == 1 || (k > -1 && k == this.gameSettings.keyBindClose.getKeyCode())) { if (k == 1 || (k > -1 && k == this.gameSettings.keyBindClose.getKeyCode())) {
this.displayInGameMenu(); this.displayInGameMenu();
} }

View File

@ -1,5 +1,6 @@
package net.minecraft.client.entity; package net.minecraft.client.entity;
import net.FatalCodes.shadow.Shadow;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.client.audio.MovingSoundMinecartRiding; import net.minecraft.client.audio.MovingSoundMinecartRiding;
import net.minecraft.client.audio.PositionedSoundRecord; import net.minecraft.client.audio.PositionedSoundRecord;
@ -594,6 +595,7 @@ public class EntityPlayerSP extends AbstractClientPlayer {
* to react to sunlight and start to burn. * to react to sunlight and start to burn.
*/ */
public void onLivingUpdate() { public void onLivingUpdate() {
Shadow.moduleManager.onUpdate();
if (this.sprintingTicksLeft > 0) { if (this.sprintingTicksLeft > 0) {
--this.sprintingTicksLeft; --this.sprintingTicksLeft;
if (this.sprintingTicksLeft == 0) { if (this.sprintingTicksLeft == 0) {

View File

@ -47,8 +47,8 @@ public abstract class GuiScreen extends Gui implements GuiYesNoCallback {
private static final Splitter NEWLINE_SPLITTER = Splitter.on('\n'); private static final Splitter NEWLINE_SPLITTER = Splitter.on('\n');
protected Minecraft mc; protected Minecraft mc;
protected RenderItem itemRender; protected RenderItem itemRender;
public int width; public static int width;
public int height; public static int height;
/**+ /**+
* A list of all the buttons in this container. * A list of all the buttons in this container.
*/ */

View File

@ -13,6 +13,7 @@ import java.util.concurrent.Callable;
import com.google.common.base.Predicate; import com.google.common.base.Predicate;
import com.google.common.base.Predicates; import com.google.common.base.Predicates;
import net.FatalCodes.shadow.Shadow;
import net.lax1dude.eaglercraft.v1_8.Display; import net.lax1dude.eaglercraft.v1_8.Display;
import net.lax1dude.eaglercraft.v1_8.Mouse; import net.lax1dude.eaglercraft.v1_8.Mouse;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
@ -1267,6 +1268,7 @@ public class EntityRenderer implements IResourceManagerReloadListener {
} }
this.mc.mcProfiler.endStartSection("hand"); this.mc.mcProfiler.endStartSection("hand");
Shadow.moduleManager.onRender();
if (this.renderHand) { if (this.renderHand) {
GlStateManager.clear(GL_DEPTH_BUFFER_BIT); GlStateManager.clear(GL_DEPTH_BUFFER_BIT);
this.renderHand(partialTicks, pass); this.renderHand(partialTicks, pass);