2024-02-10 23:54:25 -06:00
|
|
|
package net.eaglerforge.api;
|
|
|
|
|
2024-02-15 06:00:47 -06:00
|
|
|
import net.eaglerforge.gui.ModGUI;
|
2024-05-29 10:56:04 -05:00
|
|
|
import net.eaglerforge.reflect.PLReflect;
|
2024-03-26 01:51:08 -05:00
|
|
|
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
2024-02-10 23:54:25 -06:00
|
|
|
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
|
|
|
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
2024-03-08 05:57:27 -06:00
|
|
|
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
2024-03-20 09:56:48 -05:00
|
|
|
import net.lax1dude.eaglercraft.v1_8.profile.EaglerProfile;
|
2024-03-26 01:51:08 -05:00
|
|
|
import net.lax1dude.eaglercraft.v1_8.sp.SingleplayerServerController;
|
2024-02-11 03:43:45 -06:00
|
|
|
import net.minecraft.client.ClientBrandRetriever;
|
2024-02-10 23:54:25 -06:00
|
|
|
import net.minecraft.client.Minecraft;
|
2024-03-02 02:57:12 -06:00
|
|
|
import net.minecraft.client.gui.ScaledResolution;
|
2024-02-11 03:43:45 -06:00
|
|
|
import net.minecraft.util.ChatComponentText;
|
2024-02-20 00:28:56 -06:00
|
|
|
import me.otterdev.UwUAPI;
|
2024-02-10 23:54:25 -06:00
|
|
|
import org.teavm.jso.JSBody;
|
|
|
|
import org.teavm.jso.JSObject;
|
2024-02-23 03:00:17 -06:00
|
|
|
import net.minecraft.enchantment.Enchantment;
|
|
|
|
import net.minecraft.init.Blocks;
|
|
|
|
import net.minecraft.init.Items;
|
|
|
|
import net.minecraft.block.material.Material;
|
2024-02-10 23:54:25 -06:00
|
|
|
|
2024-02-11 03:43:45 -06:00
|
|
|
import java.util.ArrayList;
|
|
|
|
|
2024-02-10 23:54:25 -06:00
|
|
|
import static net.lax1dude.eaglercraft.v1_8.EaglercraftVersion.projectForkVersion;
|
2024-02-22 07:09:44 -06:00
|
|
|
import static net.minecraft.client.Minecraft.getDebugFPS;
|
|
|
|
import net.minecraft.client.gui.Gui;
|
2024-02-10 23:54:25 -06:00
|
|
|
|
|
|
|
public class ModAPI {
|
2024-02-22 07:09:44 -06:00
|
|
|
|
2024-02-10 23:54:25 -06:00
|
|
|
private static Minecraft mc;
|
2024-03-02 02:57:12 -06:00
|
|
|
private static ScaledResolution sr;
|
2024-03-02 00:27:15 -06:00
|
|
|
|
|
|
|
private static Gui gui;
|
2024-02-11 03:43:45 -06:00
|
|
|
public ArrayList<String> requiredList;
|
2024-02-10 23:54:25 -06:00
|
|
|
public static final Logger log = LogManager.getLogger();
|
|
|
|
public static String version = projectForkVersion;
|
2024-02-11 03:43:45 -06:00
|
|
|
public static boolean clientPacketSendEventsEnabled = true;
|
2024-02-13 04:19:11 -06:00
|
|
|
@JSBody(params = { "version" }, script = "initAPI(version)")
|
2024-02-10 23:54:25 -06:00
|
|
|
public static native void initAPI(String version);
|
2024-02-11 03:43:45 -06:00
|
|
|
@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);
|
|
|
|
|
2024-03-20 09:56:48 -05:00
|
|
|
@JSBody(params = { "minecraft" }, script = "window.Minecraft = minecraft;")
|
|
|
|
public static native void setMinecraftContext(BaseData minecraft);
|
|
|
|
|
|
|
|
|
2024-02-11 03:43:45 -06:00
|
|
|
public void onGlobalUpdated(String global) {
|
|
|
|
// logger.info("Global update request: "+global);
|
|
|
|
BaseData data = getGlobal(global);
|
|
|
|
// logJSObj(data);
|
|
|
|
if (data == null) {
|
|
|
|
return;
|
|
|
|
}
|
2024-02-23 03:00:17 -06:00
|
|
|
switch (global) {
|
|
|
|
case "player":
|
|
|
|
mc.thePlayer.loadModData(data);
|
|
|
|
}
|
2024-02-11 03:43:45 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onRequire(String global) {
|
|
|
|
if (!requiredList.contains(global)) {
|
|
|
|
log.info("Required global: " + global);
|
|
|
|
requiredList.add(global);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-02-10 23:54:25 -06:00
|
|
|
public ModAPI(Minecraft mcIn) {
|
|
|
|
this.mc = mcIn;
|
2024-02-11 03:43:45 -06:00
|
|
|
requiredList = new ArrayList<String>();
|
2024-02-10 23:54:25 -06:00
|
|
|
initAPI(version);
|
2024-02-19 04:15:45 -06:00
|
|
|
|
|
|
|
newEvent("load");
|
|
|
|
newEvent("gui");
|
2024-02-20 00:28:56 -06:00
|
|
|
newEvent("drawhud");
|
2024-02-22 07:09:44 -06:00
|
|
|
newEvent("key");
|
2024-02-23 03:00:17 -06:00
|
|
|
newEvent("postmotionupdate");
|
|
|
|
newEvent("motionupdate");
|
|
|
|
newEvent("premotionupdate");
|
2024-03-08 05:57:27 -06:00
|
|
|
newEvent("sendchatmessage");
|
2024-02-15 13:15:52 -06:00
|
|
|
newEvent("update");
|
2024-03-20 09:56:48 -05:00
|
|
|
newEvent("frame");
|
2024-06-05 12:44:45 -05:00
|
|
|
newEvent("render");
|
2024-02-23 03:00:17 -06:00
|
|
|
|
|
|
|
/*newEvent("packetjoingame");
|
|
|
|
newEvent("packetspawnobject");
|
|
|
|
newEvent("packetspawnxporb");
|
|
|
|
newEvent("packetspawnglobalentity");
|
|
|
|
newEvent("packetspawnpainting");
|
|
|
|
newEvent("packetentityvelocity");
|
|
|
|
newEvent("packetentitymetadata");
|
|
|
|
newEvent("packetspawnplayer");
|
|
|
|
newEvent("packetentityteleport");
|
|
|
|
newEvent("packethelditemchange");
|
|
|
|
newEvent("packetentity");
|
|
|
|
newEvent("packetentityheadlook");
|
|
|
|
newEvent("packetdestroyentities");
|
|
|
|
newEvent("packetplayerposlook");
|
|
|
|
newEvent("packetmultiblockchange");
|
|
|
|
newEvent("packetchunkdata");
|
|
|
|
newEvent("packetblockchange");
|
|
|
|
newEvent("packetdisconnect");
|
|
|
|
newEvent("packetcollectitem");
|
|
|
|
newEvent("packetchat");
|
|
|
|
newEvent("packetanimation");
|
|
|
|
newEvent("packetusebed");
|
|
|
|
newEvent("packetspawnmob");
|
|
|
|
newEvent("packettimeupdate");
|
|
|
|
newEvent("packetspawnposition");
|
|
|
|
newEvent("packetentityattatch");
|
|
|
|
newEvent("packetentitystatus");
|
|
|
|
newEvent("packetupdatehealth");
|
|
|
|
newEvent("packetsetxp");
|
|
|
|
newEvent("packetrespawn");
|
|
|
|
newEvent("packetexplosion");
|
|
|
|
newEvent("packetopenwindow");
|
|
|
|
newEvent("packetsetslot");
|
|
|
|
newEvent("packetconfirmtransaction");
|
|
|
|
newEvent("packetwindowitems");
|
|
|
|
newEvent("packetsigneditoropen");
|
|
|
|
newEvent("packetupdatesign");
|
|
|
|
newEvent("packetupdatetileentity");
|
|
|
|
newEvent("packetwindowproperty");
|
|
|
|
newEvent("packetentityequipment");
|
|
|
|
newEvent("packetclosewindow");
|
|
|
|
newEvent("packetblockaction");
|
|
|
|
newEvent("packetblockbreakanim");
|
|
|
|
newEvent("packetmapchunkbulk");
|
|
|
|
newEvent("packetchangegamestate");
|
|
|
|
newEvent("packetmaps");
|
|
|
|
newEvent("packeteffect");
|
|
|
|
newEvent("packetstatistics");
|
|
|
|
newEvent("packetentityeffect");
|
|
|
|
newEvent("packetcombatevent");
|
|
|
|
newEvent("packetserverdifficulty");
|
|
|
|
newEvent("packetcamera");
|
|
|
|
newEvent("packetworldborder");
|
|
|
|
newEvent("packettitle");
|
|
|
|
newEvent("packetsetcompressionlevel");
|
|
|
|
newEvent("packetplayerlistheaderfooter");
|
|
|
|
newEvent("packetremoveentityeffect");
|
|
|
|
newEvent("packetplayerlistitem");
|
|
|
|
newEvent("packetkeepalive");
|
|
|
|
newEvent("packetplayerabilities");
|
|
|
|
newEvent("packettabcomplete");
|
|
|
|
newEvent("packetsoundeffect");
|
|
|
|
newEvent("packetresourcepack");
|
|
|
|
newEvent("packetupdateentitynbt");
|
|
|
|
newEvent("packetcustompayload");
|
|
|
|
newEvent("packetscoreboardobjective");
|
|
|
|
newEvent("packetupdatescore");
|
|
|
|
newEvent("packetdisplayscoreboard");
|
|
|
|
newEvent("packetteams");
|
|
|
|
newEvent("packetparticles");
|
2024-03-12 07:27:15 -05:00
|
|
|
newEvent("packetentityproperties");*/
|
2024-02-23 03:00:17 -06:00
|
|
|
|
|
|
|
newEvent("sendpacketanimation");
|
|
|
|
newEvent("sendpacketentityaction");
|
|
|
|
newEvent("sendpacketinput");
|
|
|
|
newEvent("sendpacketclosewindow");
|
|
|
|
newEvent("sendpacketclickwindow");
|
|
|
|
newEvent("sendpacketconfirmtransaction");
|
|
|
|
newEvent("sendpacketkeepalive");
|
|
|
|
newEvent("sendpacketchatmessage");
|
|
|
|
newEvent("sendpacketuseentity");
|
|
|
|
newEvent("sendpacketplayer");
|
|
|
|
newEvent("sendpacketplayerposition");
|
|
|
|
newEvent("sendpacketplayerlook");
|
|
|
|
newEvent("sendpacketplayerposlook");
|
|
|
|
newEvent("sendpacketplayerdigging");
|
|
|
|
newEvent("sendpacketplayerblockplacement");
|
|
|
|
newEvent("sendpackethelditemchange");
|
|
|
|
newEvent("sendpacketcreativeinventoryaction");
|
|
|
|
newEvent("sendpacketenchantitem");
|
|
|
|
newEvent("sendpacketupdatesign");
|
|
|
|
newEvent("sendpacketplayerabilities");
|
|
|
|
newEvent("sendpackettabcomplete");
|
|
|
|
newEvent("sendpacketclientsettings");
|
|
|
|
newEvent("sendpacketclientstatus");
|
|
|
|
newEvent("sendpacketcustompayload");
|
|
|
|
newEvent("sendpacketspectate");
|
2024-03-12 07:27:15 -05:00
|
|
|
newEvent("sendpacketresourcepackstatus");
|
|
|
|
|
|
|
|
newEvent("packetsoundeffect");
|
|
|
|
newEvent("packetchat");
|
2024-02-15 13:15:52 -06:00
|
|
|
globalsFunctor(this);
|
|
|
|
globalsRequireFunctor(this);
|
|
|
|
globalsUpdateFunctor(this);
|
2024-02-11 03:43:45 -06:00
|
|
|
getModAPI().setCallbackVoidWithDataArg("displayToChat", (BaseData params) -> {
|
|
|
|
mc.ingameGUI.getChatGUI().printChatMessage(new ChatComponentText(params.getString("msg")));
|
|
|
|
});
|
2024-05-03 08:54:52 -05:00
|
|
|
getModAPI().setCallbackStringWithDataArg("rate", (BaseData params) -> {
|
|
|
|
int hash = 0;
|
|
|
|
int counterRate = 0;
|
|
|
|
|
|
|
|
for (i < params.getString('string').length(); i++) {
|
|
|
|
hash = (hash << 5) - hash + params.getString('string').codePointAt();
|
|
|
|
}
|
|
|
|
|
|
|
|
String res = (Math.abs(hash) % 100) + 1;
|
|
|
|
|
|
|
|
return res;
|
|
|
|
});
|
2024-02-16 10:43:17 -06:00
|
|
|
getModAPI().setCallbackStringWithDataArg("uwuify", (BaseData params) -> {
|
|
|
|
return UwUAPI.uwuify(params.getString("string"));
|
|
|
|
});
|
2024-02-11 03:43:45 -06:00
|
|
|
getModAPI().setCallbackVoid("clickMouse", () -> {
|
|
|
|
mc.clickMouse();
|
|
|
|
});
|
|
|
|
getModAPI().setCallbackVoid("rightClickMouse", () -> {
|
|
|
|
mc.rightClickMouse();
|
|
|
|
});
|
2024-03-02 00:27:15 -06:00
|
|
|
getModAPI().setCallbackInt("getFPS", () -> {
|
|
|
|
return getDebugFPS();
|
2024-02-22 07:09:44 -06:00
|
|
|
});
|
2024-03-26 01:51:08 -05:00
|
|
|
/*getModAPI().setCallbackVoidWithDataArg("displayParticleAtPlayer", (BaseData params) -> {
|
2024-03-20 09:56:48 -05:00
|
|
|
if (params.getString("type") == "EXPLOSION_NORMAL") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.EXPLOSION_NORMAL);
|
|
|
|
} else if (params.getString("type") == "EXPLOSION_LARGE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.EXPLOSION_LARGE);
|
|
|
|
} else if (params.getString("type") == "EXPLOSION_HUGE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.EXPLOSION_HUGE);
|
|
|
|
} else if (params.getString("type") == "FIREWORKS_SPARK") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.FIREWORKS_SPARK);
|
|
|
|
} else if (params.getString("type") == "WATER_BUBBLE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.WATER_BUBBLE);
|
|
|
|
} else if (params.getString("type") == "WATER_SPLASH") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.WATER_SPLASH);
|
|
|
|
} else if (params.getString("type") == "WATER_WAKE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.WATER_WAKE);
|
|
|
|
} else if (params.getString("type") == "SUSPENDED") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SUSPENDED);
|
|
|
|
} else if (params.getString("type") == "SUSPENDED_DEPTH") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SUSPENDED_DEPTH);
|
|
|
|
} else if (params.getString("type") == "CRIT") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.CRIT);
|
|
|
|
} else if (params.getString("type") == "CRIT_MAGIC") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.CRIT_MAGIC);
|
|
|
|
} else if (params.getString("type") == "SMOKE_NORMAL") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SMOKE_NORMAL);
|
|
|
|
} else if (params.getString("type") == "SMOKE_LARGE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SMOKE_LARGE);
|
|
|
|
} else if (params.getString("type") == "SPELL") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SPELL);
|
|
|
|
} else if (params.getString("type") == "SPELL_INSTANT") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SPELL_INSTANT);
|
|
|
|
} else if (params.getString("type") == "SPELL_MOB") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SPELL_MOB);
|
|
|
|
} else if (params.getString("type") == "SPELL_MOB_AMBIENT") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SPELL_MOB_AMBIENT);
|
|
|
|
} else if (params.getString("type") == "SPELL_WITCH") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SPELL_WITCH);
|
|
|
|
} else if (params.getString("type") == "DRIP_WATER") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.DRIP_WATER);
|
|
|
|
} else if (params.getString("type") == "DRIP_LAVA") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.DRIP_LAVA);
|
|
|
|
} else if (params.getString("type") == "VILLAGER_ANGRY") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.VILLAGER_ANGRY);
|
|
|
|
} else if (params.getString("type") == "VILLAGER_HAPPY") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.VILLAGER_HAPPY);
|
|
|
|
} else if (params.getString("type") == "TOWN_AURA") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.TOWN_AURA);
|
|
|
|
} else if (params.getString("type") == "NOTE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.NOTE);
|
|
|
|
} else if (params.getString("type") == "PORTAL") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.PORTAL);
|
|
|
|
} else if (params.getString("type") == "ENCHANTMENT_TABLE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.ENCHANTMENT_TABLE);
|
|
|
|
} else if (params.getString("type") == "FLAME") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.FLAME);
|
|
|
|
} else if (params.getString("type") == "LAVA") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.LAVA);
|
|
|
|
} else if (params.getString("type") == "FOOTSTEP") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.FOOTSTEP);
|
|
|
|
} else if (params.getString("type") == "CLOUD") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.CLOUD);
|
|
|
|
} else if (params.getString("type") == "REDSTONE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.REDSTONE);
|
|
|
|
} else if (params.getString("type") == "SNOWBALL") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SNOWBALL);
|
|
|
|
} else if (params.getString("type") == "SNOW_SHOVEL") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SNOW_SHOVEL);
|
|
|
|
} else if (params.getString("type") == "SLIME") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.SLIME);
|
|
|
|
} else if (params.getString("type") == "HEART") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.HEART);
|
|
|
|
} else if (params.getString("type") == "BARRIER") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.BARRIER);
|
|
|
|
} else if (params.getString("type") == "ITEM_CRACK") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.ITEM_CRACK);
|
|
|
|
} else if (params.getString("type") == "BLOCK_CRACK") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.BLOCK_CRACK);
|
|
|
|
} else if (params.getString("type") == "BLOCK_DUST") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.BLOCK_DUST);
|
|
|
|
} else if (params.getString("type") == "WATER_DROP") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.WATER_DROP);
|
|
|
|
} else if (params.getString("type") == "ITEM_TAKE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.ITEM_TAKE);
|
|
|
|
} else if (params.getString("type") == "MOB_APPEARANCE") {
|
|
|
|
mc.effectRenderer.emitParticleAtEntity(mc.thePlayer, EnumParticleTypes.MOB_APPEARANCE);
|
|
|
|
}
|
2024-03-26 01:51:08 -05:00
|
|
|
});*/
|
2024-02-11 03:43:45 -06:00
|
|
|
getModAPI().set("clientBrand", ClientBrandRetriever.getClientModName());
|
|
|
|
|
2024-02-23 03:00:17 -06:00
|
|
|
setGlobal("enchantments", Enchantment.makeModDataStatic());
|
|
|
|
setGlobal("blocks", Blocks.makeModData());
|
|
|
|
setGlobal("items", Items.makeModData());
|
|
|
|
setGlobal("materials", Material.makeModDataStatic());
|
2024-02-11 03:43:45 -06:00
|
|
|
setGlobal("mcinstance", mc);
|
2024-03-20 09:56:48 -05:00
|
|
|
setMinecraftContext(mc);
|
2024-02-16 10:43:17 -06:00
|
|
|
setGlobal("platform", PlatformAPI.makeModData());
|
2024-05-29 10:56:04 -05:00
|
|
|
setGlobal("reflect", PLReflect.makeModData());
|
2024-02-16 10:43:17 -06:00
|
|
|
setGlobal("logger", LoggerAPI.makeModData());
|
2024-03-26 01:51:08 -05:00
|
|
|
//setGlobal("emptygui", EmptyGui.makeModData());
|
2024-03-02 02:57:12 -06:00
|
|
|
setGlobal("ScaledResolution", ScaledResolution.makeModData());
|
2024-03-08 05:57:27 -06:00
|
|
|
setGlobal("GlStateManager", GlStateManager.makeModData());
|
2024-03-26 01:51:08 -05:00
|
|
|
setGlobal("sp", SingleplayerServerController.makeModData());
|
2024-03-02 02:57:12 -06:00
|
|
|
getModAPI().setCallbackString("currentScreen", () -> {
|
|
|
|
return mc.currentScreen.toString();
|
|
|
|
});
|
2024-02-20 00:28:56 -06:00
|
|
|
getModAPI().setCallbackInt("getdisplayHeight", () -> {
|
|
|
|
return mc.displayHeight;
|
|
|
|
});
|
|
|
|
getModAPI().setCallbackInt("getdisplayWidth", () -> {
|
|
|
|
return mc.displayWidth;
|
|
|
|
});
|
2024-03-08 05:57:27 -06:00
|
|
|
getModAPI().setCallbackInt("getdisplayWidth", () -> {
|
|
|
|
return mc.displayWidth;
|
|
|
|
});
|
2024-03-02 02:57:12 -06:00
|
|
|
getModAPI().setCallbackInt("getFONT_HEIGHT", () -> {
|
|
|
|
return mc.fontRendererObj.FONT_HEIGHT;
|
|
|
|
});
|
2024-03-08 05:57:27 -06:00
|
|
|
getModAPI().setCallbackIntWithDataArg("getStringWidth", (BaseData params) -> {
|
|
|
|
return mc.fontRendererObj.getStringWidth(params.getString("string"));
|
|
|
|
});
|
2024-02-20 00:28:56 -06:00
|
|
|
getModAPI().setCallbackVoidWithDataArg("drawStringWithShadow", (BaseData params) -> {
|
|
|
|
mc.fontRendererObj.drawStringWithShadow(params.getString("msg"), params.getFloat("x"), params.getFloat("y"), params.getInt("color"));
|
|
|
|
});
|
|
|
|
getModAPI().setCallbackVoidWithDataArg("drawString", (BaseData params) -> {
|
|
|
|
mc.fontRendererObj.drawString(params.getString("msg"), params.getFloat("x"), params.getFloat("y"), params.getInt("color"), false);
|
|
|
|
});
|
2024-02-22 07:09:44 -06:00
|
|
|
getModAPI().setCallbackVoidWithDataArg("drawRect", (BaseData params) -> {
|
2024-03-02 00:27:15 -06:00
|
|
|
gui.drawRect(params.getInt("left"), params.getInt("top"), params.getInt("right"), params.getInt("bottom"), params.getInt("color"));
|
2024-02-22 07:09:44 -06:00
|
|
|
});
|
2024-03-20 09:56:48 -05:00
|
|
|
getModAPI().setCallbackVoid("reloadchunks", () -> {
|
|
|
|
mc.renderGlobal.loadRenderers();
|
|
|
|
});
|
|
|
|
getModAPI().setCallbackString("getProfileName", () -> {
|
|
|
|
return EaglerProfile.getName();
|
|
|
|
});
|
2024-02-15 06:00:47 -06:00
|
|
|
ModGUI.loadFont();
|
2024-02-11 03:43:45 -06:00
|
|
|
}
|
|
|
|
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();
|
|
|
|
});
|
|
|
|
}
|
2024-03-26 01:51:08 -05:00
|
|
|
|
2024-02-11 03:43:45 -06:00
|
|
|
|
2024-02-22 07:09:44 -06:00
|
|
|
|
2024-02-11 03:43:45 -06:00
|
|
|
public void onUpdate() {
|
2024-02-23 03:00:17 -06:00
|
|
|
if (requiredList.contains("player") && mc.thePlayer != null) {
|
|
|
|
ModAPI.setGlobal("player", mc.thePlayer.makeModData());
|
|
|
|
}
|
2024-03-12 07:27:15 -05:00
|
|
|
if (requiredList.contains("network") && mc.thePlayer != null && mc.thePlayer.sendQueue != null) {
|
2024-02-23 03:00:17 -06:00
|
|
|
ModAPI.setGlobal("network", mc.thePlayer.sendQueue.makeModData());
|
2024-03-12 07:27:15 -05:00
|
|
|
}
|
2024-03-26 01:51:08 -05:00
|
|
|
if (requiredList.contains("server") && mc.getCurrentServerData() != null) {
|
|
|
|
ModAPI.setGlobal("server", server.makeModData());
|
|
|
|
}
|
2024-03-20 09:56:48 -05:00
|
|
|
ModAPI.callEvent("update", new ModData());
|
|
|
|
}
|
|
|
|
public void onFrame(){
|
2024-02-23 03:00:17 -06:00
|
|
|
if (requiredList.contains("settings") && mc.gameSettings != null) {
|
|
|
|
ModAPI.setGlobal("settings", mc.gameSettings.makeModData());
|
|
|
|
}
|
2024-03-20 09:56:48 -05:00
|
|
|
ModAPI.callEvent("frame", new ModData());
|
2024-02-10 23:54:25 -06:00
|
|
|
}
|
|
|
|
}
|