feature(areacontrol): more command and logout recover

feature(areacontrol):
- merge setcenter and setradius into single command
- add setAreaPos command to simplify the process of setting radius
- recover gamemode when logout
This commit is contained in:
2025-11-12 21:02:28 +08:00
parent b6a958af58
commit 17987c0cec
2 changed files with 212 additions and 104 deletions

View File

@@ -1,3 +1,17 @@
/**
* @typedef {(
* "PlayerItemFishedEvent" |
* "LivingEntityUseItemEvent$Finish"
* )} EventName
*/
/**
* @typedef {(
* ((event: Internal.ItemFishedEvent) => any) |
* ((event: Internal.LivingEntityUseItemEvent$Finish) => any)
* )} EventCallback
*/
/**
* A simple event bus for handling custom events in KubeJS environment.
* @namespace
@@ -9,6 +23,13 @@ const eventBus = {
*/
eventMap: {},
/**
* Registers a callback function for a specific event.
* @overload
* @param {"PlayerItemFishedEvent"} eventName - The name of the event to listen for.
* @param {(event: Internal.ItemFishedEvent) => any} callback - The callback function.
* @returns {void}
*/
/**
* Registers a callback function for a specific event.
* @overload
@@ -18,14 +39,21 @@ const eventBus = {
*/
/**
* Registers a callback function for a specific event.
* @param {string} eventName - The name of the event to listen for.
* @param {Function} callback - The callback function to execute when the event is emitted.
* @param {EventName} eventName - The name of the event to listen for.
* @param {EventCallback} callback - The callback function to execute when the event is emitted.
* @returns {void}
*/
register: function (eventName, callback) {
this.eventMap[eventName] = callback;
},
/**
* Registers a callback function for a specific event.
* @overload
* @param {"PlayerItemFishedEvent"} eventName - The name of the event to listen for.
* @param {(event: Internal.ItemFishedEvent) => any} callback - The callback function.
* @returns {void}
*/
/**
* Emits an event, calling the registered callback function if it exists.
* @overload
@@ -59,3 +87,17 @@ ForgeEvents.onEvent(
eventBus.emit("LivingEntityUseItemEvent$Finish", event);
},
);
ForgeEvents.onEvent(
"net.minecraftforge.event.entity.player.ItemFishedEvent",
(event) => {
eventBus.emit("PlayerItemFishedEvent", event);
},
);
ForgeEvents.onEvent(
"net.minecraftforge.event.entity.player.ItemFishedEvent",
(event) => {
eventBus.emit("PlayerItemFishedEvent", event);
},
);