This commit is contained in:
radmanplays 2024-02-13 13:49:11 +03:30
parent d8738996de
commit f226435556
6 changed files with 50 additions and 123 deletions

View File

@ -25,11 +25,12 @@
~ I18n.format("shaders.gui.optionsButton")));
> CHANGE 2 : 5 @ 2 : 4
> CHANGE 2 : 6 @ 2 : 4
~ this.buttonList.add(broadcastSettings = new GuiButton(107, this.width / 2 + 5, this.height / 6 + 72 - 6, 150,
~ 20, I18n.format(EagRuntime.getRecText(), new Object[0])));
~ broadcastSettings.enabled = EagRuntime.recSupported();
~
> CHANGE 8 : 10 @ 8 : 9

View File

@ -9,7 +9,7 @@
~ eaglercraft.recording.unsupported=Recording Unsupported!
~ eaglercraft.recording.stop=Stop Recording
~ eaglercraft.recording.start=Record Screen...
~ eaglercraft.recording.start=reen...
~ eaglercraft.soundCategory.voice=Voice
> INSERT 1 : 200 @ 1

View File

@ -2,14 +2,25 @@ package net.eaglerforge;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
import static net.eaglerforge.api.ModAPI.initAPI;
import org.teavm.jso.JSBody;
public class EaglerForge {
public static final Logger log = LogManager.getLogger();
@JSBody(params = { "message" }, script = "alert(message)")
public static native void jsalert(String message);
@JSBody(params = { "message" }, script = "console.log(message)")
public static native void jsconsolelog(String message);
@JSBody(params = { "message" }, script = "prompt(message)")
public static native void jsprompt(String message);
@JSBody(params = { "message", "default_text" }, script = "prompt(message, default_text)")
public static native void jspromptdt(String message, String default_text);
public static void init() {
log.info("Starting EaglerForge!");
log.info("Loading Mods...");
// TODO: Make a javascript moding api using teavm and make the mods load here
}
}

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import com.google.common.base.Splitter;
import com.google.common.collect.Lists;
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.Keyboard;
import net.lax1dude.eaglercraft.v1_8.Mouse;
import net.lax1dude.eaglercraft.v1_8.internal.EnumCursorType;
@ -16,6 +17,7 @@ import net.lax1dude.eaglercraft.v1_8.sp.gui.GuiScreenConnectOption;
import net.lax1dude.eaglercraft.v1_8.sp.gui.GuiScreenLANConnecting;
import net.lax1dude.eaglercraft.v1_8.sp.lan.LANServerList;
import net.lax1dude.eaglercraft.v1_8.sp.relay.RelayServer;
import net.lax1dude.eaglercraft.v1_8.vfs.SYS;
import net.minecraft.client.audio.PositionedSoundRecord;
import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.GuiListExtended;
@ -62,6 +64,7 @@ public class GuiMods extends GuiScreen implements GuiYesNoCallback {
private boolean editingServer;
private boolean directConnect;
private String hoveringText;
public static int ModsLoaded = 0;
private boolean initialized;
@ -133,13 +136,15 @@ public class GuiMods extends GuiScreen implements GuiYesNoCallback {
protected void actionPerformed(GuiButton parGuiButton) {
if (parGuiButton.enabled) {
if (parGuiButton.id == 2) {
} else if (parGuiButton.id == 1) {
} else if (parGuiButton.id == 4) {
} else if (parGuiButton.id == 3) {
} else if (parGuiButton.id == 7) {
} else if (parGuiButton.id == 0) {
this.mc.displayGuiScreen(this.parentScreen);
} else if (parGuiButton.id == 8) {
EagRuntime.displayFileChooser("text/javascript", "js");
if (EagRuntime.fileChooserHasResult()){
ModsLoaded++;
EagRuntime.clearFileChooserResult();
}
}
}

View File

@ -18,117 +18,7 @@ public class ModAPI {
public static final Logger log = LogManager.getLogger();
public static String version = projectForkVersion;
public static boolean clientPacketSendEventsEnabled = true;
@JSBody(params = { "version" }, script = "var ModAPI = {};\r\n" + //
"ModAPI.events = {};\r\n" + //
"ModAPI.events.types = [\"event\"];\r\n" + //
"ModAPI.events.listeners = {\"event\": []};\r\n" + //
"ModAPI.globals = {};\r\n" + //
"ModAPI.version = version;\r\n" + //
"ModAPI.addEventListener = function newEventListener(name, callback) {\r\n" + //
" if (!callback) {\r\n" + //
" throw new Error(\"Invalid callback!\");\r\n" + //
" }\r\n" + //
" if (ModAPI.events.types.includes(name)) {\r\n" + //
" if (!Array.isArray(ModAPI.events.listeners[name])) {\r\n" + //
" ModAPI.events.listeners[name] = [];\r\n" + //
" }\r\n" + //
" ModAPI.events.listeners[name].push(callback);\r\n" + //
" console.log(\"Added new event listener.\");\r\n" + //
" } else {\r\n" + //
" throw new Error(\"This event does not exist!\");\r\n" + //
" }\r\n" + //
"};\r\n" + //
"ModAPI.removeEventListener = function removeEventListener(name, func, slow) {\r\n" + //
" if (!func) {\r\n" + //
" throw new Error(\"Invalid callback!\");\r\n" + //
" }\r\n" + //
" if (!Array.isArray(ModAPI.events.listeners[name])) {\r\n" + //
" ModAPI.events.listeners[name] = [];\r\n" + //
" }\r\n" + //
" var targetArr = ModAPI.events.listeners[name];\r\n" + //
" if (!slow) {\r\n" + //
" if (targetArr.indexOf(func) !== -1) {\r\n" + //
" targetArr.splice(targetArr.indexOf(func), 1);\r\n" + //
" console.log(\"Removed event listener.\");\r\n" + //
" }\r\n" + //
" } else {\r\n" + //
" var functionString = func.toString();\r\n" + //
" targetArr.forEach((f, i) => {\r\n" + //
" if (f.toString() === functionString) {\r\n" + //
" targetArr.splice(i, 1);\r\n" + //
" console.log(\"Removed event listener.\");\r\n" + //
" }\r\n" + //
" });\r\n" + //
" }\r\n" + //
"};\r\n" + //
"ModAPI.events.newEvent = function newEvent(name) {\r\n" + //
" ModAPI.events.types.push(name);\r\n" + //
"};\r\n" + //
"ModAPI.events.callEvent = function callEvent(name, data) {\r\n" + //
" if (\r\n" + //
" !ModAPI.events.types.includes(name) ||\r\n" + //
" !Array.isArray(ModAPI.events.listeners[name])\r\n" + //
" ) {\r\n" + //
" if (!Array.isArray(ModAPI.events.listeners[name])) {\r\n" + //
" if (ModAPI.events.types.includes(name)) {\r\n" + //
" ModAPI.events.listeners.event.forEach((func) => {\r\n" + //
" func({event: name, data: data});\r\n" + //
" });\r\n" + //
" return;\r\n" + //
" }\r\n" + //
" return;\r\n" + //
" }\r\n" + //
" console.error(\"The ModAPI has been called with an invalid event name: \"+name);\r\n" + //
" console.error(\"Please report this bug to the repo.\");\r\n" + //
" return;\r\n" + //
" }\r\n" + //
" ModAPI.events.listeners[name].forEach((func) => {\r\n" + //
" func(data);\r\n" + //
" });\r\n" + //
" ModAPI.events.listeners.event.forEach((func) => {\r\n" + //
" func({event: name, data: data});\r\n" + //
" });\r\n" + //
"\r\n" + //
" ModAPI.globals._initUpdate();\r\n" + //
"};\r\n" + //
"ModAPI.updateComponent = function updateComponent(component) {\r\n" + //
" if (\r\n" + //
" typeof component !== \"string\" ||\r\n" + //
" ModAPI[component] === null ||\r\n" + //
" ModAPI[component] === undefined\r\n" + //
" ) {\r\n" + //
" return;\r\n" + //
" }\r\n" + //
" if (!ModAPI.globals || !ModAPI.globals.onGlobalsUpdate) {\r\n" + //
" return;\r\n" + //
" }\r\n" + //
" if (!ModAPI.globals.toUpdate) {\r\n" + //
" ModAPI.globals.toUpdate = [];\r\n" + //
" }\r\n" + //
" if (ModAPI.globals.toUpdate.indexOf(component) === -1) {\r\n" + //
" ModAPI.globals.toUpdate.push(component);\r\n" + //
" }\r\n" + //
"};\r\n" + //
"ModAPI.require = function require(component) {\r\n" + //
" if (typeof component !== \"string\") {\r\n" + //
" return;\r\n" + //
" }\r\n" + //
" if (!ModAPI.globals || !ModAPI.globals.onRequire) {\r\n" + //
" return;\r\n" + //
" }\r\n" + //
" ModAPI.globals.onRequire(component);\r\n" + //
"};\r\n" + //
"ModAPI.globals._initUpdate = function _initUpdate() {\r\n" + //
" if (!ModAPI.globals.toUpdate) {\r\n" + //
" ModAPI.globals.toUpdate = [];\r\n" + //
" }\r\n" + //
" ModAPI.globals.toUpdate.forEach((id) => {\r\n" + //
" ModAPI.globals.onGlobalsUpdate(id);\r\n" + //
" });\r\n" + //
" ModAPI.globals.toUpdate = [];\r\n" + //
"};\r\n" + //
"window.ModAPI = ModAPI;\r\n" + //
"")
@JSBody(params = { "version" }, script = "initAPI(version)")
public static native void initAPI(String version);
@JSBody(params = { "name" }, script = "ModAPI.events.newEvent(name);")
private static native void newEvent(String name);
@ -180,7 +70,26 @@ public class ModAPI {
getModAPI().set("clientBrand", ClientBrandRetriever.getClientModName());
setGlobal("mcinstance", mc);
setGlobal("mcinstance", log);
getModAPI().setCallbackVoidWithDataArg("log", (BaseData params) -> {
if (params.getString("type") == "info"){
log.info(params.getString("msg"));
}
if (params.getString("type") == "debug"){
log.debug(params.getString("msg"));
}
if (params.getString("type") == "error"){
log.error(params.getString("msg"));
}
if (params.getString("type") == "warn"){
log.warn(params.getString("msg"));
}
if (params.getString("type") == "fatal"){
log.fatal(params.getString("msg"));
}
});
getModAPI().setCallbackVoidWithDataArg("drawStringWithShadow", (BaseData params) -> {
mc.ingameGUI.getFontRenderer().drawStringWithShadow(params.getString("msg"), params.getFloat("x"), params.getFloat("y"), params.getInt("color"));
});
}
static void globalsFunctor(ModAPI modAPI) {
GlobalsListener.provideCallback((String name) -> {
@ -201,6 +110,5 @@ public class ModAPI {
}
public void onUpdate() {
ModAPI.callEvent("update", new ModData());
}
}

View File

@ -2,6 +2,8 @@ package net.lax1dude.eaglercraft.v1_8;
import java.math.BigInteger;
import static net.eaglerforge.GuiMods.ModsLoaded;
public class EaglercraftVersion {
@ -48,7 +50,7 @@ public class EaglercraftVersion {
// Miscellaneous variables:
public static final String mainMenuStringA = "Minecraft* 1.8.8";
public static final String mainMenuStringB = projectForkName + " " + projectForkVersion;
public static final String mainMenuStringB = projectForkName + " " + projectForkVersion + " (" + ModsLoaded + " Mods loaded)";
public static final String mainMenuStringC = "";
public static final String mainMenuStringD = "Resources Copyright Mojang AB";