From 30670ce446e4c5d1ad686e9de263453a79824042 Mon Sep 17 00:00:00 2001 From: radmanplays <95340057+radmanplays@users.noreply.github.com> Date: Thu, 22 Feb 2024 16:39:44 +0330 Subject: [PATCH] last commit until v1.2 --- .../client/ClientBrandRetriever.edit.java | 9 ++- .../net/minecraft/client/Minecraft.edit.java | 14 ++++- .../client/gui/GuiMainMenu.edit.java | 12 ++-- .../minecraft/client/gui/GuiScreen.edit.java | 55 +++++++++++-------- .../java/net/eaglerforge/api/LoggerAPI.java | 5 +- .../main/java/net/eaglerforge/api/ModAPI.java | 11 ++++ .../java/net/eaglerforge/api/ModLoader.java | 4 ++ .../java/net/eaglerforge/api/PlatformAPI.java | 10 ++++ .../eaglercraft/v1_8/EaglercraftVersion.java | 9 ++- 9 files changed, 96 insertions(+), 33 deletions(-) diff --git a/patches/minecraft/net/minecraft/client/ClientBrandRetriever.edit.java b/patches/minecraft/net/minecraft/client/ClientBrandRetriever.edit.java index 31000e9..ad415d7 100644 --- a/patches/minecraft/net/minecraft/client/ClientBrandRetriever.edit.java +++ b/patches/minecraft/net/minecraft/client/ClientBrandRetriever.edit.java @@ -5,8 +5,13 @@ # Version: 1.0 # Author: lax1dude -> CHANGE 4 : 5 @ 4 : 5 +> INSERT 2 : 4 @ 2 -~ return "eagler"; ++ import static net.lax1dude.eaglercraft.v1_8.EaglercraftVersion.projectForkName; ++ + +> CHANGE 2 : 3 @ 2 : 3 + +~ return projectForkName; > EOF diff --git a/patches/minecraft/net/minecraft/client/Minecraft.edit.java b/patches/minecraft/net/minecraft/client/Minecraft.edit.java index 781a5d6..cb4a2a9 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.edit.java +++ b/patches/minecraft/net/minecraft/client/Minecraft.edit.java @@ -20,10 +20,11 @@ > DELETE 1 @ 1 : 4 -> CHANGE 1 : 55 @ 1 : 4 +> CHANGE 1 : 56 @ 1 : 4 ~ ~ import net.eaglerforge.EaglerForge; +~ import net.eaglerforge.api.BaseData; ~ import net.eaglerforge.api.ModAPI; ~ import net.eaglerforge.api.ModData; ~ import net.eaglerforge.api.ModLoader; @@ -613,8 +614,17 @@ ~ DebugFramebufferView.switchView(1); ~ } -> CHANGE 5 : 6 @ 5 : 6 +> CHANGE 5 : 15 @ 5 : 6 +~ ModData event = new ModData(); +~ event.set("key", k); +~ event.set("preventDefault", false); +~ BaseData newEvent = ModAPI.callEvent("key", event); +~ +~ if (newEvent.has("preventDefault") && newEvent.getBoolean("preventDefault")) { +~ return; +~ } +~ k = newEvent.has("key") ? newEvent.getInt("key") : k; ~ if (k == 1 || (k > -1 && k == this.gameSettings.keyBindClose.getKeyCode())) { > INSERT 11 : 18 @ 11 diff --git a/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.edit.java b/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.edit.java index 72abf3b..14c803d 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.edit.java +++ b/patches/minecraft/net/minecraft/client/gui/GuiMainMenu.edit.java @@ -5,7 +5,11 @@ # Version: 1.0 # Author: lax1dude -> DELETE 2 @ 2 : 3 +> CHANGE 2 : 5 @ 2 : 3 + +~ import static net.eaglerforge.api.ModLoader.returntotalloadedmods; +~ import static net.lax1dude.eaglercraft.v1_8.EaglercraftVersion.*; +~ > DELETE 3 @ 3 : 4 @@ -51,9 +55,10 @@ > DELETE 3 @ 3 : 5 -> CHANGE 4 : 5 @ 4 : 11 +> CHANGE 4 : 6 @ 4 : 11 ~ import net.eaglerforge.gui.ModGUI; +~ import org.teavm.jso.JSBody; > DELETE 2 @ 2 : 3 @@ -160,13 +165,12 @@ ~ this.buttonList.add(new GuiButton(0, this.width / 2 - 100, i + 72 + 24, 98, 20, -> CHANGE 1 : 10 @ 1 : 5 +> CHANGE 1 : 9 @ 1 : 5 ~ this.buttonList.add(new GuiButton(4, this.width / 2 + 2, i + 72 + 24, 98, 20, ~ I18n.format("menu.editProfile", new Object[0]))); ~ ~ this.buttonList.add(new GuiButtonLanguage(5, this.width / 2 - 124, i + 72 + 24)); -~ ~ if (isFork) { ~ this.openGLWarning1 = EaglercraftVersion.mainMenuStringE; ~ this.openGLWarning2 = EaglercraftVersion.mainMenuStringF; diff --git a/patches/minecraft/net/minecraft/client/gui/GuiScreen.edit.java b/patches/minecraft/net/minecraft/client/gui/GuiScreen.edit.java index 81dfaf3..56fc492 100644 --- a/patches/minecraft/net/minecraft/client/gui/GuiScreen.edit.java +++ b/patches/minecraft/net/minecraft/client/gui/GuiScreen.edit.java @@ -9,9 +9,10 @@ > DELETE 1 @ 1 : 3 -> INSERT 4 : 20 @ 4 +> INSERT 4 : 21 @ 4 + ++ import net.eaglerforge.gui.ModGUI; + import org.apache.commons.lang3.StringUtils; + + import com.google.common.base.Splitter; @@ -45,20 +46,22 @@ ~ private String clickedLinkURI; ~ protected long showingCloseKey = 0; -> INSERT 10 : 40 @ 10 +> CHANGE 10 : 21 @ 10 : 17 + +~ long millis = System.currentTimeMillis(); +~ long closeKeyTimeout = millis - showingCloseKey; +~ if (closeKeyTimeout < 3000l) { +~ int alpha1 = 0xC0000000; +~ int alpha2 = 0xFF000000; +~ if (closeKeyTimeout > 2500l) { +~ float f = (float) (3000l - closeKeyTimeout) * 0.002f; +~ if (f < 0.03f) +~ f = 0.03f; +~ alpha1 = (int) (f * 192.0f) << 24; +~ alpha2 = (int) (f * 255.0f) << 24; + +> INSERT 1 : 17 @ 1 -+ long millis = System.currentTimeMillis(); -+ long closeKeyTimeout = millis - showingCloseKey; -+ if (closeKeyTimeout < 3000l) { -+ int alpha1 = 0xC0000000; -+ int alpha2 = 0xFF000000; -+ if (closeKeyTimeout > 2500l) { -+ float f = (float) (3000l - closeKeyTimeout) * 0.002f; -+ if (f < 0.03f) -+ f = 0.03f; -+ alpha1 = (int) (f * 192.0f) << 24; -+ alpha2 = (int) (f * 255.0f) << 24; -+ } + String str; + int k = getCloseKey(); + if (k == KeyboardConstants.KEY_GRAVE) { @@ -75,10 +78,8 @@ + fontRendererObj.drawStringWithShadow(str, x + 2, y + 2, 0xFFAAAA | alpha2); + if (closeKeyTimeout > 2500l) + GlStateManager.disableBlend(); -+ } -+ -> CHANGE 2 : 14 @ 2 : 4 +> CHANGE 4 : 23 @ 4 : 9 ~ protected int getCloseKey() { ~ if (this instanceof GuiContainer) { @@ -92,16 +93,26 @@ ~ if (((this.mc.theWorld == null || this.mc.thePlayer.getHealth() <= 0.0F) && parInt1 == 1) ~ || parInt1 == this.mc.gameSettings.keyBindClose.getKeyCode() ~ || (parInt1 == 1 && (this.mc.gameSettings.keyBindClose.getKeyCode() == 0 || this.mc.areKeysLocked()))) { +~ if (!ModGUI.isGuiOpen()) { +~ this.mc.displayGuiScreen((GuiScreen) null); +~ if (this.mc.currentScreen == null) { +~ this.mc.setIngameFocus(); +~ } +~ } else { +~ ModGUI.closeGui(); -> INSERT 4 : 6 @ 4 +> CHANGE 1 : 3 @ 1 : 3 -+ } else if (parInt1 == 1) { -+ showingCloseKey = System.currentTimeMillis(); +~ } else if (parInt1 == 1) { +~ showingCloseKey = System.currentTimeMillis(); -> DELETE 1 @ 1 : 2 +> INSERT 1 : 2 @ 1 -> CHANGE 3 : 4 @ 3 : 13 ++ } +> CHANGE 1 : 3 @ 1 : 2 + +~ public static String getClipboardString() { ~ return EagRuntime.getClipboard(); > CHANGE 4 : 5 @ 4 : 11 diff --git a/sources/main/java/net/eaglerforge/api/LoggerAPI.java b/sources/main/java/net/eaglerforge/api/LoggerAPI.java index 21e7eba..72805f5 100644 --- a/sources/main/java/net/eaglerforge/api/LoggerAPI.java +++ b/sources/main/java/net/eaglerforge/api/LoggerAPI.java @@ -5,9 +5,12 @@ import net.lax1dude.eaglercraft.v1_8.log4j.LogManager; import net.lax1dude.eaglercraft.v1_8.log4j.Logger; public class LoggerAPI { - public static final Logger log = LogManager.getLogger(); + public static Logger log = LogManager.getLogger(); public static ModData makeModData() { ModData loggerGlobal = new ModData(); + loggerGlobal.setCallbackVoidWithDataArg("setlogger", (BaseData params) -> { + log = LogManager.getLogger(params.getString("name")); + }); loggerGlobal.setCallbackVoidWithDataArg("loginfo", (BaseData params) -> { log.info(params.getString("string")); }); diff --git a/sources/main/java/net/eaglerforge/api/ModAPI.java b/sources/main/java/net/eaglerforge/api/ModAPI.java index 2834465..a357e97 100644 --- a/sources/main/java/net/eaglerforge/api/ModAPI.java +++ b/sources/main/java/net/eaglerforge/api/ModAPI.java @@ -14,8 +14,11 @@ import net.eaglerforge.EaglerForge; import java.util.ArrayList; import static net.lax1dude.eaglercraft.v1_8.EaglercraftVersion.projectForkVersion; +import static net.minecraft.client.Minecraft.getDebugFPS; +import net.minecraft.client.gui.Gui; public class ModAPI { + private static Minecraft mc; public ArrayList requiredList; public static final Logger log = LogManager.getLogger(); @@ -65,6 +68,7 @@ public class ModAPI { newEvent("load"); newEvent("gui"); newEvent("drawhud"); + newEvent("key"); newEvent("update"); globalsFunctor(this); @@ -82,6 +86,9 @@ public class ModAPI { getModAPI().setCallbackVoid("rightClickMouse", () -> { mc.rightClickMouse(); }); + getModAPI().setCallbackVoid("getFPS", () -> { + getDebugFPS(); + }); getModAPI().set("clientBrand", ClientBrandRetriever.getClientModName()); setGlobal("mcinstance", mc); @@ -103,6 +110,9 @@ public class ModAPI { getModAPI().setCallbackVoidWithDataArg("drawString", (BaseData params) -> { mc.fontRendererObj.drawString(params.getString("msg"), params.getFloat("x"), params.getFloat("y"), params.getInt("color"), false); }); + getModAPI().setCallbackVoidWithDataArg("drawRect", (BaseData params) -> { + Gui.drawRect(params.getInt("left"), params.getInt("top"), params.getInt("right"), params.getInt("bottom"), params.getInt("color")); + }); ModGUI.loadFont(); } static void globalsFunctor(ModAPI modAPI) { @@ -123,6 +133,7 @@ public class ModAPI { }); } + public void onUpdate() { ModAPI.callEvent("update", new ModData()); } diff --git a/sources/main/java/net/eaglerforge/api/ModLoader.java b/sources/main/java/net/eaglerforge/api/ModLoader.java index 7a3f062..6633c56 100644 --- a/sources/main/java/net/eaglerforge/api/ModLoader.java +++ b/sources/main/java/net/eaglerforge/api/ModLoader.java @@ -17,6 +17,10 @@ public class ModLoader { @JSBody(params = {}, script = "try { return JSON.parse(localStorage.getItem('ml::Mods')||'[]') } catch(err) {return []}") private static native String[] retrieveMods(); + @JSBody(params = {}, script = "return returntotalloadedmods()") + public static native int returntotalloadedmods(); + + public static void saveModsToLocalStorage() { saveMods(Mods); }; diff --git a/sources/main/java/net/eaglerforge/api/PlatformAPI.java b/sources/main/java/net/eaglerforge/api/PlatformAPI.java index 1ef7332..dbe412a 100644 --- a/sources/main/java/net/eaglerforge/api/PlatformAPI.java +++ b/sources/main/java/net/eaglerforge/api/PlatformAPI.java @@ -1,6 +1,7 @@ package net.eaglerforge.api; import net.lax1dude.eaglercraft.v1_8.EagRuntime; +import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime; import net.minecraft.client.Minecraft; import org.teavm.jso.JSBody; @@ -40,6 +41,15 @@ public class PlatformAPI { //return EagRuntime.getPlatformOS(); getplatformOS(); }); + platformGlobal.setCallbackVoid("getUserAgentString", () -> { + PlatformRuntime.getUserAgentString(); + }); + platformGlobal.setCallbackVoid("getGLRenderer", () -> { + PlatformRuntime.getGLRenderer(); + }); + platformGlobal.setCallbackVoid("getGLVersion", () -> { + PlatformRuntime.getGLVersion(); + }); return platformGlobal; } } diff --git a/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java b/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java index 3b0fc8c..1ddb093 100644 --- a/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java +++ b/sources/main/java/net/lax1dude/eaglercraft/v1_8/EaglercraftVersion.java @@ -1,7 +1,11 @@ package net.lax1dude.eaglercraft.v1_8; +import org.teavm.jso.JSBody; + import java.math.BigInteger; +import static net.eaglerforge.api.ModLoader.returntotalloadedmods; + public class EaglercraftVersion { @@ -42,12 +46,13 @@ public class EaglercraftVersion { // Miscellaneous variables: + public static int loadedmods = returntotalloadedmods(); public static final String mainMenuStringA = "Minecraft* 1.8.8"; - public static final String mainMenuStringB = projectForkName + " " + projectForkVersion + " (" + 0 + " Mods loaded)"; + public static String mainMenuStringB = projectForkName + " " + projectForkVersion + " (" + loadedmods + " Mods loaded)"; public static final String mainMenuStringC = ""; public static final String mainMenuStringD = "Resources Copyright Mojang AB"; - public static final String mainMenuStringE = "based on eaglercraft " + projectOriginVersion; + public static final String mainMenuStringE = "Based on eaglercraft " + projectOriginVersion; public static final String mainMenuStringF = null; public static final String mainMenuStringG = "Collector's Edition";