mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-24 22:51:18 -09:00
frame event, scaledresolution, crafting postprocessing for LCI
This commit is contained in:
parent
c1234e997b
commit
8d4a8152be
@ -39,7 +39,9 @@ Events broadcast data for use in mods.
|
||||
- String representing the type of event being fired.
|
||||
- `data: Object`
|
||||
- Object representing the original arguments to be passed to the callback.
|
||||
|
||||
- `frame`:
|
||||
- Called just when a frame is rendered on the client.
|
||||
- Event object is blank.
|
||||
### Server Side Events
|
||||
Can only be used in the context of the dedicated server. More: [DedicatedServerDocumentation](dedicatedserver.md)
|
||||
- `serverstart`:
|
||||
|
@ -59,6 +59,10 @@ The global object has the following properties:
|
||||
- `ModAPI.array`
|
||||
- This object is used to interact and create arrays easily.
|
||||
- More: [ArrayDocumentation](array.md)
|
||||
- `ModAPI.resolution`
|
||||
- This object is used to query information about GUI dimensions, to make drawing to the screen easier, generated when the `frame` event is fired.
|
||||
- Deprecated alias (please do not use): `ModAPI.ScaledResolution`
|
||||
- More: [ArrayDocumentation](array.md)
|
||||
- `ModAPI.version: String`
|
||||
- The version of ModAPI.
|
||||
- `ModAPI.flavour: String`
|
||||
|
@ -6,11 +6,12 @@
|
||||
ModAPI.meta.description("Library to make adding basic custom items easier.");
|
||||
ModAPI.events.newEvent("lib:libcustomitems:loaded");
|
||||
function libServerside() {
|
||||
var packetblockchange = ModAPI.reflect.getClassByName("S23PacketBlockChange").constructors.find(x => {return x.length === 2});
|
||||
var packetblockchange = ModAPI.reflect.getClassByName("S23PacketBlockChange").constructors.find(x => { return x.length === 2 });
|
||||
var sendPacket = ModAPI.reflect.getClassByName("NetHandlerPlayServer").methods.sendPacket.method;
|
||||
globalThis.LCI_REGISTRY ||= [];
|
||||
globalThis.LCI_RMBEVENTS ||= {};
|
||||
globalThis.LCI_LMBEVENTS ||= {};
|
||||
globalThis.LCI_RECIPEEVENTS ||= {};
|
||||
var useName = ModAPI.util.getMethodFromPackage("net.minecraft.network.NetHandlerPlayServer", "processPlayerBlockPlacement");
|
||||
var oldUse = ModAPI.hooks.methods[useName];
|
||||
ModAPI.hooks.methods[useName] = function ($this, packet) {
|
||||
@ -91,6 +92,7 @@
|
||||
globalThis.LCI_REGISTRY ||= [];
|
||||
globalThis.LCI_RMBEVENTS ||= {};
|
||||
globalThis.LCI_LMBEVENTS ||= {};
|
||||
globalThis.LCI_RECIPEEVENTS ||= {};
|
||||
globalThis.LCI_REGISTRY.push(data.tag);
|
||||
if (data.onRightClickGround) {
|
||||
globalThis.LCI_RMBEVENTS[data.tag] = new Function("user", "world", "itemstack", "blockpos", data.onRightClickGround);
|
||||
@ -98,6 +100,9 @@
|
||||
if (data.onLeftClickGround) {
|
||||
globalThis.LCI_LMBEVENTS[data.tag] = new Function("user", "world", "itemstack", "blockpos", data.onLeftClickGround);
|
||||
}
|
||||
if (data.craftingExtra) {
|
||||
globalThis.LCI_RECIPEEVENTS[data.tag] = new Function("itemstack", data.craftingExtra);
|
||||
}
|
||||
var ObjectClass = ModAPI.reflect.getClassById("java.lang.Object").class;
|
||||
function ToChar(char) {
|
||||
return ModAPI.reflect.getClassById("java.lang.Character").staticMethods.valueOf.method(char[0].charCodeAt(0));
|
||||
@ -132,6 +137,9 @@
|
||||
var lore = ModAPI.reflect.getClassById("net.minecraft.nbt.NBTTagList").constructors[0]();
|
||||
lore.$appendTag(ModAPI.reflect.getClassById("net.minecraft.nbt.NBTTagString").constructors.filter(x => { return x.length === 1 })[0](ModAPI.util.str(data.tag)));
|
||||
displayTag.$setTag(ModAPI.util.str("Lore"), lore);
|
||||
if (globalThis.LCI_RECIPEEVENTS[data.tag]) {
|
||||
globalThis.LCI_RECIPEEVENTS[data.tag](new Proxy(testItem, ModAPI.util.TeaVM_to_Recursive_BaseData_ProxyConf));
|
||||
}
|
||||
|
||||
var craftingManager = ModAPI.reflect.getClassById("net.minecraft.item.crafting.CraftingManager").staticMethods.getInstance.method();
|
||||
ModAPI.hooks.methods.nmic_CraftingManager_addRecipe(craftingManager, testItem, recipe);
|
||||
|
@ -648,6 +648,18 @@ globalThis.modapi_postinit = `(() => {
|
||||
return sendChatMessage.apply(this, [$this, $message]);
|
||||
}
|
||||
|
||||
const ScaledResolutionConstructor = ModAPI.reflect.getClassByName("ScaledResolution").constructors[0];
|
||||
ModAPI.events.newEvent("frame", "client");
|
||||
const frameMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "runTick");
|
||||
const frameMethod = ModAPI.hooks.methods[frameMethodName];
|
||||
ModAPI.hooks.methods[frameMethodName] = function (...args) {
|
||||
ModAPI.events.callEvent("frame", {});
|
||||
if (ModAPI.required.has("resolution") && ModAPI.mcinstance) {
|
||||
ModAPI.ScaledResolution = ModAPI.resolution = new Proxy(ScaledResolutionConstructor(ModAPI.mcinstance), TeaVM_to_Recursive_BaseData_ProxyConf);
|
||||
}
|
||||
return frameMethod.apply(this, args);
|
||||
}
|
||||
|
||||
ModAPI.events.newEvent("tick", "server");
|
||||
const serverTickMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.server.MinecraftServer", "tick");
|
||||
const serverTickMethod = ModAPI.hooks.methods[serverTickMethodName];
|
||||
|
12
postinit.js
12
postinit.js
@ -648,6 +648,18 @@
|
||||
return sendChatMessage.apply(this, [$this, $message]);
|
||||
}
|
||||
|
||||
const ScaledResolutionConstructor = ModAPI.reflect.getClassByName("ScaledResolution").constructors[0];
|
||||
ModAPI.events.newEvent("frame", "client");
|
||||
const frameMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.client.Minecraft", "runTick");
|
||||
const frameMethod = ModAPI.hooks.methods[frameMethodName];
|
||||
ModAPI.hooks.methods[frameMethodName] = function (...args) {
|
||||
ModAPI.events.callEvent("frame", {});
|
||||
if (ModAPI.required.has("resolution") && ModAPI.mcinstance) {
|
||||
ModAPI.ScaledResolution = ModAPI.resolution = new Proxy(ScaledResolutionConstructor(ModAPI.mcinstance), TeaVM_to_Recursive_BaseData_ProxyConf);
|
||||
}
|
||||
return frameMethod.apply(this, args);
|
||||
}
|
||||
|
||||
ModAPI.events.newEvent("tick", "server");
|
||||
const serverTickMethodName = ModAPI.util.getMethodFromPackage("net.minecraft.server.MinecraftServer", "tick");
|
||||
const serverTickMethod = ModAPI.hooks.methods[serverTickMethodName];
|
||||
|
Loading…
x
Reference in New Issue
Block a user