This commit is contained in:
parent
5127ac2faa
commit
7f7aa279e4
|
@ -20,11 +20,12 @@
|
||||||
|
|
||||||
> DELETE 1 @ 1 : 4
|
> DELETE 1 @ 1 : 4
|
||||||
|
|
||||||
> CHANGE 1 : 53 @ 1 : 4
|
> CHANGE 1 : 54 @ 1 : 4
|
||||||
|
|
||||||
~
|
~
|
||||||
~ import net.eaglerforge.EaglerForge;
|
~ import net.eaglerforge.EaglerForge;
|
||||||
~ import net.eaglerforge.api.ModAPI;
|
~ import net.eaglerforge.api.ModAPI;
|
||||||
|
~ import net.eaglerforge.api.ModData;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.internal.PlatformInput;
|
~ import net.lax1dude.eaglercraft.v1_8.internal.PlatformInput;
|
||||||
~
|
~
|
||||||
~ import org.apache.commons.lang3.Validate;
|
~ import org.apache.commons.lang3.Validate;
|
||||||
|
@ -129,7 +130,7 @@
|
||||||
|
|
||||||
> CHANGE 1 : 2 @ 1 : 2
|
> CHANGE 1 : 2 @ 1 : 2
|
||||||
|
|
||||||
~ public class Minecraft implements IThreadListener {
|
~ public class Minecraft extends ModData implements IThreadListener {
|
||||||
|
|
||||||
> CHANGE 2 : 3 @ 2 : 9
|
> CHANGE 2 : 3 @ 2 : 9
|
||||||
|
|
||||||
|
@ -519,7 +520,15 @@
|
||||||
|
|
||||||
> DELETE 110 @ 110 : 114
|
> DELETE 110 @ 110 : 114
|
||||||
|
|
||||||
> CHANGE 108 : 109 @ 108 : 148
|
> CHANGE 24 : 25 @ 24 : 25
|
||||||
|
|
||||||
|
~ public void clickMouse() {
|
||||||
|
|
||||||
|
> CHANGE 30 : 31 @ 30 : 31
|
||||||
|
|
||||||
|
~ public void rightClickMouse() {
|
||||||
|
|
||||||
|
> CHANGE 52 : 53 @ 52 : 92
|
||||||
|
|
||||||
~ Display.toggleFullscreen();
|
~ Display.toggleFullscreen();
|
||||||
|
|
||||||
|
|
|
@ -13,9 +13,10 @@
|
||||||
|
|
||||||
+ import java.util.Arrays;
|
+ import java.util.Arrays;
|
||||||
|
|
||||||
> CHANGE 2 : 29 @ 2 : 4
|
> CHANGE 2 : 30 @ 2 : 4
|
||||||
|
|
||||||
~
|
~
|
||||||
|
~ import net.eaglerforge.GuiMods;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
~ import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
~ import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||||
|
@ -176,11 +177,13 @@
|
||||||
|
|
||||||
~ this.field_92019_w = this.field_92021_u + (line2 ? 24 : 11);
|
~ this.field_92019_w = this.field_92021_u + (line2 ? 24 : 11);
|
||||||
|
|
||||||
> CHANGE 10 : 23 @ 10 : 12
|
> CHANGE 10 : 25 @ 10 : 12
|
||||||
|
|
||||||
|
~ this.buttonList.add(new GuiButton(69420, this.width / 2 - 100, parInt1 + parInt2 * 2,
|
||||||
|
~ I18n.format("eaglerforge.menu.mods")));
|
||||||
~ if (EaglercraftVersion.mainMenuEnableGithubButton) {
|
~ if (EaglercraftVersion.mainMenuEnableGithubButton) {
|
||||||
~ this.buttonList.add(
|
~ this.buttonList.add(
|
||||||
~ new GuiButton(14, this.width / 2 - 100, parInt1 + parInt2 * 2, I18n.format("menu.forkOnGitlab")));
|
~ new GuiButton(14, this.width / 2 - 100, parInt1 + parInt2 * 3, I18n.format("menu.forkOnGitlab")));
|
||||||
~ } else {
|
~ } else {
|
||||||
~ if (EagRuntime.getConfiguration().isEnableDownloadOfflineButton()
|
~ if (EagRuntime.getConfiguration().isEnableDownloadOfflineButton()
|
||||||
~ && (EagRuntime.getConfiguration().getDownloadOfflineButtonLink() != null
|
~ && (EagRuntime.getConfiguration().getDownloadOfflineButtonLink() != null
|
||||||
|
@ -209,7 +212,13 @@
|
||||||
~ if (parGuiButton.id == 4) {
|
~ if (parGuiButton.id == 4) {
|
||||||
~ this.mc.displayGuiScreen(new GuiScreenEditProfile(this));
|
~ this.mc.displayGuiScreen(new GuiScreenEditProfile(this));
|
||||||
|
|
||||||
> CHANGE 2 : 4 @ 2 : 4
|
> INSERT 1 : 4 @ 1
|
||||||
|
|
||||||
|
+ if (parGuiButton.id == 69420) {
|
||||||
|
+ this.mc.displayGuiScreen(new GuiMods(this));
|
||||||
|
+ }
|
||||||
|
|
||||||
|
> CHANGE 1 : 3 @ 1 : 3
|
||||||
|
|
||||||
~ if (parGuiButton.id == 14) {
|
~ if (parGuiButton.id == 14) {
|
||||||
~ EagRuntime.openLink(EaglercraftVersion.projectForkURL);
|
~ EagRuntime.openLink(EaglercraftVersion.projectForkURL);
|
||||||
|
|
|
@ -5,8 +5,10 @@
|
||||||
# Version: 1.0
|
# Version: 1.0
|
||||||
# Author: lax1dude
|
# Author: lax1dude
|
||||||
|
|
||||||
> CHANGE 3 : 8 @ 3 : 5
|
> CHANGE 3 : 10 @ 3 : 5
|
||||||
|
|
||||||
|
~
|
||||||
|
~ import net.eaglerforge.api.BaseData;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
|
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.HString;
|
~ import net.lax1dude.eaglercraft.v1_8.HString;
|
||||||
|
|
|
@ -7,8 +7,11 @@
|
||||||
|
|
||||||
> DELETE 2 @ 2 : 5
|
> DELETE 2 @ 2 : 5
|
||||||
|
|
||||||
> CHANGE 4 : 11 @ 4 : 6
|
> CHANGE 4 : 14 @ 4 : 6
|
||||||
|
|
||||||
|
~
|
||||||
|
~ import net.eaglerforge.api.BaseData;
|
||||||
|
~ import net.eaglerforge.api.ModData;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftRandom;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
|
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
|
||||||
~
|
~
|
||||||
|
|
|
@ -7,8 +7,11 @@
|
||||||
|
|
||||||
> DELETE 2 @ 2 : 5
|
> DELETE 2 @ 2 : 5
|
||||||
|
|
||||||
> CHANGE 2 : 8 @ 2 : 3
|
> CHANGE 2 : 11 @ 2 : 3
|
||||||
|
|
||||||
|
~
|
||||||
|
~ import net.eaglerforge.api.BaseData;
|
||||||
|
~ import net.eaglerforge.api.ModData;
|
||||||
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
|
~ import net.lax1dude.eaglercraft.v1_8.EaglercraftUUID;
|
||||||
~
|
~
|
||||||
~ import com.google.common.base.Charsets;
|
~ import com.google.common.base.Charsets;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
~ eaglercraft.recording.start=Record Screen...
|
~ eaglercraft.recording.start=Record Screen...
|
||||||
~ eaglercraft.soundCategory.voice=Voice
|
~ eaglercraft.soundCategory.voice=Voice
|
||||||
|
|
||||||
> INSERT 1 : 195 @ 1
|
> INSERT 1 : 197 @ 1
|
||||||
|
|
||||||
+ eaglercraft.resourcePack.prompt.title=What do you want to do with '%s'?
|
+ eaglercraft.resourcePack.prompt.title=What do you want to do with '%s'?
|
||||||
+ eaglercraft.resourcePack.prompt.text=Tip: Hold Shift to skip this screen when selecting a resource pack!
|
+ eaglercraft.resourcePack.prompt.text=Tip: Hold Shift to skip this screen when selecting a resource pack!
|
||||||
|
@ -208,6 +208,8 @@
|
||||||
+
|
+
|
||||||
+ eaglercraft.command.clientStub=This command is client side!
|
+ eaglercraft.command.clientStub=This command is client side!
|
||||||
+
|
+
|
||||||
|
+ eaglerforge.menu.mods=Mods
|
||||||
|
+
|
||||||
|
|
||||||
> INSERT 163 : 350 @ 163
|
> INSERT 163 : 350 @ 163
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
package net.eaglerforge;
|
||||||
|
|
||||||
|
import net.minecraft.client.gui.GuiButton;
|
||||||
|
import net.minecraft.client.gui.GuiScreen;
|
||||||
|
import net.minecraft.client.resources.I18n;
|
||||||
|
import net.minecraft.util.IChatComponent;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class GuiMods extends GuiScreen {
|
||||||
|
private final GuiScreen parentScreen;
|
||||||
|
private IChatComponent message;
|
||||||
|
private List<String> multilineMessage;
|
||||||
|
private int field_175353_i;
|
||||||
|
|
||||||
|
public GuiMods(GuiScreen parentScreen) {
|
||||||
|
this.parentScreen = parentScreen;
|
||||||
|
}
|
||||||
|
public void initGui() {
|
||||||
|
this.buttonList.clear();
|
||||||
|
this.multilineMessage = this.fontRendererObj.listFormattedStringToWidth(this.message.getFormattedText(),
|
||||||
|
this.width - 50);
|
||||||
|
this.field_175353_i = this.multilineMessage.size() * this.fontRendererObj.FONT_HEIGHT;
|
||||||
|
this.buttonList.add(new GuiButton(69, this.width / 2 - 100,
|
||||||
|
this.height / 2 + this.field_175353_i / 2 + this.fontRendererObj.FONT_HEIGHT,
|
||||||
|
I18n.format("gui.toMenu", new Object[0])));
|
||||||
|
}
|
||||||
|
protected void actionPerformed(GuiButton parGuiButton) {
|
||||||
|
if (parGuiButton.id == 0) {
|
||||||
|
this.mc.displayGuiScreen(this.parentScreen);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public void drawScreen(int i, int j, float f) {
|
||||||
|
this.drawDefaultBackground();
|
||||||
|
this.drawCenteredString(this.fontRendererObj, "testing", this.width / 2,
|
||||||
|
this.height / 2 - this.field_175353_i / 2 - this.fontRendererObj.FONT_HEIGHT * 2, 11184810);
|
||||||
|
int k = this.height / 2 - this.field_175353_i / 2;
|
||||||
|
if (this.multilineMessage != null) {
|
||||||
|
for (String s : this.multilineMessage) {
|
||||||
|
this.drawCenteredString(this.fontRendererObj, s, this.width / 2, k, 16777215);
|
||||||
|
k += this.fontRendererObj.FONT_HEIGHT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
super.drawScreen(i, j, f);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,362 @@
|
||||||
|
package net.eaglerforge.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.teavm.jso.JSBody;
|
||||||
|
import org.teavm.jso.JSObject;
|
||||||
|
import org.teavm.jso.JSFunctor;
|
||||||
|
|
||||||
|
public abstract class BaseData implements JSObject {
|
||||||
|
@JSFunctor
|
||||||
|
public interface VoidCallback extends JSObject {
|
||||||
|
void onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface BooleanCallback extends JSObject {
|
||||||
|
boolean onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface ObjectCallback extends JSObject {
|
||||||
|
JSObject onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface FloatCallback extends JSObject {
|
||||||
|
float onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DoubleCallback extends JSObject {
|
||||||
|
double onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface StringCallback extends JSObject {
|
||||||
|
String onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface IntCallback extends JSObject {
|
||||||
|
int onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface BooleanCallbackArr extends JSObject {
|
||||||
|
boolean[] onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface ObjectCallbackArr extends JSObject {
|
||||||
|
JSObject[] onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface FloatCallbackArr extends JSObject {
|
||||||
|
float[] onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DoubleCallbackArr extends JSObject {
|
||||||
|
double[] onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface StringCallbackArr extends JSObject {
|
||||||
|
String[] onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface IntCallbackArr extends JSObject {
|
||||||
|
int[] onCallback();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataVoidCallback extends JSObject {
|
||||||
|
void onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataBooleanCallback extends JSObject {
|
||||||
|
boolean onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataObjectCallback extends JSObject {
|
||||||
|
JSObject onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataFloatCallback extends JSObject {
|
||||||
|
float onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataDoubleCallback extends JSObject {
|
||||||
|
double onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataStringCallback extends JSObject {
|
||||||
|
String onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataIntCallback extends JSObject {
|
||||||
|
int onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataBooleanCallbackArr extends JSObject {
|
||||||
|
boolean[] onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataObjectCallbackArr extends JSObject {
|
||||||
|
JSObject[] onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataFloatCallbackArr extends JSObject {
|
||||||
|
float[] onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataDoubleCallbackArr extends JSObject {
|
||||||
|
double[] onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataStringCallbackArr extends JSObject {
|
||||||
|
String[] onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface DataIntCallbackArr extends JSObject {
|
||||||
|
int[] onCallback(BaseData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, String value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, int value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, boolean value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, float value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, byte value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, char value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, double value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, JSObject value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, BaseData value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, String[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, int[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, boolean[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, float[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, byte[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, char[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, double[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, JSObject[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, BaseData[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, short[] value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void set(String key, short value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "this[key]=null;")
|
||||||
|
public native void setNull(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackVoid(String key, VoidCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackBoolean(String key, BooleanCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackInt(String key, IntCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackString(String key, StringCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackDouble(String key, DoubleCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackFloat(String key, FloatCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackObject(String key, ObjectCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackBooleanWithDataArg(String key, DataBooleanCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackDoubleWithDataArg(String key, DataDoubleCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackFloatWithDataArg(String key, DataFloatCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackIntWithDataArg(String key, DataIntCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackStringWithDataArg(String key, DataStringCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackObjectWithDataArg(String key, DataObjectCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackVoidWithDataArg(String key, DataVoidCallback value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackBooleanArrWithDataArg(String key, DataBooleanCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackDoubleArrWithDataArg(String key, DataDoubleCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackFloatArrWithDataArg(String key, DataFloatCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackIntArrWithDataArg(String key, DataIntCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackStringArrWithDataArg(String key, DataStringCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackObjectArrWithDataArg(String key, DataObjectCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackBooleanArr(String key, BooleanCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackIntArr(String key, IntCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackStringArr(String key, StringCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackDoubleArr(String key, DoubleCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackFloatArr(String key, FloatCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key", "value" }, script = "this[key]=value;")
|
||||||
|
public native void setCallbackObjectArr(String key, ObjectCallbackArr value);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native String getString(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native int getInt(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native boolean getBoolean(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native float getFloat(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native byte getByte(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native char getChar(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native double getDouble(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native JSObject getObject(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native BaseData getBaseData(String key);
|
||||||
|
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native String[] getStringArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native int[] getIntArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native short getShort(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native short[] getShortArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native boolean[] getBooleanArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native float[] getFloatArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native byte[] getByteArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native char[] getCharArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native double[] getDoubleArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native JSObject[] getObjectArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key];")
|
||||||
|
public native BaseData[] getBaseDataArr(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return key in this;")
|
||||||
|
public native boolean has(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return typeof this[key];")
|
||||||
|
public native String getType(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key]();")
|
||||||
|
public native JSObject execFuncObject(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key]();")
|
||||||
|
public native BaseData execFuncBaseData(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "return this[key]();")
|
||||||
|
public native String execFuncString(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { "key" }, script = "if(this[key] && this[key].getRef){ return this[key].getRef(); } else { return null; }")
|
||||||
|
public native BaseData getRef(String key);
|
||||||
|
|
||||||
|
@JSBody(params = { }, script = "if(this.getRef){ return this.getRef(); } else { return null; }")
|
||||||
|
public native BaseData getRef();
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package net.eaglerforge.api;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.teavm.jso.JSBody;
|
||||||
|
import org.teavm.jso.JSObject;
|
||||||
|
import org.teavm.jso.JSFunctor;
|
||||||
|
|
||||||
|
class GlobalsListener {
|
||||||
|
@JSFunctor
|
||||||
|
public interface GlobalsHandler extends JSObject {
|
||||||
|
void onGlobalsUpdate(String global);
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSFunctor
|
||||||
|
public interface UpdateHandler extends JSObject {
|
||||||
|
void onUpdate();
|
||||||
|
}
|
||||||
|
|
||||||
|
@JSBody(params = { "handler" }, script = "window.PluginAPI.globals.onGlobalsUpdate = handler;")
|
||||||
|
static native void provideCallback(GlobalsHandler handler);
|
||||||
|
|
||||||
|
@JSBody(params = { "handler" }, script = "window.PluginAPI.globals.onRequire = handler;")
|
||||||
|
static native void provideRequireCallback(GlobalsHandler handler);
|
||||||
|
|
||||||
|
@JSBody(params = { "handler" }, script = "window.PluginAPI.update = handler;")
|
||||||
|
static native void provideUpdateCallback(UpdateHandler handler);
|
||||||
|
}
|
|
@ -2,24 +2,205 @@ package net.eaglerforge.api;
|
||||||
|
|
||||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||||
|
import net.minecraft.client.ClientBrandRetriever;
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.util.ChatComponentText;
|
||||||
import org.teavm.jso.JSBody;
|
import org.teavm.jso.JSBody;
|
||||||
import org.teavm.jso.JSObject;
|
import org.teavm.jso.JSObject;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static net.lax1dude.eaglercraft.v1_8.EaglercraftVersion.projectForkVersion;
|
import static net.lax1dude.eaglercraft.v1_8.EaglercraftVersion.projectForkVersion;
|
||||||
|
|
||||||
public class ModAPI {
|
public class ModAPI {
|
||||||
private static Minecraft mc;
|
private static Minecraft mc;
|
||||||
|
public ArrayList<String> requiredList;
|
||||||
public static final Logger log = LogManager.getLogger();
|
public static final Logger log = LogManager.getLogger();
|
||||||
public static String version = projectForkVersion;
|
public static String version = projectForkVersion;
|
||||||
|
public static boolean clientPacketSendEventsEnabled = true;
|
||||||
@JSBody(params = { "version" }, script = "var ModAPI = {};\r\n" + //
|
@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.version = version;\r\n" + //
|
||||||
"ModAPI.log = log;\r\n" + //
|
"ModAPI.addEventListener = function newEventListener(name, callback) {\r\n" + //
|
||||||
"ModAPI.mcinstance = mc;\r\n" + //
|
" if (!callback) {\r\n" + //
|
||||||
"window.ModAPI = ModAPI;")
|
" 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" + //
|
||||||
|
"")
|
||||||
public static native void initAPI(String version);
|
public static native void initAPI(String version);
|
||||||
|
@JSBody(params = { "name" }, script = "ModAPI.events.newEvent(name);")
|
||||||
|
private static native void newEvent(String name);
|
||||||
|
|
||||||
|
@JSBody(params = { "name", "data" }, script = "ModAPI.events.callEvent(name, data); return data;")
|
||||||
|
public static native BaseData callEvent(String name, BaseData data);
|
||||||
|
|
||||||
|
@JSBody(params = { "name", "data" }, script = "ModAPI[name]=data;")
|
||||||
|
public static native void setGlobal(String name, BaseData data);
|
||||||
|
|
||||||
|
@JSBody(params = { "name" }, script = "return ModAPI[name] || {};")
|
||||||
|
public static native BaseData getGlobal(String name);
|
||||||
|
|
||||||
|
@JSBody(params = {}, script = "return ModAPI;")
|
||||||
|
public static native BaseData getModAPI();
|
||||||
|
|
||||||
|
@JSBody(params = { "data" }, script = "console.log(data);")
|
||||||
|
public static native void logJSObj(JSObject data);
|
||||||
|
|
||||||
|
public void onGlobalUpdated(String global) {
|
||||||
|
// logger.info("Global update request: "+global);
|
||||||
|
BaseData data = getGlobal(global);
|
||||||
|
// logJSObj(data);
|
||||||
|
if (data == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onRequire(String global) {
|
||||||
|
if (!requiredList.contains(global)) {
|
||||||
|
log.info("Required global: " + global);
|
||||||
|
requiredList.add(global);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ModAPI(Minecraft mcIn) {
|
public ModAPI(Minecraft mcIn) {
|
||||||
this.mc = mcIn;
|
this.mc = mcIn;
|
||||||
|
requiredList = new ArrayList<String>();
|
||||||
initAPI(version);
|
initAPI(version);
|
||||||
|
getModAPI().setCallbackVoidWithDataArg("displayToChat", (BaseData params) -> {
|
||||||
|
mc.ingameGUI.getChatGUI().printChatMessage(new ChatComponentText(params.getString("msg")));
|
||||||
|
});
|
||||||
|
getModAPI().setCallbackVoid("clickMouse", () -> {
|
||||||
|
mc.clickMouse();
|
||||||
|
});
|
||||||
|
getModAPI().setCallbackVoid("rightClickMouse", () -> {
|
||||||
|
mc.rightClickMouse();
|
||||||
|
});
|
||||||
|
getModAPI().set("clientBrand", ClientBrandRetriever.getClientModName());
|
||||||
|
|
||||||
|
setGlobal("mcinstance", mc);
|
||||||
|
setGlobal("mcinstance", log);
|
||||||
|
}
|
||||||
|
static void globalsFunctor(ModAPI modAPI) {
|
||||||
|
GlobalsListener.provideCallback((String name) -> {
|
||||||
|
modAPI.onGlobalUpdated(name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void globalsRequireFunctor(ModAPI modAPI) {
|
||||||
|
GlobalsListener.provideRequireCallback((String name) -> {
|
||||||
|
modAPI.onRequire(name);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
static void globalsUpdateFunctor(ModAPI modAPI) {
|
||||||
|
GlobalsListener.provideUpdateCallback(() -> {
|
||||||
|
modAPI.onUpdate();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onUpdate() {
|
||||||
|
ModAPI.callEvent("update", new ModData());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,4 @@
|
||||||
|
package net.eaglerforge.api;
|
||||||
|
|
||||||
|
public class ModData extends BaseData{
|
||||||
|
}
|
|
@ -3,6 +3,7 @@ package net.lax1dude.eaglercraft.v1_8.log4j;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
import net.eaglerforge.api.ModData;
|
||||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||||
* POSSIBILITY OF SUCH DAMAGE.
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Logger {
|
public class Logger extends ModData {
|
||||||
|
|
||||||
public final String loggerName;
|
public final String loggerName;
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,15 @@ dependencies {
|
||||||
teavm(teavm.libs.jso)
|
teavm(teavm.libs.jso)
|
||||||
teavm(teavm.libs.jsoApis)
|
teavm(teavm.libs.jsoApis)
|
||||||
}
|
}
|
||||||
|
dependencies {
|
||||||
|
implementation teavm.libs.jsoApis
|
||||||
|
}
|
||||||
|
|
||||||
teavm.js {
|
teavm.js {
|
||||||
obfuscated = true
|
obfuscated = false;
|
||||||
sourceMap = true
|
sourceMap = true
|
||||||
targetFileName = "../classes.js"
|
targetFileName = "../classes.js"
|
||||||
// optimization = OptimizationLevel.ADVANCED
|
optimization = org.teavm.gradle.api.OptimizationLevel.AGGRESSIVE;
|
||||||
outOfProcess = false
|
outOfProcess = false
|
||||||
fastGlobalAnalysis = false
|
fastGlobalAnalysis = false
|
||||||
processMemory = 512
|
processMemory = 512
|
||||||
|
|
Loading…
Reference in New Issue