diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..3c68280 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -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" +} diff --git a/src/main/java/net/FatalCodes/shadow/Shadow.java b/src/main/java/net/FatalCodes/shadow/Shadow.java new file mode 100644 index 0000000..fa72cd4 --- /dev/null +++ b/src/main/java/net/FatalCodes/shadow/Shadow.java @@ -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(); + } +} diff --git a/src/main/java/net/FatalCodes/shadow/module/Category.java b/src/main/java/net/FatalCodes/shadow/module/Category.java new file mode 100644 index 0000000..b153a86 --- /dev/null +++ b/src/main/java/net/FatalCodes/shadow/module/Category.java @@ -0,0 +1,5 @@ +package net.FatalCodes.shadow.module; + +public enum Category { + HUD, ADMIN +} diff --git a/src/main/java/net/FatalCodes/shadow/module/Module.java b/src/main/java/net/FatalCodes/shadow/module/Module.java new file mode 100644 index 0000000..f267e71 --- /dev/null +++ b/src/main/java/net/FatalCodes/shadow/module/Module.java @@ -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); + } + + + + + +} \ No newline at end of file diff --git a/src/main/java/net/FatalCodes/shadow/module/ModuleManager.java b/src/main/java/net/FatalCodes/shadow/module/ModuleManager.java new file mode 100644 index 0000000..823478a --- /dev/null +++ b/src/main/java/net/FatalCodes/shadow/module/ModuleManager.java @@ -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 mods; + + public ModuleManager() { + mods = new ArrayList(); + + } + + public static void newMod(Module m) { + mods.add(m); + } + + public static ArrayList 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)); + } + +} \ No newline at end of file diff --git a/src/main/java/net/FatalCodes/shadow/module/RenderModule.java b/src/main/java/net/FatalCodes/shadow/module/RenderModule.java new file mode 100644 index 0000000..623a8cd --- /dev/null +++ b/src/main/java/net/FatalCodes/shadow/module/RenderModule.java @@ -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; + } + +} \ No newline at end of file diff --git a/src/main/java/net/minecraft/client/Minecraft.java b/src/main/java/net/minecraft/client/Minecraft.java index da70ffb..a878e70 100644 --- a/src/main/java/net/minecraft/client/Minecraft.java +++ b/src/main/java/net/minecraft/client/Minecraft.java @@ -18,6 +18,7 @@ import org.apache.commons.lang3.Validate; import com.google.common.collect.Lists; +import net.FatalCodes.shadow.Shadow; import net.lax1dude.eaglercraft.v1_8.Display; import net.lax1dude.eaglercraft.v1_8.EagRuntime; import net.lax1dude.eaglercraft.v1_8.HString; @@ -455,6 +456,7 @@ public class Minecraft implements IThreadListener { SkinPreviewRenderer.initialize(); this.checkGLError("Post startup"); this.ingameGUI = new GuiIngame(this); + Shadow.ShadowClientStartup(); ServerList.initServerList(this); EaglerProfile.read(); @@ -1377,6 +1379,7 @@ public class Minecraft implements IThreadListener { if (this.currentScreen != null) { this.currentScreen.handleKeyboardInput(); } else { + Shadow.moduleManager.onKey(k); if (k == 1 || (k > -1 && k == this.gameSettings.keyBindClose.getKeyCode())) { this.displayInGameMenu(); } diff --git a/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java b/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java index 6535160..b494814 100644 --- a/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java +++ b/src/main/java/net/minecraft/client/entity/EntityPlayerSP.java @@ -1,5 +1,6 @@ package net.minecraft.client.entity; +import net.FatalCodes.shadow.Shadow; import net.minecraft.client.Minecraft; import net.minecraft.client.audio.MovingSoundMinecartRiding; import net.minecraft.client.audio.PositionedSoundRecord; @@ -594,6 +595,7 @@ public class EntityPlayerSP extends AbstractClientPlayer { * to react to sunlight and start to burn. */ public void onLivingUpdate() { + Shadow.moduleManager.onUpdate(); if (this.sprintingTicksLeft > 0) { --this.sprintingTicksLeft; if (this.sprintingTicksLeft == 0) { diff --git a/src/main/java/net/minecraft/client/gui/GuiScreen.java b/src/main/java/net/minecraft/client/gui/GuiScreen.java index 31f8446..10c9b59 100644 --- a/src/main/java/net/minecraft/client/gui/GuiScreen.java +++ b/src/main/java/net/minecraft/client/gui/GuiScreen.java @@ -47,8 +47,8 @@ public abstract class GuiScreen extends Gui implements GuiYesNoCallback { private static final Splitter NEWLINE_SPLITTER = Splitter.on('\n'); protected Minecraft mc; protected RenderItem itemRender; - public int width; - public int height; + public static int width; + public static int height; /**+ * A list of all the buttons in this container. */ diff --git a/src/main/java/net/minecraft/client/renderer/EntityRenderer.java b/src/main/java/net/minecraft/client/renderer/EntityRenderer.java index f9e1ab2..a39e511 100644 --- a/src/main/java/net/minecraft/client/renderer/EntityRenderer.java +++ b/src/main/java/net/minecraft/client/renderer/EntityRenderer.java @@ -13,6 +13,7 @@ import java.util.concurrent.Callable; import com.google.common.base.Predicate; import com.google.common.base.Predicates; +import net.FatalCodes.shadow.Shadow; import net.lax1dude.eaglercraft.v1_8.Display; import net.lax1dude.eaglercraft.v1_8.Mouse; import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; @@ -1267,6 +1268,7 @@ public class EntityRenderer implements IResourceManagerReloadListener { } this.mc.mcProfiler.endStartSection("hand"); + Shadow.moduleManager.onRender(); if (this.renderHand) { GlStateManager.clear(GL_DEPTH_BUFFER_BIT); this.renderHand(partialTicks, pass);