mirror of
https://github.com/eaglerforge/EaglerForgeInjector
synced 2025-07-25 23:16:56 -09:00
Fix lib events
This commit is contained in:
parent
7615fb213f
commit
2e60921d5f
@ -61,6 +61,9 @@ ModAPI.dedicatedServer.appendCode(function () {
|
|||||||
var blockPos = blockPosConstructor(Math.round(hitResult.$hitVec.$xCoord), Math.round(hitResult.$hitVec.$yCoord), Math.round(hitResult.$hitVec.$zCoord));
|
var blockPos = blockPosConstructor(Math.round(hitResult.$hitVec.$xCoord), Math.round(hitResult.$hitVec.$yCoord), Math.round(hitResult.$hitVec.$zCoord));
|
||||||
var blockType = blockTypesList[Math.floor(Math.random() * blockTypesList.length)];
|
var blockType = blockTypesList[Math.floor(Math.random() * blockTypesList.length)];
|
||||||
blockType = ModAPI.blocks[blockType];
|
blockType = ModAPI.blocks[blockType];
|
||||||
|
console.log(blockType);
|
||||||
|
var block = blockType.getDefaultState().getRef();
|
||||||
|
console.log(block, blockPos);
|
||||||
pair.world.setBlockState(blockPos, block, 3);
|
pair.world.setBlockState(blockPos, block, 3);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -364,7 +364,7 @@ globalThis.modapi_postinit = `(() => {
|
|||||||
if (!callback || typeof callback !== "function") {
|
if (!callback || typeof callback !== "function") {
|
||||||
throw new Error("[ModAPI] Invalid callback!");
|
throw new Error("[ModAPI] Invalid callback!");
|
||||||
}
|
}
|
||||||
if (ModAPI.events.types.includes(name) || name.startsWith("custom:") || name.startsWith("lib:")) {
|
if (ModAPI.events.types.includes(name) || name.startsWith("custom:")) {
|
||||||
if (!Array.isArray(ModAPI.events.listeners[name])) {
|
if (!Array.isArray(ModAPI.events.listeners[name])) {
|
||||||
ModAPI.events.listeners[name] = [];
|
ModAPI.events.listeners[name] = [];
|
||||||
}
|
}
|
||||||
@ -406,6 +406,15 @@ globalThis.modapi_postinit = `(() => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ModAPI.events.callEvent = function callEvent(name, data) {
|
ModAPI.events.callEvent = function callEvent(name, data) {
|
||||||
|
if (ModAPI.events.types.includes(name) && name.startsWith("lib:")) {
|
||||||
|
if (Array.isArray(ModAPI.events.listeners[name])) {
|
||||||
|
ModAPI.events.listeners[name].forEach((func) => {
|
||||||
|
func({});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ModAPI.events.lib_map[name] = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
!ModAPI.events.types.includes(name) ||
|
!ModAPI.events.types.includes(name) ||
|
||||||
!Array.isArray(ModAPI.events.listeners[name])
|
!Array.isArray(ModAPI.events.listeners[name])
|
||||||
@ -425,19 +434,12 @@ globalThis.modapi_postinit = `(() => {
|
|||||||
console.error("Please report this bug to the repo.");
|
console.error("Please report this bug to the repo.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name.startsWith("lib:")) {
|
|
||||||
ModAPI.events.listeners[name].forEach((func) => {
|
|
||||||
func({});
|
|
||||||
});
|
|
||||||
ModAPI.events.lib_map[name] = true;
|
|
||||||
} else {
|
|
||||||
ModAPI.events.listeners[name].forEach((func) => {
|
ModAPI.events.listeners[name].forEach((func) => {
|
||||||
func(data);
|
func(data);
|
||||||
});
|
});
|
||||||
ModAPI.events.listeners.event.forEach((func) => {
|
ModAPI.events.listeners.event.forEach((func) => {
|
||||||
func({ event: name, data: data });
|
func({ event: name, data: data });
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
ModAPI.events.newEvent("update", "client");
|
ModAPI.events.newEvent("update", "client");
|
||||||
|
|
||||||
|
18
postinit.js
18
postinit.js
@ -364,7 +364,7 @@
|
|||||||
if (!callback || typeof callback !== "function") {
|
if (!callback || typeof callback !== "function") {
|
||||||
throw new Error("[ModAPI] Invalid callback!");
|
throw new Error("[ModAPI] Invalid callback!");
|
||||||
}
|
}
|
||||||
if (ModAPI.events.types.includes(name) || name.startsWith("custom:") || name.startsWith("lib:")) {
|
if (ModAPI.events.types.includes(name) || name.startsWith("custom:")) {
|
||||||
if (!Array.isArray(ModAPI.events.listeners[name])) {
|
if (!Array.isArray(ModAPI.events.listeners[name])) {
|
||||||
ModAPI.events.listeners[name] = [];
|
ModAPI.events.listeners[name] = [];
|
||||||
}
|
}
|
||||||
@ -406,6 +406,15 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
ModAPI.events.callEvent = function callEvent(name, data) {
|
ModAPI.events.callEvent = function callEvent(name, data) {
|
||||||
|
if (ModAPI.events.types.includes(name) && name.startsWith("lib:")) {
|
||||||
|
if (Array.isArray(ModAPI.events.listeners[name])) {
|
||||||
|
ModAPI.events.listeners[name].forEach((func) => {
|
||||||
|
func({});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
ModAPI.events.lib_map[name] = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (
|
if (
|
||||||
!ModAPI.events.types.includes(name) ||
|
!ModAPI.events.types.includes(name) ||
|
||||||
!Array.isArray(ModAPI.events.listeners[name])
|
!Array.isArray(ModAPI.events.listeners[name])
|
||||||
@ -425,19 +434,12 @@
|
|||||||
console.error("Please report this bug to the repo.");
|
console.error("Please report this bug to the repo.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (name.startsWith("lib:")) {
|
|
||||||
ModAPI.events.listeners[name].forEach((func) => {
|
|
||||||
func({});
|
|
||||||
});
|
|
||||||
ModAPI.events.lib_map[name] = true;
|
|
||||||
} else {
|
|
||||||
ModAPI.events.listeners[name].forEach((func) => {
|
ModAPI.events.listeners[name].forEach((func) => {
|
||||||
func(data);
|
func(data);
|
||||||
});
|
});
|
||||||
ModAPI.events.listeners.event.forEach((func) => {
|
ModAPI.events.listeners.event.forEach((func) => {
|
||||||
func({ event: name, data: data });
|
func({ event: name, data: data });
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
};
|
||||||
ModAPI.events.newEvent("update", "client");
|
ModAPI.events.newEvent("update", "client");
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user