From 4af207a74e46e9acf463b20f218c3c1b5991fbce Mon Sep 17 00:00:00 2001 From: PneuJai <53138480+Rjlintkh@users.noreply.github.com> Date: Sat, 30 Apr 2022 14:04:49 +0800 Subject: [PATCH] Implement `MobSpawnEvent` --- README.md | 18 +- package-lock.json | 2 +- package.json | 2 +- src/api/block.ts | 24 +-- src/api/block_entity.ts | 6 +- src/api/command.ts | 19 +- src/api/container.ts | 16 +- src/api/device.ts | 6 +- src/api/entity.ts | 18 +- src/api/event.ts | 384 ++++++++++++++++++++-------------------- src/api/gui.ts | 8 +- src/api/index.ts | 38 ++-- src/api/item.ts | 18 +- src/api/logger.ts | 6 +- src/api/player.ts | 30 ++-- src/api/scoreboard.ts | 18 +- src/dep/BaseLib.js | 28 ++- src/dep/native.ts | 19 +- src/utils/money.ts | 10 +- 19 files changed, 351 insertions(+), 319 deletions(-) diff --git a/README.md b/README.md index b09b973..e395890 100644 --- a/README.md +++ b/README.md @@ -2,16 +2,16 @@ ## BDSX-LLSE: Load LiteLoader ScriptingEngine JS plugins in BDSX! #### Background -Both LiteLoader ScriptingEngine (LLSE) and Bedrock Dedicated Server eXtended (BDSX) are popular options of loading different kinds of plugins currently. However, JS plugins designed for LXL cannot be loaded in BDSX and they need a lot of extra work to port to BDSX. This plugin aims to reduce the work and allow users to load some of the LXL JS plugins with BDSX. +Both LiteLoader ScriptingEngine (LLSE) and Bedrock Dedicated Server eXtended (BDSX) are popular options of loading different kinds of plugins currently. However, JS plugins designed for LLSE cannot be loaded in BDSX and they need a lot of extra work to port to BDSX. This plugin aims to reduce the work and allow users to load some of the LLSE JS plugins with BDSX. #### Features -We aim to be consistent with the features of LXL, even with the bugs it has. However, there are some features that we could not implement at the time. +We aim to be consistent with the features of LLSE, even with the bugs it has. However, there are some features that we could not implement at the time. - Supported APIs: - Scripting - [x] [πŸ’Ό Helpers](https://lxl.litebds.com/#/zh_CN/Development/ScriptAPI/ScriptHelp) - [x] [πŸ“… Logger](https://lxl.litebds.com/#/zh_CN/Development/ScriptAPI/Logger) - - [x] [πŸ’‘ LXL](https://lxl.litebds.com/#/zh_CN/Development/ScriptAPI/Lxl) + - [x] [πŸ’‘ LL](https://lxl.litebds.com/#/zh_CN/Development/ScriptAPI/Ll) - [ ] [πŸ’‘ I18n](https://lxl.litebds.com/#/zh_CN/Development/ScriptAPI/i18n) - Game - [x] [🎨 Basic](https://lxl.litebds.com/#/zh_CN/Development/GameAPI/Basic) @@ -68,7 +68,7 @@ We aim to be consistent with the features of LXL, even with the bugs it has. How - Scripts that pass through `TSC` may throw errors with different position rather than the position of the original code. - Logging to file is not yet implemented and some colors and formats are not same as LXL's. - This plugin does not load any plugins written in Lua, the closet approach we tried was using `glua`, but it does not support `GOTO` syntax yet. - - There is no auto-update system currently, but you can run `npm i` to update it if this project got onto it. + - There is no auto-update system currently. - Tested Plugins: - [x] [BDSLM - εŸΊε²©η‰ˆε«ζ˜Ÿεœ°ε›Ύ](https://www.minebbs.com/resources/bdslm.3484/) @@ -98,15 +98,15 @@ We aim to be consistent with the features of LXL, even with the bugs it has. How #### Usage 1. Download `bdsx-lxl.zip` from the [latest release](https://github.com/Rjlintkh/bdsx-lxl/releases/latest) and extract it to `your_bdsx_folder/plugins` so that there is a folder named `your_bdsx_folder/plugins/bdsx-lxl`. -2. Create a folder `your_bdsx_folder/bedrock_server/plugins` and put all the LXL `.js` plugins inside. +2. Create a folder `your_bdsx_folder/bedrock_server/plugins` and put all the LLSE `.js` plugins inside. OR -Copy all content or create a junction from `your_lxl_folder/plugins` to `your_bdsx_folder/bedrock_server/plugins` if you have previously worked on LXL. +Copy all content or create a junction from `your_llse_folder/plugins` to `your_bdsx_folder/bedrock_server/plugins` if you have previously worked on LLSE. 1. Start the server from `your_bdsx_folder/bdsx.bat`. #### Disclaimers -- In order to use this project, you must follow the terms of EULA and LXL. -- This project is not affiliated to LXL, but it imitates the functionalities of LXL. No code is directly copied, but the logic of codes are kept for the purpose of loading plugins. -- We do not offer guarantee of successfully loading any LXL plugins. +- In order to use this project, you must follow the terms of EULA and LLSE. +- This project is not affiliated to LLSE, but it imitates the functionalities of LLSE. No code is directly copied, but the logic of codes are kept for the purpose of loading plugins. +- We do not offer guarantee of successfully loading any LLSE plugins. - The project is experimental, it may contain bugs, bugs found in loading the plugins using this loader should not be reported to their according developers. - We will not hold any responsibiliy for any corruptions of server. Use it at your own risk. diff --git a/package-lock.json b/package-lock.json index ed7a4b6..d1dbcf5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@bdsx/bdsx-llse", - "version": "1.2.1", + "version": "1.2.2", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index de01cb1..ab316b4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bdsx/bdsx-llse", - "version": "1.2.1", + "version": "1.2.2", "description": "LiteLoader ScriptingEngine ported into BDSX", "main": "index.js", "keywords": [], diff --git a/src/api/block.ts b/src/api/block.ts index fb3a48f..cae2652 100644 --- a/src/api/block.ts +++ b/src/api/block.ts @@ -11,7 +11,7 @@ import { FloatPos, IntPos, IntPos$newPos } from "./base"; import { BlockEntity$newBlockEntity } from "./block_entity"; import { NbtCompound } from "./nbt"; -export class LXL_Block { +export class LLSE_Block { [PrivateFields]: Block; getRawPtr() { @@ -72,12 +72,12 @@ export class LXL_Block { } } -export function Block$newBlock(p: Block, pos: BlockPos, dim: number): LXL_Block; -export function Block$newBlock(p: Block, pos: BlockPos, bs: BlockSource): LXL_Block; -export function Block$newBlock(pos: BlockPos, dim: number): LXL_Block; +export function Block$newBlock(p: Block, pos: BlockPos, dim: number): LLSE_Block; +export function Block$newBlock(p: Block, pos: BlockPos, bs: BlockSource): LLSE_Block; +export function Block$newBlock(pos: BlockPos, dim: number): LLSE_Block; // export function Block$newBlock(pos: IntVec4): Block; -export function Block$newBlock(a0: any, a1: any, a2?: any): LXL_Block { - const newp = new LXL_Block(); +export function Block$newBlock(a0: any, a1: any, a2?: any): LLSE_Block { + const newp = new LLSE_Block(); let p: Block | undefined = undefined!; let pos: BlockPos | undefined = void 0; let dim: number | undefined = undefined!; @@ -103,8 +103,8 @@ export function Block$newBlock(a0: any, a1: any, a2?: any): LXL_Block { return newp; } -export function getBlock(pos: IntPos| FloatPos): LXL_Block; -export function getBlock(x: number, y: number, z: number, dimid: DimensionId): LXL_Block; +export function getBlock(pos: IntPos| FloatPos): LLSE_Block; +export function getBlock(x: number, y: number, z: number, dimid: DimensionId): LLSE_Block; export function getBlock(a0: any, a1?: any, a2?: any, a3?: any) { let pos: BlockPos; let dimId: DimensionId; @@ -118,12 +118,12 @@ export function getBlock(a0: any, a1?: any, a2?: any, a3?: any) { return Block$newBlock(pos, dimId); } -export function setBlock(pos: IntPos| FloatPos, block: LXL_Block | string | NbtCompound, tiledata?: number): boolean; -export function setBlock(x: number, y: number, z: number, dimid: DimensionId, block: LXL_Block | string | NbtCompound, tiledata: number): boolean; +export function setBlock(pos: IntPos| FloatPos, block: LLSE_Block | string | NbtCompound, tiledata?: number): boolean; +export function setBlock(x: number, y: number, z: number, dimid: DimensionId, block: LLSE_Block | string | NbtCompound, tiledata: number): boolean; export function setBlock(a0: any, a1: any, a2?: any, a3?: any, a4?: any, a5?: any) { let pos: BlockPos; let dimId: DimensionId; - let block: LXL_Block | string | NbtCompound; + let block: LLSE_Block | string | NbtCompound; let tileData = 0; if (a0 instanceof IntPos || a0 instanceof FloatPos) { if (typeof a2 === "number") { @@ -146,7 +146,7 @@ export function setBlock(a0: any, a1: any, a2?: any, a3?: any, a4?: any, a5?: an if (!newBlock) { return false; } - } else if (block instanceof LXL_Block) { + } else if (block instanceof LLSE_Block) { newBlock = block[PrivateFields]; } else if (block instanceof NbtCompound) { newBlock = Block.create("minecraft:stone")!; diff --git a/src/api/block_entity.ts b/src/api/block_entity.ts index a24a0ea..08eaa3b 100644 --- a/src/api/block_entity.ts +++ b/src/api/block_entity.ts @@ -5,7 +5,7 @@ import { IntPos, IntPos$newPos } from "./base"; import { Block$newBlock } from "./block"; import { NbtCompound } from "./nbt"; -export class LXL_BlockEntity { +export class LLSE_BlockEntity { [PrivateFields]: BlockActor; getRawPtr() { @@ -31,8 +31,8 @@ export class LXL_BlockEntity { } } -export function BlockEntity$newBlockEntity(be: BlockActor, dim: DimensionId): LXL_BlockEntity { - const newp = new LXL_BlockEntity(); +export function BlockEntity$newBlockEntity(be: BlockActor, dim: DimensionId): LLSE_BlockEntity { + const newp = new LLSE_BlockEntity(); newp[PrivateFields] = be; Object.defineProperty(newp, "type", { value: be.getType() }); Object.defineProperty(newp, "pos", { value: IntPos$newPos(be.getPosition(), dim) }); diff --git a/src/api/command.ts b/src/api/command.ts index f59a790..55bc875 100644 --- a/src/api/command.ts +++ b/src/api/command.ts @@ -4,7 +4,7 @@ import { BlockPos } from "bdsx/bds/blockpos"; import { ActorCommandSelector, Command, CommandItem, CommandMessage, CommandOutput, CommandPermissionLevel, CommandPosition, CommandPositionFloat, CommandRawEnum, CommandRawText, PlayerCommandSelector, SoftEnumUpdateType } from "bdsx/bds/command"; import { CommandOrigin, CommandOriginType, ServerCommandOrigin } from "bdsx/bds/commandorigin"; import { JsonValue } from "bdsx/bds/connreq"; -import { MobEffectInstance } from "bdsx/bds/effects"; +import { MobEffect } from "bdsx/bds/effects"; import { ServerPlayer } from "bdsx/bds/player"; import { command } from "bdsx/command"; import { CommandParameterType } from "bdsx/commandparam"; @@ -14,14 +14,15 @@ import { bedrockServer } from "bdsx/launcher"; import { bool_t, CxxString, float32_t, int32_t } from "bdsx/nativetype"; import { _tickCallback } from "bdsx/util"; import { IsInDebugMode, LockDebugModeForOnce } from "../debug"; +import { MCAPI } from "../dep/native"; import { logger, PrivateFields } from "./api_help"; import { FloatPos$newPos, IntPos$newPos } from "./base"; import { Block$newBlock } from "./block"; import { Entity$newEntity } from "./entity"; -import { LXL_Events } from "./event"; +import { LLSE_Events } from "./event"; import { Item$newItem } from "./item"; import { NbtCompound } from "./nbt"; -import { LXL_Player, Player$newPlayer } from "./player"; +import { LLSE_Player, Player$newPlayer } from "./player"; export const OriginType = { Player: 0, @@ -240,8 +241,8 @@ function convertResults(value: any, origin: CommandOrigin) { if (value instanceof Block) { return Block$newBlock(value, BlockPos.create(0,0,0), -1); } - if (value instanceof MobEffectInstance) { - return value.getComponentName(); + if (value instanceof MobEffect) { + return MCAPI.MobEffect.getResourceName(value); } if (value instanceof ActorDefinitionIdentifier) { return value.canonicalName.str; @@ -511,7 +512,7 @@ export function runcmdEx(cmd: string): { success: boolean, output: string } { } } -const playerCmdCallbacks = new Map void>(); +const playerCmdCallbacks = new Map void>(); const consoleCmdCallbacks = new Map void>(); function LxlRegisterNewCmd(isPlayerCmd: boolean, cmd: string, description: string, level: number, func: Function) { @@ -569,7 +570,7 @@ events.command.on((cmd, _, ctx) => { } const player = ctx.origin.getEntity(); if (player?.isPlayer()) { - const cancelled = LXL_Events.onPlayerCmd.fire(Player$newPlayer(player), cmd); + const cancelled = LLSE_Events.onPlayerCmd.fire(Player$newPlayer(player), cmd); _tickCallback(); if (cancelled) { return 0; @@ -600,7 +601,7 @@ events.command.on((cmd, _, ctx) => { return 0; } } else { - const cancelled = LXL_Events.onConsoleCmd.fire(cmd); + const cancelled = LLSE_Events.onConsoleCmd.fire(cmd); _tickCallback(); if (cancelled) { return 0; @@ -635,7 +636,7 @@ events.command.on((cmd, _, ctx) => { }); /** @deprecated */ -export function regPlayerCmd(cmd: string, description: string, callback: (player: LXL_Player, args: string[]) => void, level: number = 0) { +export function regPlayerCmd(cmd: string, description: string, callback: (player: LLSE_Player, args: string[]) => void, level: number = 0) { return LxlRegisterNewCmd(true, cmd, description, level, callback); } diff --git a/src/api/container.ts b/src/api/container.ts index 0e09643..e2c22f1 100644 --- a/src/api/container.ts +++ b/src/api/container.ts @@ -1,9 +1,9 @@ import { Container as _Container } from "bdsx/bds/inventory"; import { LlAPI } from "../dep/native"; import { logger, PrivateFields } from "./api_help"; -import { Item$newItem, LXL_Item } from "./item"; +import { Item$newItem, LLSE_Item } from "./item"; -export class LXL_Container { +export class LLSE_Container { private [PrivateFields]: _Container; getRawPtr() { @@ -18,7 +18,7 @@ export class LXL_Container { return LlAPI.Container.getTypeName(this[PrivateFields]); } - addItem(item: LXL_Item) { + addItem(item: LLSE_Item) { if (!item[PrivateFields]) { logger.error("Wrong type of argument in addItem!"); return null; @@ -26,7 +26,7 @@ export class LXL_Container { return LlAPI.Container.addItemSafe(this[PrivateFields], item[PrivateFields]); } - addItemToFirstEmptySlot(item: LXL_Item) { + addItemToFirstEmptySlot(item: LLSE_Item) { if (!item[PrivateFields]) { logger.error("Wrong type of argument in addItemToFirstEmptySlot!"); return null; @@ -34,7 +34,7 @@ export class LXL_Container { return LlAPI.Container.addItemToFirstEmptySlotSafe(this[PrivateFields], item[PrivateFields]); } - hasRoomFor(item: LXL_Item) { + hasRoomFor(item: LLSE_Item) { if (!item[PrivateFields]) { logger.error("Wrong type of argument in hasRoomFor!"); return null; @@ -55,7 +55,7 @@ export class LXL_Container { return Item$newItem(item); } - setItem(index: number, item: LXL_Item) { + setItem(index: number, item: LLSE_Item) { if (!item[PrivateFields]) { logger.error("Wrong type of argument in setItem!"); return null; @@ -94,8 +94,8 @@ export class LXL_Container { getAllSlots = this.getAllItems; } -export function Container$newContainer(p: _Container): LXL_Container { - const newp = new LXL_Container(); +export function Container$newContainer(p: _Container): LLSE_Container { + const newp = new LLSE_Container(); newp[PrivateFields] = p; return newp; } \ No newline at end of file diff --git a/src/api/device.ts b/src/api/device.ts index ca122d8..0849df1 100644 --- a/src/api/device.ts +++ b/src/api/device.ts @@ -2,7 +2,7 @@ import { ServerPlayer as _ServerPlayer } from "bdsx/bds/player"; import { LlAPI } from "../dep/native"; import { PrivateFields } from "./api_help"; -export class LXL_Device { +export class LLSE_Device { [PrivateFields]: _ServerPlayer; get ip() { @@ -26,8 +26,8 @@ export class LXL_Device { } } -export function Device$newDevice(p: _ServerPlayer): LXL_Device { - const newp = new LXL_Device(); +export function Device$newDevice(p: _ServerPlayer): LLSE_Device { + const newp = new LLSE_Device(); newp[PrivateFields] = p; return newp; } \ No newline at end of file diff --git a/src/api/entity.ts b/src/api/entity.ts index 1c9c806..79ecb54 100644 --- a/src/api/entity.ts +++ b/src/api/entity.ts @@ -13,7 +13,7 @@ import { Item$newItem } from "./item"; import { NbtCompound } from "./nbt"; import { Player$newPlayer } from "./player"; -export class LXL_Entity { +export class LLSE_Entity { private [PrivateFields]?: Actor; getRawPtr() { @@ -335,22 +335,22 @@ export class LXL_Entity { getTag = this.getNbt; } -export function Entity$newEntity(p: Actor): LXL_Entity { - const newp = new LXL_Entity(); +export function Entity$newEntity(p: Actor): LLSE_Entity { + const newp = new LLSE_Entity(); newp[PrivateFields] = p; return newp; } export function getAllEntities() { const entityList = bedrockServer.level.getEntities(); - const arr = new Array(); + const arr = new Array(); for (const i of entityList) { arr.push(Entity$newEntity(i)); } return arr; } -export function spawnMob(name: string, pos: IntPos | FloatPos): LXL_Entity; -export function spawnMob(name: string, x: number, y: number, z: number, dimid: DimensionId): LXL_Entity; +export function spawnMob(name: string, pos: IntPos | FloatPos): LLSE_Entity; +export function spawnMob(name: string, x: number, y: number, z: number, dimid: DimensionId): LLSE_Entity; export function spawnMob(name: string, a1: any, a2?: any, a3?: any, a4?: any) { let pos: Vec3; let dimId: DimensionId; @@ -372,12 +372,12 @@ export function spawnMob(name: string, a1: any, a2?: any, a3?: any, a4?: any) { } -export function explode(pos: IntPos | FloatPos, source: LXL_Entity | null, power: number, range: number, isDestroy: number, isFire: number): boolean; -export function explode(x: number, y: number, z: number, dimid: DimensionId, source: LXL_Entity | null, power: number, range: number, isDestroy: number, isFire: number): boolean; +export function explode(pos: IntPos | FloatPos, source: LLSE_Entity | null, power: number, range: number, isDestroy: number, isFire: number): boolean; +export function explode(x: number, y: number, z: number, dimid: DimensionId, source: LLSE_Entity | null, power: number, range: number, isDestroy: number, isFire: number): boolean; export function explode(a0: any, a1?: any, a2?: any, a3?: any, a4?: any, a5?: any, a6?: any, a7?: any, a8?: any) { let pos: Vec3; let dimId: DimensionId; - let source: LXL_Entity | null, + let source: LLSE_Entity | null, power: number, range: number, isDestroy: boolean, diff --git a/src/api/event.ts b/src/api/event.ts index d77de22..e807067 100644 --- a/src/api/event.ts +++ b/src/api/event.ts @@ -1,4 +1,4 @@ -import { Actor, ActorDamageCause, ActorDamageSource, ActorDefinitionIdentifier, ActorFlags, ActorUniqueID } from "bdsx/bds/actor"; +import { Actor, ActorDamageCause, ActorDamageSource, ActorDefinitionIdentifier, ActorFlags, ActorUniqueID, Mob } from "bdsx/bds/actor"; import { AttributeId } from "bdsx/bds/attribute"; import { Block, BlockActor, BlockLegacy, BlockSource } from "bdsx/bds/block"; import { BlockPos, Vec3 } from "bdsx/bds/blockpos"; @@ -26,12 +26,12 @@ import { _tickCallback } from "bdsx/util"; import { daccess, LlAPI, MCAPI, symhook } from "../dep/native"; import { logger } from "./api_help"; import { FloatPos, FloatPos$newPos, IntPos, IntPos$newPos } from "./base"; -import { Block$newBlock, LXL_Block } from "./block"; -import { Entity$newEntity, LXL_Entity } from "./entity"; -import { Item$newItem, LXL_Item } from "./item"; -import { LXL_Player, Player$newPlayer } from "./player"; +import { Block$newBlock, LLSE_Block } from "./block"; +import { Entity$newEntity, LLSE_Entity } from "./entity"; +import { Item$newItem, LLSE_Item } from "./item"; +import { LLSE_Player, Player$newPlayer } from "./player"; -class LXL_Event void | false> { +class LLSE_Event void | false> { name!: string; listeners: CB[] = []; @@ -54,116 +54,108 @@ class LXL_Event void | false> { } } -export const LXL_Events = { - /** Valid 03-02-2022 19:21:40 */ - onPreJoin: new LXL_Event<(player: LXL_Player) => void | false>(), - /** Valid 03-02-2022 19:21:45 */ - onJoin: new LXL_Event<(player: LXL_Player) => void>(), - /** Valid 03-02-2022 19:21:53 */ - onLeft: new LXL_Event<(player: LXL_Player) => void>(), - /** Valid 03-02-2022 19:22:14 */ - onRespawn: new LXL_Event<(player: LXL_Player) => void>(), - /** Valid 03-02-2022 19:22:08 */ - onChat: new LXL_Event<(player: LXL_Player, msg: string) => void | false>(), - /** Valid 03-02-2022 19:22:27 */ - onChangeDim: new LXL_Event<(player: LXL_Player, dimid: number) => void>(), - /** Valid 03-02-2022 19:22:22 */ - onJump: new LXL_Event<(player: LXL_Player) => void>(), - onEntityTransformation: new LXL_Event<(uniqueId: string, entity: LXL_Entity) => void>(), - onSneak: new LXL_Event<(player: LXL_Player, isSneaking: boolean) => void>(), - onAttackEntity: new LXL_Event<(player: LXL_Player, entity: LXL_Entity) => void | false>(), - onAttackBlock: new LXL_Event<(player: LXL_Player, block: LXL_Block, item: LXL_Item | null) => void | false>(), - onTakeItem: new LXL_Event<(player: LXL_Player, entity: LXL_Entity, item: LXL_Item | null) => void | false>(), - onDropItem: new LXL_Event<(player: LXL_Player, item: LXL_Item) => void | false>(), - onEat: new LXL_Event<(player: LXL_Player, item: LXL_Item) => void | false>(), - onConsumeTotem: new LXL_Event<(player: LXL_Player) => void | false>(), - onEffectAdded: new LXL_Event<(player: LXL_Player, effectName: string) => void | false>(), - onEffectRemoved: new LXL_Event<(player: LXL_Player, effectName: string) => void | false>(), - onEffectUpdated: new LXL_Event<(player: LXL_Player, effectName: string) => void | false>(), - onStartDestroyBlock: new LXL_Event<(player: LXL_Player, block: LXL_Block) => void>(), - onPlaceBlock: new LXL_Event<(player: LXL_Player, block: LXL_Block) => void | false>(), - /** Valid 03-02-2022 19:21:02 */ - onOpenContainer: new LXL_Event<(player: LXL_Player, block: LXL_Block) => void | false>(), - onCloseContainer: new LXL_Event<(player: LXL_Player, block: LXL_Block) => void>(), - onInventoryChange: new LXL_Event<(player: LXL_Player, slotNum: number, oldItem: LXL_Item, newItem: LXL_Item) => void>(), - /** Valid 03-02-2022 19:21:18 */ - onMove: new LXL_Event<(player: LXL_Player, pos: FloatPos) => void>(), - onChangeSprinting: new LXL_Event<(player: LXL_Player, sprinting: boolean) => void>(), - onSetArmor: new LXL_Event<(player: LXL_Player, slotNum: number, item: LXL_Item) => void>(), - onUseRespawnAnchor: new LXL_Event<(player: LXL_Player, pos: IntPos) => void | false>(), - onOpenContainerScreen: new LXL_Event<(player: LXL_Player) => void | false>(), - /** Valid 03-02-2022 19:22:45 */ - onPlayerCmd: new LXL_Event<(player: LXL_Player, cmd: string) => void | false>(), - /** Valid 03-02-2022 19:22:50 */ - onConsoleCmd: new LXL_Event<(cmd: string) => void | false>(), - /** Valid 06-02-2022 14:24:59 */ - onCmdBlockExecute: new LXL_Event<(cmd: string, pos: IntPos, isMinecart: boolean) => void | false>(), - onBlockInteracted: new LXL_Event<(player: LXL_Player, block: LXL_Block) => void | false>(), - onBlockChanged: new LXL_Event<(beforeBlock: LXL_Block, afterBlock: LXL_Block) => void | false>(), - onBlockExploded: new LXL_Event<(block: LXL_Block, source: LXL_Entity) => void>(), - onFireSpread: new LXL_Event<(pos: IntPos) => void | false>(), - onContainerChange: new LXL_Event<(player: LXL_Player, container: LXL_Block, slotNum: number, oldItem: LXL_Item, newItem: LXL_Item) => void>(), - onProjectileHitBlock: new LXL_Event<(block: LXL_Block, source: LXL_Entity) => void>(), - onRedStoneUpdate: new LXL_Event<(block: LXL_Block, level: number, isActive: boolean) => void | false>(), - onHopperSearchItem: new LXL_Event<(pos: FloatPos, isMinecart: boolean) => void | false>(), - onHopperPushOut: new LXL_Event<(pos: FloatPos) => void | false>(), - onPistonTryPush: new LXL_Event<(pistonPos: IntPos, block: LXL_Block) => void | false>(), - onPistonPush: new LXL_Event<(pistonPos: IntPos, block: LXL_Block) => void>(), - /** Valid 03-02-2022 19:24:55 */ - onFarmLandDecay: new LXL_Event<(pos: IntPos, entity: LXL_Entity) => void | false>(), - onUseFrameBlock: new LXL_Event<(player: LXL_Player, block: LXL_Block) => void | false>(), - onLiquidFlow: new LXL_Event<(from: LXL_Block, to: IntPos) => void | false>(), - onPlayerDie: new LXL_Event<(player: LXL_Player, source: LXL_Entity | null) => void>(), - onDestroyBlock: new LXL_Event<(player: LXL_Player, block: LXL_Block) => void | false>(), - onUseItemOn: new LXL_Event<(player: LXL_Player, item: LXL_Item, block: LXL_Block, side: number) => void | false>(), - onMobHurt: new LXL_Event<(mob: LXL_Entity, source: LXL_Entity | null, damage: number) => void | false>(), - onUseItem: new LXL_Event<(player: LXL_Player, item: LXL_Item) => void | false>(), - onMobDie: new LXL_Event<(mob: LXL_Entity, source: LXL_Entity | null) => void>(), - onEntityExplode: new LXL_Event<(source: LXL_Entity, pos: FloatPos, radius: number, maxResistance: number, isDestroy: boolean, isFire: boolean) => void | false>(), - onBlockExplode: new LXL_Event<(source: LXL_Block, pos: IntPos, radius: number, maxResistance: number, isDestroy: boolean, isFire: boolean) => void | false>(), - /** Valid 03-02-2022 18:54:11 */ - onProjectileHitEntity: new LXL_Event<(entity: LXL_Entity, source: LXL_Entity) => void>(), - onWitherBossDestroy: new LXL_Event<(witherBoss: LXL_Entity, AAbb: IntPos, aaBB: IntPos) => void | false>(), - onRide: new LXL_Event<(entity1: LXL_Entity, entity2: LXL_Entity) => void | false>(), - onStepOnPressurePlate: new LXL_Event<(entity: LXL_Entity, pressurePlate: LXL_Block) => void | false>(), - onSpawnProjectile: new LXL_Event<(shooter: LXL_Entity, type: string) => void | false>(), - onProjectileCreated: new LXL_Event<(shooter: LXL_Entity, entity: LXL_Entity) => void>(), - onNpcCmd: new LXL_Event<(npc: LXL_Entity, pl: LXL_Player, cmd: string) => void | false>(), - /** Valid 06-02-2022 14:37:44 */ - onChangeArmorStand: new LXL_Event<(as: LXL_Entity, pl: LXL_Player, slot: number) => void | false>(), - onScoreChanged: new LXL_Event<(player: LXL_Player, num: number, name: string, disName: string) => void>(), - /** 03-02-2022 19:23:42 */ - onServerStarted: new LXL_Event<() => void>(), - /** 03-02-2022 19:23:49 */ - onConsoleOutput: new LXL_Event<(cmd: string) => void | false>(), - /** Valid 03-02-2022 19:21:26 */ - onTick: new LXL_Event<() => void>(), - - onMoneyAdd: new LXL_Event<(xuid: string, money: number) => void | false>(), - onMoneyReduce: new LXL_Event<(xuid: string, money: number) => void | false>(), - onMoneyTrans: new LXL_Event<(from: string, to: string, money: number) => void | false>(), - onMoneySet: new LXL_Event<(xuid: string, money: number) => void | false>(), - - onFireworkShootWithCrossbow: new LXL_Event<(player: LXL_Player) => void | false>(), - onRespawnAnchorExplode: new LXL_Event<(pos: IntPos) => void | false>(), - onBedExplode: new LXL_Event<(pos: IntPos) => void | false>(), +export const LLSE_Events = { + /** Valid 30-04-2022 13:14:21 */ + onPreJoin: new LLSE_Event<(player: LLSE_Player) => void | false>(), + /** Valid 30-04-2022 13:14:37 */ + onJoin: new LLSE_Event<(player: LLSE_Player) => void>(), + onLeft: new LLSE_Event<(player: LLSE_Player) => void>(), + onRespawn: new LLSE_Event<(player: LLSE_Player) => void>(), + onChat: new LLSE_Event<(player: LLSE_Player, msg: string) => void | false>(), + onChangeDim: new LLSE_Event<(player: LLSE_Player, dimid: number) => void>(), + onJump: new LLSE_Event<(player: LLSE_Player) => void>(), + onEntityTransformation: new LLSE_Event<(uniqueId: string, entity: LLSE_Entity) => void>(), + onSneak: new LLSE_Event<(player: LLSE_Player, isSneaking: boolean) => void>(), + onAttackEntity: new LLSE_Event<(player: LLSE_Player, entity: LLSE_Entity) => void | false>(), + onAttackBlock: new LLSE_Event<(player: LLSE_Player, block: LLSE_Block, item: LLSE_Item | null) => void | false>(), + /** Always valid */ + onTakeItem: new LLSE_Event<(player: LLSE_Player, entity: LLSE_Entity, item: LLSE_Item | null) => void | false>(), + /** Always valid */ + onDropItem: new LLSE_Event<(player: LLSE_Player, item: LLSE_Item) => void | false>(), + onEat: new LLSE_Event<(player: LLSE_Player, item: LLSE_Item) => void | false>(), + onConsumeTotem: new LLSE_Event<(player: LLSE_Player) => void | false>(), + onEffectAdded: new LLSE_Event<(player: LLSE_Player, effectName: string) => void | false>(), + onEffectRemoved: new LLSE_Event<(player: LLSE_Player, effectName: string) => void | false>(), + onEffectUpdated: new LLSE_Event<(player: LLSE_Player, effectName: string) => void | false>(), + onStartDestroyBlock: new LLSE_Event<(player: LLSE_Player, block: LLSE_Block) => void>(), + onPlaceBlock: new LLSE_Event<(player: LLSE_Player, block: LLSE_Block) => void | false>(), + onOpenContainer: new LLSE_Event<(player: LLSE_Player, block: LLSE_Block) => void | false>(), + onCloseContainer: new LLSE_Event<(player: LLSE_Player, block: LLSE_Block) => void>(), + onInventoryChange: new LLSE_Event<(player: LLSE_Player, slotNum: number, oldItem: LLSE_Item, newItem: LLSE_Item) => void>(), + onMove: new LLSE_Event<(player: LLSE_Player, pos: FloatPos) => void>(), + onChangeSprinting: new LLSE_Event<(player: LLSE_Player, sprinting: boolean) => void>(), + onSetArmor: new LLSE_Event<(player: LLSE_Player, slotNum: number, item: LLSE_Item) => void>(), + onUseRespawnAnchor: new LLSE_Event<(player: LLSE_Player, pos: IntPos) => void | false>(), + onOpenContainerScreen: new LLSE_Event<(player: LLSE_Player) => void | false>(), + onPlayerCmd: new LLSE_Event<(player: LLSE_Player, cmd: string) => void | false>(), + onConsoleCmd: new LLSE_Event<(cmd: string) => void | false>(), + onCmdBlockExecute: new LLSE_Event<(cmd: string, pos: IntPos, isMinecart: boolean) => void | false>(), + onBlockInteracted: new LLSE_Event<(player: LLSE_Player, block: LLSE_Block) => void | false>(), + onBlockChanged: new LLSE_Event<(beforeBlock: LLSE_Block, afterBlock: LLSE_Block) => void | false>(), + onBlockExploded: new LLSE_Event<(block: LLSE_Block, source: LLSE_Entity) => void>(), + onFireSpread: new LLSE_Event<(pos: IntPos) => void | false>(), + onContainerChange: new LLSE_Event<(player: LLSE_Player, container: LLSE_Block, slotNum: number, oldItem: LLSE_Item, newItem: LLSE_Item) => void>(), + onProjectileHitBlock: new LLSE_Event<(block: LLSE_Block, source: LLSE_Entity) => void>(), + onRedStoneUpdate: new LLSE_Event<(block: LLSE_Block, level: number, isActive: boolean) => void | false>(), + onHopperSearchItem: new LLSE_Event<(pos: FloatPos, isMinecart: boolean) => void | false>(), + onHopperPushOut: new LLSE_Event<(pos: FloatPos) => void | false>(), + onPistonTryPush: new LLSE_Event<(pistonPos: IntPos, block: LLSE_Block) => void | false>(), + onPistonPush: new LLSE_Event<(pistonPos: IntPos, block: LLSE_Block) => void>(), + /** Always valid */ + onFarmLandDecay: new LLSE_Event<(pos: IntPos, entity: LLSE_Entity) => void | false>(), + onUseFrameBlock: new LLSE_Event<(player: LLSE_Player, block: LLSE_Block) => void | false>(), + onLiquidFlow: new LLSE_Event<(from: LLSE_Block, to: IntPos) => void | false>(), + onPlayerDie: new LLSE_Event<(player: LLSE_Player, source: LLSE_Entity | null) => void>(), + onDestroyBlock: new LLSE_Event<(player: LLSE_Player, block: LLSE_Block) => void | false>(), + onUseItemOn: new LLSE_Event<(player: LLSE_Player, item: LLSE_Item, block: LLSE_Block, side: number) => void | false>(), + onMobHurt: new LLSE_Event<(mob: LLSE_Entity, source: LLSE_Entity | null, damage: number, cause: number) => void | false>(), + onUseItem: new LLSE_Event<(player: LLSE_Player, item: LLSE_Item) => void | false>(), + /** Always valid */ + onMobDie: new LLSE_Event<(mob: LLSE_Entity, source: LLSE_Entity | null, cause: number) => void>(), + onEntityExplode: new LLSE_Event<(source: LLSE_Entity, pos: FloatPos, radius: number, maxResistance: number, isDestroy: boolean, isFire: boolean) => void | false>(), + onBlockExplode: new LLSE_Event<(source: LLSE_Block, pos: IntPos, radius: number, maxResistance: number, isDestroy: boolean, isFire: boolean) => void | false>(), + onProjectileHitEntity: new LLSE_Event<(entity: LLSE_Entity, source: LLSE_Entity) => void>(), + onWitherBossDestroy: new LLSE_Event<(witherBoss: LLSE_Entity, AAbb: IntPos, aaBB: IntPos) => void | false>(), + onRide: new LLSE_Event<(entity1: LLSE_Entity, entity2: LLSE_Entity) => void | false>(), + onStepOnPressurePlate: new LLSE_Event<(entity: LLSE_Entity, pressurePlate: LLSE_Block) => void | false>(), + onSpawnProjectile: new LLSE_Event<(shooter: LLSE_Entity, type: string) => void | false>(), + onProjectileCreated: new LLSE_Event<(shooter: LLSE_Entity, entity: LLSE_Entity) => void>(), + onNpcCmd: new LLSE_Event<(npc: LLSE_Entity, pl: LLSE_Player, cmd: string) => void | false>(), + onChangeArmorStand: new LLSE_Event<(as: LLSE_Entity, pl: LLSE_Player, slot: number) => void | false>(), + onScoreChanged: new LLSE_Event<(player: LLSE_Player, num: number, name: string, disName: string) => void>(), + /** Always valid */ + onServerStarted: new LLSE_Event<() => void>(), + /** Always valid */ + onConsoleOutput: new LLSE_Event<(cmd: string) => void | false>(), + onMobSpawn: new LLSE_Event<(typeName: string, pos: FloatPos) => void | false>(), + /** Always valid */ + onTick: new LLSE_Event<() => void>(), + + onMoneyAdd: new LLSE_Event<(xuid: string, money: number) => void | false>(), + onMoneyReduce: new LLSE_Event<(xuid: string, money: number) => void | false>(), + onMoneyTrans: new LLSE_Event<(from: string, to: string, money: number) => void | false>(), + onMoneySet: new LLSE_Event<(xuid: string, money: number) => void | false>(), + + onFireworkShootWithCrossbow: new LLSE_Event<(player: LLSE_Player) => void | false>(), + onRespawnAnchorExplode: new LLSE_Event<(pos: IntPos) => void | false>(), + onBedExplode: new LLSE_Event<(pos: IntPos) => void | false>(), }; -(LXL_Events as any).onAttack = LXL_Events.onAttackEntity; -(LXL_Events as any).onExplode = LXL_Events.onEntityExplode; -(LXL_Events as any).onFormSelected = new LXL_Event(); +(LLSE_Events as any).onAttack = LLSE_Events.onAttackEntity; +(LLSE_Events as any).onExplode = LLSE_Events.onEntityExplode; +(LLSE_Events as any).onFormSelected = new LLSE_Event(); -export function listen(event: E, callback: (typeof LXL_Events[E])["listeners"][number]) { - if (!LXL_Events[event]) { +export function listen(event: E, callback: (typeof LLSE_Events[E])["listeners"][number]) { + if (!LLSE_Events[event]) { logger.warn(`Event ${event} not found`); return; } - LXL_Events[event].listeners.push(callback as any); - LXL_Events[event].name ??= event; + LLSE_Events[event].listeners.push(callback as any); + LLSE_Events[event].name ??= event; } -export function unlisten(event: E, callback: (typeof LXL_Events[E])["listeners"][number]) { - const index = LXL_Events[event].listeners.findIndex(cb => cb.toString() === callback.toString()); - index !== -1 && LXL_Events[event].listeners.splice(index, 1); +export function unlisten(event: E, callback: (typeof LLSE_Events[E])["listeners"][number]) { + const index = LLSE_Events[event].listeners.findIndex(cb => cb.toString() === callback.toString()); + index !== -1 && LLSE_Events[event].listeners.splice(index, 1); } /////////////////// PreJoin /////////////////// @@ -171,7 +163,7 @@ export function unlisten(event: E, callback: const original = symhook("?sendLoginMessageLocal@ServerNetworkHandler@@QEAAXAEBVNetworkIdentifier@@AEBVConnectionRequest@@AEAVServerPlayer@@@Z", void_t, null, ServerNetworkHandler, NetworkIdentifier, ConnectionRequest, ServerPlayer) ((thiz, source, connectionRequest, player) => { - const cancelled = LXL_Events.onPreJoin.fire(Player$newPlayer(player)); + const cancelled = LLSE_Events.onPreJoin.fire(Player$newPlayer(player)); _tickCallback(); if (cancelled) { return; @@ -185,7 +177,7 @@ export function unlisten(event: E, callback: const original = symhook("?setLocalPlayerAsInitialized@ServerPlayer@@QEAAXXZ", bool_t, null, ServerPlayer) ((thiz) => { - const cancelled = LXL_Events.onJoin.fire(Player$newPlayer(thiz)); + const cancelled = LLSE_Events.onJoin.fire(Player$newPlayer(thiz)); _tickCallback(); if (cancelled) { return false; @@ -199,7 +191,7 @@ export function unlisten(event: E, callback: const original = symhook("?_onPlayerLeft@ServerNetworkHandler@@AEAAXPEAVServerPlayer@@_N@Z", void_t, null, ServerNetworkHandler, ServerPlayer, bool_t) ((thiz, player, skipMessage) => { - const cancelled = LXL_Events.onLeft.fire(Player$newPlayer(player)); + const cancelled = LLSE_Events.onLeft.fire(Player$newPlayer(player)); _tickCallback(); return original(thiz, player, skipMessage); }); @@ -209,7 +201,7 @@ export function unlisten(event: E, callback: { events.packetSend(MinecraftPacketIds.PlayerAction).on((pk, ni) => { if (pk.action === PlayerActionPacket.Actions.Respawn) { - LXL_Events.onRespawn.fire(Player$newPlayer(ni.getActor()!)); + LLSE_Events.onRespawn.fire(Player$newPlayer(ni.getActor()!)); _tickCallback(); } }); @@ -220,7 +212,7 @@ export function unlisten(event: E, callback: const original = symhook("?handle@ServerNetworkHandler@@UEAAXAEBVNetworkIdentifier@@AEBVTextPacket@@@Z", void_t, null, ServerNetworkHandler, NetworkIdentifier.ref(), TextPacket.ref()) ((thiz, source, packet) => { - const cancelled = LXL_Events.onChat.fire(Player$newPlayer(source.getActor()!), packet.message); + const cancelled = LLSE_Events.onChat.fire(Player$newPlayer(source.getActor()!), packet.message); _tickCallback(); if (cancelled) { return; @@ -238,7 +230,7 @@ export function unlisten(event: E, callback: if (toDimID === player.getDimensionId()) { return original(thiz, player, changeRequest); } - const cancelled = LXL_Events.onChangeDim.fire(Player$newPlayer(player), toDimID); + const cancelled = LLSE_Events.onChangeDim.fire(Player$newPlayer(player), toDimID); _tickCallback(); if (cancelled) { return false; @@ -252,7 +244,7 @@ export function unlisten(event: E, callback: const original = symhook("?jumpFromGround@Player@@UEAAXXZ", void_t, null, Player) ((thiz) => { - const cancelled = LXL_Events.onJump.fire(Player$newPlayer(thiz)); + const cancelled = LLSE_Events.onJump.fire(Player$newPlayer(thiz)); _tickCallback(); return original(thiz); }); @@ -263,7 +255,7 @@ export function unlisten(event: E, callback: const original = symhook("?maintainOldData@TransformationComponent@@QEAAXAEAVActor@@0AEBUTransformationDescription@@AEBUActorUniqueID@@AEBVLevel@@@Z", void_t, null, StaticPointer, Actor, Actor, StaticPointer, ActorUniqueID.ref(), Level) ((thiz, originalActor, transformed, transformation, ownerID, level) => { - const cancelled = LXL_Events.onEntityTransformation.fire(bin.toString(originalActor.getUniqueIdBin()), Entity$newEntity(transformed)); + const cancelled = LLSE_Events.onEntityTransformation.fire(bin.toString(originalActor.getUniqueIdBin()), Entity$newEntity(transformed)); _tickCallback(); return original(thiz, originalActor, transformed, transformation, ownerID, level); }); @@ -275,7 +267,7 @@ export function unlisten(event: E, callback: const original = symhook("?sendActorSneakChanged@ActorEventCoordinator@@QEAAXAEAVActor@@_N@Z", void_t, null, StaticPointer, Actor, bool_t) ((thiz, actor, isSneaking) => { - const cancelled = LXL_Events.onSneak.fire(Player$newPlayer(actor), isSneaking); + const cancelled = LLSE_Events.onSneak.fire(Player$newPlayer(actor), isSneaking); _tickCallback(); return original(thiz, actor, isSneaking); }); @@ -287,7 +279,7 @@ export function unlisten(event: E, callback: bool_t, null, Player, Actor, Wrapper.make(int32_t)) ((thiz, actor, cause: Wrapper) => { if (actor) { - const cancelled = LXL_Events.onAttackEntity.fire(Player$newPlayer(thiz), Entity$newEntity(actor)); + const cancelled = LLSE_Events.onAttackEntity.fire(Player$newPlayer(thiz), Entity$newEntity(actor)); _tickCallback(); if (cancelled) { return false; @@ -303,7 +295,7 @@ export function unlisten(event: E, callback: bool_t, null, Block, Player, BlockPos) ((thiz, player, pos) => { const itemStack = player.getMainhandSlot(); - const cancelled = LXL_Events.onAttackBlock.fire(Player$newPlayer(player), Block$newBlock(thiz, pos, player.getDimensionId()), !itemStack.isNull() ? Item$newItem(itemStack) : null); + const cancelled = LLSE_Events.onAttackBlock.fire(Player$newPlayer(player), Block$newBlock(thiz, pos, player.getDimensionId()), !itemStack.isNull() ? Item$newItem(itemStack) : null); _tickCallback(); if (cancelled) { return false; @@ -314,7 +306,7 @@ export function unlisten(event: E, callback: /////////////////// PlayerTakeItem /////////////////// events.playerPickupItem.on(event => { - const cancelled = LXL_Events.onTakeItem.fire(Player$newPlayer(event.player), Entity$newEntity(event.itemActor), event.itemActor.itemStack ? Item$newItem(event.itemActor.itemStack) : null); + const cancelled = LLSE_Events.onTakeItem.fire(Player$newPlayer(event.player), Entity$newEntity(event.itemActor), event.itemActor.itemStack ? Item$newItem(event.itemActor.itemStack) : null); _tickCallback(); if (cancelled) { return CANCEL; @@ -323,7 +315,7 @@ events.playerPickupItem.on(event => { /////////////////// PlayerDropItem /////////////////// events.playerDropItem.on(event => { - const cancelled = LXL_Events.onDropItem.fire(Player$newPlayer(event.player), Item$newItem(event.itemStack)); + const cancelled = LLSE_Events.onDropItem.fire(Player$newPlayer(event.player), Item$newItem(event.itemStack)); _tickCallback(); if (cancelled) { return CANCEL; @@ -335,7 +327,7 @@ events.playerDropItem.on(event => { const original = symhook("?consumeTotem@Player@@UEAA_NXZ", bool_t, null, Player) ((thiz) => { - const cancelled = LXL_Events.onConsumeTotem.fire(Player$newPlayer(thiz)); + const cancelled = LLSE_Events.onConsumeTotem.fire(Player$newPlayer(thiz)); _tickCallback(); if (cancelled) { return false; @@ -350,7 +342,7 @@ events.playerDropItem.on(event => { const original = symhook("?onEffectAdded@ServerPlayer@@MEAAXAEAVMobEffectInstance@@@Z", bool_t, null, ServerPlayer, MobEffectInstance) ((thiz, effect) => { - const cancelled = LXL_Events.onEffectAdded.fire(Player$newPlayer(thiz), effect.getComponentName()); + const cancelled = LLSE_Events.onEffectAdded.fire(Player$newPlayer(thiz), effect.getComponentName()); _tickCallback(); if (cancelled) { return false; @@ -363,7 +355,7 @@ events.playerDropItem.on(event => { const original = symhook("?onEffectRemoved@ServerPlayer@@MEAAXAEAVMobEffectInstance@@@Z", bool_t, null, ServerPlayer, MobEffectInstance) ((thiz, effect) => { - const cancelled = LXL_Events.onEffectRemoved.fire(Player$newPlayer(thiz), effect.getComponentName()); + const cancelled = LLSE_Events.onEffectRemoved.fire(Player$newPlayer(thiz), effect.getComponentName()); _tickCallback(); if (cancelled) { return false; @@ -376,7 +368,7 @@ events.playerDropItem.on(event => { const original = symhook("?onEffectUpdated@ServerPlayer@@MEAAXAEAVMobEffectInstance@@@Z", bool_t, null, ServerPlayer, MobEffectInstance) ((thiz, effect) => { - const cancelled = LXL_Events.onEffectUpdated.fire(Player$newPlayer(thiz), effect.getComponentName()); + const cancelled = LLSE_Events.onEffectUpdated.fire(Player$newPlayer(thiz), effect.getComponentName()); _tickCallback(); if (cancelled) { return false; @@ -390,7 +382,7 @@ events.playerDropItem.on(event => { const original = symhook("?sendBlockDestructionStarted@BlockEventCoordinator@@QEAAXAEAVPlayer@@AEBVBlockPos@@@Z", void_t, null, StaticPointer, Player, BlockPos) ((thiz, player, blockPos) => { - const cancelled = LXL_Events.onStartDestroyBlock.fire(Player$newPlayer(player), Block$newBlock(blockPos, player.getDimensionId())); + const cancelled = LLSE_Events.onStartDestroyBlock.fire(Player$newPlayer(player), Block$newBlock(blockPos, player.getDimensionId())); _tickCallback(); return original(thiz, player, blockPos); }); @@ -406,7 +398,7 @@ events.playerDropItem.on(event => { return rtn; } if (placer?.isPlayer()) { - const cancelled = LXL_Events.onPlaceBlock.fire(Player$newPlayer(placer), Block$newBlock(block, pos, placer.getDimensionId())); + const cancelled = LLSE_Events.onPlaceBlock.fire(Player$newPlayer(placer), Block$newBlock(block, pos, placer.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -420,7 +412,7 @@ events.playerDropItem.on(event => { bool_t, null, StaticPointer, ItemStack, Actor, BlockPos, uint8_t, Vec3) ((thiz, instance, entity, pos, face, clickPos) => { if (entity.isPlayer()) { - const cancelled = LXL_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(pos, entity.getDimensionId())); + const cancelled = LLSE_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(pos, entity.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -434,7 +426,7 @@ events.playerDropItem.on(event => { bool_t, null, StaticPointer, ItemStack, Actor, BlockPos, uint8_t, Vec3) ((thiz, instance, entity, pos, face, clickPos) => { if (entity.isPlayer()) { - const cancelled = LXL_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(pos, entity.getDimensionId())); + const cancelled = LLSE_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(pos, entity.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -467,7 +459,7 @@ events.playerDropItem.on(event => { if (!block) { return false; } - const cancelled = LXL_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(block, pos, entity.getDimensionId())); + const cancelled = LLSE_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(block, pos, entity.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -481,7 +473,7 @@ events.playerDropItem.on(event => { bool_t, null, StaticPointer, ItemStack, Actor, BlockPos, uint8_t, Vec3) ((thiz, instance, entity, pos, face, clickPos) => { if (entity.isPlayer()) { - const cancelled = LXL_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(pos, entity.getDimensionId())); + const cancelled = LLSE_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(pos, entity.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -513,7 +505,7 @@ events.playerDropItem.on(event => { if (entity.isPlayer()) { const signType = daccess(thiz, int32_t, 568); const block = face === 1 ? blockMap.get(signType)![0] : blockMap.get(signType)![1]; - const cancelled = LXL_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(block, pos, entity.getDimensionId())); + const cancelled = LLSE_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(block, pos, entity.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -530,7 +522,7 @@ events.playerDropItem.on(event => { const growDirection = daccess(thiz, int32_t, 42); const blockPos = pos.relative(growDirection, 1); const block = daccess(thiz, Block.ref(), 8); - const cancelled = LXL_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(block, blockPos, entity.getDimensionId())); + const cancelled = LLSE_Events.onPlaceBlock.fire(Player$newPlayer(entity), Block$newBlock(block, blockPos, entity.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -547,7 +539,7 @@ events.playerDropItem.on(event => { ((thiz, event) => { const blockPos = daccess(event, BlockPos, 28); const pl = MCAPI.WeakEntityRef.tryUnwrap(event)!; - const cancelled = LXL_Events.onOpenContainer.fire(Player$newPlayer(pl), Block$newBlock(blockPos, pl.getDimensionId())); + const cancelled = LLSE_Events.onOpenContainer.fire(Player$newPlayer(pl), Block$newBlock(blockPos, pl.getDimensionId())); _tickCallback(); if (cancelled) { return 0; @@ -562,7 +554,7 @@ events.playerDropItem.on(event => { bool_t, null, BlockActor, Player) ((thiz, player) => { const bp = thiz.getPosition(); - const cancelled = LXL_Events.onCloseContainer.fire(Player$newPlayer(player), Block$newBlock(bp, player.getDimensionId())); + const cancelled = LLSE_Events.onCloseContainer.fire(Player$newPlayer(player), Block$newBlock(bp, player.getDimensionId())); _tickCallback(); return original(thiz, player); }); @@ -572,7 +564,7 @@ events.playerDropItem.on(event => { bool_t, null, BlockActor, Player) ((thiz, player) => { const bp = thiz.getPosition(); - const cancelled = LXL_Events.onCloseContainer.fire(Player$newPlayer(player), Block$newBlock(bp, player.getDimensionId())); + const cancelled = LLSE_Events.onCloseContainer.fire(Player$newPlayer(player), Block$newBlock(bp, player.getDimensionId())); _tickCallback(); return original(thiz, player); }); @@ -584,7 +576,7 @@ events.playerDropItem.on(event => { void_t, null, Player, Container, int32_t, ItemStack, ItemStack) ((thiz, container, slot, oldItem, newItem) => { if (thiz.isPlayer()) { - const cancelled = LXL_Events.onInventoryChange.fire(Player$newPlayer(thiz), slot, Item$newItem(oldItem), Item$newItem(newItem)); + const cancelled = LLSE_Events.onInventoryChange.fire(Player$newPlayer(thiz), slot, Item$newItem(oldItem), Item$newItem(newItem)); _tickCallback(); } return original(thiz, container, slot, oldItem, newItem); @@ -597,7 +589,7 @@ events.playerDropItem.on(event => { void_t, null, StaticPointer, Player) ((thiz, player) => { if (player.getStatusFlag(ActorFlags.Moving)) { - const cancelled = LXL_Events.onMove.fire(Player$newPlayer(player), FloatPos$newPos(player.getPosition(), player.getDimensionId())); + const cancelled = LLSE_Events.onMove.fire(Player$newPlayer(player), FloatPos$newPos(player.getPosition(), player.getDimensionId())); _tickCallback(); } return original(thiz, player); @@ -610,7 +602,7 @@ events.playerDropItem.on(event => { void_t, null, Actor, bool_t) ((thiz, shouldSprint) => { if (thiz.isPlayer() && thiz.isSprinting() !== shouldSprint) { - const cancelled = LXL_Events.onChangeSprinting.fire(Player$newPlayer(thiz), shouldSprint); + const cancelled = LLSE_Events.onChangeSprinting.fire(Player$newPlayer(thiz), shouldSprint); _tickCallback(); } return original(thiz, shouldSprint); @@ -623,7 +615,7 @@ events.playerDropItem.on(event => { void_t, null, Player, uint32_t, ItemStack) ((thiz, slot: ArmorSlot, item) => { if (thiz.isPlayer()) { - const cancelled = LXL_Events.onSetArmor.fire(Player$newPlayer(thiz), slot, Item$newItem(item)); + const cancelled = LLSE_Events.onSetArmor.fire(Player$newPlayer(thiz), slot, Item$newItem(item)); _tickCallback(); } return original(thiz, slot, item); @@ -635,7 +627,7 @@ events.playerDropItem.on(event => { const original = symhook("?trySetSpawn@RespawnAnchorBlock@@CA_NAEAVPlayer@@AEBVBlockPos@@AEAVBlockSource@@AEAVLevel@@@Z", bool_t, null, Player, BlockPos, BlockSource, Level) ((player, blockPos, region, level) => { - const cancelled = LXL_Events.onUseRespawnAnchor.fire(Player$newPlayer(player), IntPos$newPos(blockPos, region.getDimensionId())); + const cancelled = LLSE_Events.onUseRespawnAnchor.fire(Player$newPlayer(player), IntPos$newPos(blockPos, region.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -649,7 +641,7 @@ events.playerDropItem.on(event => { const original = symhook("?canOpenContainerScreen@Player@@UEAA_NXZ", bool_t, null, Player) ((thiz) => { - const cancelled = LXL_Events.onOpenContainerScreen.fire(Player$newPlayer(thiz)); + const cancelled = LLSE_Events.onOpenContainerScreen.fire(Player$newPlayer(thiz)); _tickCallback(); if (cancelled) { return false; @@ -669,7 +661,7 @@ events.playerDropItem.on(event => { console.log(origin.getOriginType()); const isMinecart = origin.getOriginType() === CommandOriginType.MinecartCommandBlock; const pos = isMinecart ? origin.getEntity()!.getPosition() : LlAPI.BlockPos.toVec3(origin.getBlockPosition()); - const cancelled = LXL_Events.onCmdBlockExecute.fire(command, FloatPos$newPos(pos, origin.getDimension().getDimensionId()), isMinecart); + const cancelled = LLSE_Events.onCmdBlockExecute.fire(command, FloatPos$newPos(pos, origin.getDimension().getDimensionId()), isMinecart); _tickCallback(); if (cancelled) { return false; @@ -683,7 +675,7 @@ events.playerDropItem.on(event => { const original = symhook("?onBlockInteractedWith@VanillaServerGameplayEventListener@@UEAA?AW4EventResult@@AEAVPlayer@@AEBVBlockPos@@@Z", uint16_t, null, StaticPointer, Player, BlockPos) ((thiz, player, blockPos) => { - const cancelled = LXL_Events.onBlockInteracted.fire(Player$newPlayer(player), Block$newBlock(blockPos, player.getDimensionId())); + const cancelled = LLSE_Events.onBlockInteracted.fire(Player$newPlayer(player), Block$newBlock(blockPos, player.getDimensionId())); _tickCallback(); if (cancelled) { return 0; @@ -698,7 +690,7 @@ events.playerDropItem.on(event => { void_t, null, BlockSource, BlockPos, uint32_t, Block, Block, int32_t, StaticPointer, Actor) ((thiz, pos, layer, block, previousBlock, updateFlags, syncMsg, actor) => { const dimId = thiz.getDimensionId(); - const cancelled = LXL_Events.onBlockChanged.fire(Block$newBlock(previousBlock, pos, dimId), Block$newBlock(block, pos, dimId)); + const cancelled = LLSE_Events.onBlockChanged.fire(Block$newBlock(previousBlock, pos, dimId), Block$newBlock(block, pos, dimId)); _tickCallback(); if (cancelled) { return; @@ -713,7 +705,7 @@ events.playerDropItem.on(event => { void_t, null, Block, BlockSource, BlockPos, Actor) ((thiz, region, pos, entitySource) => { if (entitySource) { - const cancelled = LXL_Events.onBlockExploded.fire(Block$newBlock(pos, entitySource.getDimensionId()), Entity$newEntity(entitySource)); + const cancelled = LLSE_Events.onBlockExploded.fire(Block$newBlock(pos, entitySource.getDimensionId()), Entity$newEntity(entitySource)); _tickCallback(); } return original(thiz, region, pos, entitySource); @@ -740,7 +732,7 @@ let onFireSpread_OnPlace = false; return rtn; } - const cancelled = LXL_Events.onFireSpread.fire(IntPos$newPos(pos, region.getDimensionId())); + const cancelled = LLSE_Events.onFireSpread.fire(IntPos$newPos(pos, region.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -757,7 +749,7 @@ let onFireSpread_OnPlace = false; const pl = daccess(thiz, Player.ref(), 208); if (pl.hasOpenContainer()) { const bp = daccess(thiz, BlockPos, 216); - const cancelled = LXL_Events.onContainerChange.fire(Player$newPlayer(pl), Block$newBlock(bp, pl.getDimensionId()), slot, Item$newItem(oldItem), Item$newItem(newItem)); + const cancelled = LLSE_Events.onContainerChange.fire(Player$newPlayer(pl), Block$newBlock(bp, pl.getDimensionId()), slot, Item$newItem(oldItem), Item$newItem(newItem)); _tickCallback(); } return original(thiz, slot, oldItem, newItem); @@ -773,7 +765,7 @@ let onFireSpread_OnPlace = false; return original(thiz, region, pos, projectile); } if (thiz.getName() !== "minecraft:air") { - const cancelled = LXL_Events.onProjectileHitBlock.fire(Block$newBlock(pos, region.getDimensionId()), Entity$newEntity(projectile)); + const cancelled = LLSE_Events.onProjectileHitBlock.fire(Block$newBlock(pos, region.getDimensionId()), Entity$newEntity(projectile)); _tickCallback(); } return original(thiz, region, pos, projectile); @@ -785,7 +777,7 @@ let onFireSpread_OnPlace = false; const original = symhook("?onRedstoneUpdate@RedStoneWireBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", void_t, null, BlockLegacy, BlockSource, BlockPos, int32_t, bool_t) ((thiz, region, pos, strength, isFirstTime) => { - const cancelled = LXL_Events.onRedStoneUpdate.fire(Block$newBlock(pos, region.getDimensionId()), strength, isFirstTime); + const cancelled = LLSE_Events.onRedStoneUpdate.fire(Block$newBlock(pos, region.getDimensionId()), strength, isFirstTime); _tickCallback(); if (cancelled) { return; @@ -797,7 +789,7 @@ let onFireSpread_OnPlace = false; const original = symhook("?onRedstoneUpdate@RedstoneTorchBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", void_t, null, BlockLegacy, BlockSource, BlockPos, int32_t, bool_t) ((thiz, region, pos, strength, isFirstTime) => { - const cancelled = LXL_Events.onRedStoneUpdate.fire(Block$newBlock(pos, region.getDimensionId()), strength, isFirstTime); + const cancelled = LLSE_Events.onRedStoneUpdate.fire(Block$newBlock(pos, region.getDimensionId()), strength, isFirstTime); _tickCallback(); if (cancelled) { return; @@ -809,7 +801,7 @@ let onFireSpread_OnPlace = false; const original = symhook("?onRedstoneUpdate@DiodeBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", void_t, null, BlockLegacy, BlockSource, BlockPos, int32_t, bool_t) ((thiz, region, pos, strength, isFirstTime) => { - const cancelled = LXL_Events.onRedStoneUpdate.fire(Block$newBlock(pos, region.getDimensionId()), strength, isFirstTime); + const cancelled = LLSE_Events.onRedStoneUpdate.fire(Block$newBlock(pos, region.getDimensionId()), strength, isFirstTime); _tickCallback(); if (cancelled) { return; @@ -821,7 +813,7 @@ let onFireSpread_OnPlace = false; const original = symhook("?onRedstoneUpdate@ComparatorBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@H_N@Z", void_t, null, BlockLegacy, BlockSource, BlockPos, int32_t, bool_t) ((thiz, region, pos, strength, isFirstTime) => { - const cancelled = LXL_Events.onRedStoneUpdate.fire(Block$newBlock(pos, region.getDimensionId()), strength, isFirstTime); + const cancelled = LLSE_Events.onRedStoneUpdate.fire(Block$newBlock(pos, region.getDimensionId()), strength, isFirstTime); _tickCallback(); if (cancelled) { return; @@ -836,7 +828,7 @@ let onFireSpread_OnPlace = false; bool_t, null, StaticPointer, BlockSource, Container, Vec3) ((thiz, region, toContainer, pos) => { const isMinecart = daccess(thiz, bool_t, 5); - const cancelled = LXL_Events.onHopperSearchItem.fire(FloatPos$newPos(isMinecart ? pos : LlAPI.Vec3.toBlockPos(pos), region.getDimensionId()), isMinecart); + const cancelled = LLSE_Events.onHopperSearchItem.fire(FloatPos$newPos(isMinecart ? pos : LlAPI.Vec3.toBlockPos(pos), region.getDimensionId()), isMinecart); _tickCallback(); if (cancelled) { return false; @@ -850,7 +842,7 @@ let onFireSpread_OnPlace = false; const original = symhook("?_pushOutItems@Hopper@@IEAA_NAEAVBlockSource@@AEAVContainer@@AEBVVec3@@H@Z", bool_t, null, StaticPointer, BlockSource, Container, Vec3, int32_t) ((thiz, region, fromContainer, position, attachedFace) => { - const cancelled = LXL_Events.onHopperPushOut.fire(FloatPos$newPos(position, region.getDimensionId())); + const cancelled = LLSE_Events.onHopperPushOut.fire(FloatPos$newPos(position, region.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -869,7 +861,7 @@ let onFireSpread_OnPlace = false; if (targetBlock.getName() === "minecraft:air") { return original(thiz, region, curPos, curBranchFacing, pistonMoveFacing); } - const cancelled = LXL_Events.onPistonTryPush.fire(IntPos$newPos(curPos, region.getDimensionId()), Block$newBlock(thiz.getPosition(), region.getDimensionId())); + const cancelled = LLSE_Events.onPistonTryPush.fire(IntPos$newPos(curPos, region.getDimensionId()), Block$newBlock(thiz.getPosition(), region.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -884,7 +876,7 @@ let onFireSpread_OnPlace = false; if (targetBlock.getName() === "minecraft:air") { return true; } - const cancelled = LXL_Events.onPistonPush.fire(IntPos$newPos(curPos, region.getDimensionId()), Block$newBlock(thiz.getPosition(), region.getDimensionId())); + const cancelled = LLSE_Events.onPistonPush.fire(IntPos$newPos(curPos, region.getDimensionId()), Block$newBlock(thiz.getPosition(), region.getDimensionId())); } return true; }); @@ -892,7 +884,7 @@ let onFireSpread_OnPlace = false; /////////////////// FarmLandDecay /////////////////// events.farmlandDecay.on(event => { - const cancelled = LXL_Events.onFarmLandDecay.fire(IntPos$newPos(event.blockPos, event.blockSource.getDimensionId()), Entity$newEntity(event.culprit)); + const cancelled = LLSE_Events.onFarmLandDecay.fire(IntPos$newPos(event.blockPos, event.blockSource.getDimensionId()), Entity$newEntity(event.culprit)); _tickCallback(); if (cancelled) { return CANCEL; @@ -904,7 +896,7 @@ events.farmlandDecay.on(event => { const original = symhook("?use@ItemFrameBlock@@UEBA_NAEAVPlayer@@AEBVBlockPos@@E@Z", bool_t, null, BlockLegacy, Player, BlockPos) ((thiz, player, pos) => { - const cancelled = LXL_Events.onUseFrameBlock.fire(Player$newPlayer(player), Block$newBlock(pos, player.getDimensionId())); + const cancelled = LLSE_Events.onUseFrameBlock.fire(Player$newPlayer(player), Block$newBlock(pos, player.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -916,7 +908,7 @@ events.farmlandDecay.on(event => { const original = symhook("?attack@ItemFrameBlock@@UEBA_NPEAVPlayer@@AEBVBlockPos@@@Z", bool_t, null, BlockLegacy, Player, BlockPos) ((thiz, player, pos) => { - const cancelled = LXL_Events.onUseFrameBlock.fire(Player$newPlayer(player), Block$newBlock(pos, player.getDimensionId())); + const cancelled = LLSE_Events.onUseFrameBlock.fire(Player$newPlayer(player), Block$newBlock(pos, player.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -934,7 +926,7 @@ events.farmlandDecay.on(event => { if (!rtn) { return rtn; } - const cancelled = LXL_Events.onLiquidFlow.fire(Block$newBlock(thiz.getRenderBlock(), pos, region.getDimensionId()), IntPos$newPos(pos, region.getDimensionId())); + const cancelled = LLSE_Events.onLiquidFlow.fire(Block$newBlock(thiz.getRenderBlock(), pos, region.getDimensionId()), IntPos$newPos(pos, region.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -949,7 +941,7 @@ events.farmlandDecay.on(event => { bool_t, null, Player, ActorDamageSource) ((thiz, source) => { const src = bedrockServer.level.fetchEntity(source.getDamagingEntityUniqueID(), true); - const cancelled = LXL_Events.onPlayerDie.fire(Player$newPlayer(thiz), src ? Entity$newEntity(src) : null); + const cancelled = LLSE_Events.onPlayerDie.fire(Player$newPlayer(thiz), src ? Entity$newEntity(src) : null); _tickCallback(); return original(thiz, source); }); @@ -961,7 +953,7 @@ events.farmlandDecay.on(event => { bool_t, null, BlockSource, Actor, BlockPos, ItemStack, bool_t) ((thiz, entity, pos, item, generateParticle) => { if (entity.isPlayer()) { - const cancelled = LXL_Events.onDestroyBlock.fire(Player$newPlayer(entity), Block$newBlock(pos, entity.getDimensionId())); + const cancelled = LLSE_Events.onDestroyBlock.fire(Player$newPlayer(entity), Block$newBlock(pos, entity.getDimensionId())); _tickCallback(); if (cancelled) { return false; @@ -977,7 +969,7 @@ events.farmlandDecay.on(event => { bool_t, null, GameMode, ItemStack, BlockPos, uint8_t, Vec3, Block) ((thiz, item, at, face, hit, targetBlock) => { const player = thiz.actor; - const cancelled = LXL_Events.onUseItemOn.fire(Player$newPlayer(player), Item$newItem(item), Block$newBlock(at, player.getDimensionId()), face); + const cancelled = LLSE_Events.onUseItemOn.fire(Player$newPlayer(player), Item$newItem(item), Block$newBlock(at, player.getDimensionId()), face); _tickCallback(); if (cancelled) { return false; @@ -992,7 +984,7 @@ events.farmlandDecay.on(event => { bool_t, null, Actor, ActorDamageSource, int32_t, bool_t, bool_t) ((thiz, source, dmg, knock, ignite) => { const src = bedrockServer.level.fetchEntity(source.getDamagingEntityUniqueID(), true); - const cancelled = LXL_Events.onMobHurt.fire(Entity$newEntity(thiz), src ? Entity$newEntity(src) : null, dmg); + const cancelled = LLSE_Events.onMobHurt.fire(Entity$newEntity(thiz), src ? Entity$newEntity(src) : null, dmg, source.cause); _tickCallback(); if (cancelled) { return false; @@ -1008,7 +1000,7 @@ events.farmlandDecay.on(event => { ((thiz, item) => { const player = thiz.actor; { - const cancelled = LXL_Events.onUseItem.fire(Player$newPlayer(player), Item$newItem(item)); + const cancelled = LLSE_Events.onUseItem.fire(Player$newPlayer(player), Item$newItem(item)); _tickCallback(); if (cancelled) { return false; @@ -1016,7 +1008,7 @@ events.farmlandDecay.on(event => { } { if (item.item.isFood() && (player.isHungry() || player.forceAllowEating())) { - const cancelled = LXL_Events.onEat.fire(Player$newPlayer(player), Item$newItem(item)); + const cancelled = LLSE_Events.onEat.fire(Player$newPlayer(player), Item$newItem(item)); _tickCallback(); if (cancelled) { player.setAttribute(AttributeId.PlayerHunger, player.getAttribute(AttributeId.PlayerHunger)); @@ -1031,7 +1023,7 @@ events.farmlandDecay.on(event => { /////////////////// MobDie /////////////////// events.entityDie.on(event => { const src = event.damageSource.getDamagingEntity(); - LXL_Events.onMobDie.fire(Entity$newEntity(event.entity), src ? Entity$newEntity(src) : null); + LLSE_Events.onMobDie.fire(Entity$newEntity(event.entity), src ? Entity$newEntity(src) : null, event.damageSource.cause); }); /////////////////// Entity & Block Explosion /////////////////// @@ -1047,7 +1039,7 @@ events.entityDie.on(event => { const genFire = thiz.mFire; const canBreaking = thiz.mBreaking; if (actor) { - const cancelled = LXL_Events.onEntityExplode.fire(Entity$newEntity(actor), FloatPos$newPos(pos, actor.getDimensionId()), maxResistance, radius, canBreaking, genFire); + const cancelled = LLSE_Events.onEntityExplode.fire(Entity$newEntity(actor), FloatPos$newPos(pos, actor.getDimensionId()), maxResistance, radius, canBreaking, genFire); _tickCallback(); if (cancelled) { return; @@ -1057,13 +1049,13 @@ events.entityDie.on(event => { const bp = LlAPI.Vec3.toBlockPos(pos); const block = bs.getBlock(bp); if (block.getName() === "minecraft:respawn_anchor") { - cancelled ||= LXL_Events.onRespawnAnchorExplode.fire(IntPos$newPos(bp, bs.getDimensionId())); + cancelled ||= LLSE_Events.onRespawnAnchorExplode.fire(IntPos$newPos(bp, bs.getDimensionId())); _tickCallback(); } else { - cancelled ||= LXL_Events.onBedExplode.fire(IntPos$newPos(bp, bs.getDimensionId())); + cancelled ||= LLSE_Events.onBedExplode.fire(IntPos$newPos(bp, bs.getDimensionId())); _tickCallback(); } - cancelled ||= LXL_Events.onBlockExplode.fire(Block$newBlock(bp, bs.getDimensionId()), IntPos$newPos(bp, bs.getDimensionId()), maxResistance, radius, canBreaking, genFire); + cancelled ||= LLSE_Events.onBlockExplode.fire(Block$newBlock(bp, bs.getDimensionId()), IntPos$newPos(bp, bs.getDimensionId()), maxResistance, radius, canBreaking, genFire); _tickCallback(); if (cancelled) { return; @@ -1080,7 +1072,7 @@ events.entityDie.on(event => { ((thiz, owner, res) => { const to = MCAPI.HitResult.getEntity(res); if (to) { - const cancelled = LXL_Events.onProjectileHitEntity.fire(Entity$newEntity(to), Entity$newEntity(owner)); + const cancelled = LLSE_Events.onProjectileHitEntity.fire(Entity$newEntity(to), Entity$newEntity(owner)); _tickCallback(); } return original(thiz, owner, res); @@ -1092,7 +1084,7 @@ events.entityDie.on(event => { const original = symhook("?_destroyBlocks@WitherBoss@@AEAAXAEAVLevel@@AEBVAABB@@AEAVBlockSource@@H@Z", void_t, null, Actor, Level, MCAPI.AABB, BlockSource, int32_t) ((thiz, level, areaofeffect, region, a5) => { - const cancelled = LXL_Events.onWitherBossDestroy.fire(Entity$newEntity(thiz), IntPos$newPos(LlAPI.Vec3.toBlockPos(areaofeffect.min), thiz.getDimensionId()), IntPos$newPos(LlAPI.Vec3.toBlockPos(areaofeffect.max), thiz.getDimensionId())); + const cancelled = LLSE_Events.onWitherBossDestroy.fire(Entity$newEntity(thiz), IntPos$newPos(LlAPI.Vec3.toBlockPos(areaofeffect.min), thiz.getDimensionId()), IntPos$newPos(LlAPI.Vec3.toBlockPos(areaofeffect.max), thiz.getDimensionId())); _tickCallback(); if (cancelled) { return; @@ -1110,7 +1102,7 @@ events.entityDie.on(event => { if (!rtn) { return false; } - const cancelled = LXL_Events.onRide.fire(Entity$newEntity(thiz), Entity$newEntity(passenger)); + const cancelled = LLSE_Events.onRide.fire(Entity$newEntity(thiz), Entity$newEntity(passenger)); _tickCallback(); if (cancelled) { return false; @@ -1124,7 +1116,7 @@ events.entityDie.on(event => { const original = symhook("?entityInside@BasePressurePlateBlock@@UEBAXAEAVBlockSource@@AEBVBlockPos@@AEAVActor@@@Z", void_t, null, BlockLegacy, BlockSource, BlockPos, Actor) ((thiz, region, pos, entity) => { - const cancelled = LXL_Events.onStepOnPressurePlate.fire(Entity$newEntity(entity), Block$newBlock(pos, entity.getDimensionId())); + const cancelled = LLSE_Events.onStepOnPressurePlate.fire(Entity$newEntity(entity), Block$newBlock(pos, entity.getDimensionId())); _tickCallback(); return original(thiz, region, pos, entity); }); @@ -1140,14 +1132,14 @@ events.entityDie.on(event => { if (fullName.endsWith("<>")) { fullName = fullName.substring(0, fullName.length - 2); } - const cancelled = LXL_Events.onSpawnProjectile.fire(Entity$newEntity(spawner), fullName); + const cancelled = LLSE_Events.onSpawnProjectile.fire(Entity$newEntity(spawner), fullName); _tickCallback(); if (cancelled) { return null as any; } } const projectile = original(thiz, region, id, spawner, position, direction); - const cancelled = LXL_Events.onProjectileCreated.fire(Entity$newEntity(spawner), Entity$newEntity(projectile)); + const cancelled = LLSE_Events.onProjectileCreated.fire(Entity$newEntity(spawner), Entity$newEntity(projectile)); return projectile; }); } @@ -1155,7 +1147,7 @@ events.entityDie.on(event => { const original = symhook("?_shootFirework@CrossbowItem@@AEBAXAEBVItemInstance@@AEAVPlayer@@@Z", void_t, null, StaticPointer, ItemStack, Player) ((thiz, projectileInstance, player) => { - const cancelled = LXL_Events.onSpawnProjectile.fire(Entity$newEntity(player), "minecraft:fireworks_rocket"); + const cancelled = LLSE_Events.onSpawnProjectile.fire(Entity$newEntity(player), "minecraft:fireworks_rocket"); _tickCallback(); if (cancelled) { return; @@ -1167,7 +1159,7 @@ events.entityDie.on(event => { const original = symhook("?releaseUsing@TridentItem@@UEBAXAEAVItemStack@@PEAVPlayer@@H@Z", void_t, null, StaticPointer, ItemStack, Player, int32_t) ((thiz, itemStack, player, durationLeft) => { - const cancelled = LXL_Events.onSpawnProjectile.fire(Entity$newEntity(player), LlAPI.ItemStack.getTypeName(itemStack)); + const cancelled = LLSE_Events.onSpawnProjectile.fire(Entity$newEntity(player), LlAPI.ItemStack.getTypeName(itemStack)); _tickCallback(); if (cancelled) { return; @@ -1188,7 +1180,7 @@ events.entityDie.on(event => { if (actionAt && actionAt.mType === MCAPI.NpcActionType.CommandAction) { const str = actionAt.as(MCAPI.NpcCommandAction).mCommands.get(0)?.mCommandLine; if (str) { - const cancelled = LXL_Events.onNpcCmd.fire(Entity$newEntity(owner), Player$newPlayer(player), str); + const cancelled = LLSE_Events.onNpcCmd.fire(Entity$newEntity(owner), Player$newPlayer(player), str); _tickCallback(); if (cancelled) { return; @@ -1206,7 +1198,7 @@ events.entityDie.on(event => { const original = symhook("?_trySwapItem@ArmorStand@@AEAA_NAEAVPlayer@@W4EquipmentSlot@@@Z", bool_t, null, Actor, Player, int32_t) ((thiz, player, slot) => { - const cancelled = LXL_Events.onChangeArmorStand.fire(Entity$newEntity(thiz), Player$newPlayer(player), slot); + const cancelled = LLSE_Events.onChangeArmorStand.fire(Entity$newEntity(thiz), Player$newPlayer(player), slot); _tickCallback(); if (cancelled) { return false; @@ -1232,7 +1224,7 @@ events.entityDie.on(event => { } } if (player?.isPlayer()) { - const cancelled = LXL_Events.onScoreChanged.fire(Player$newPlayer(player), obj.getPlayerScore(id).value, obj.name, obj.displayName); + const cancelled = LLSE_Events.onScoreChanged.fire(Player$newPlayer(player), obj.getPlayerScore(id).value, obj.name, obj.displayName); _tickCallback(); } return original(thiz, id, obj); @@ -1241,22 +1233,36 @@ events.entityDie.on(event => { ////////////// ServerStarted ////////////// events.serverOpen.on(() => { - LXL_Events.onServerStarted.fire(); + LLSE_Events.onServerStarted.fire(); _tickCallback(); }); ////////////// ConsoleOutput ////////////// events.commandOutput.on(log => { - const cancelled = LXL_Events.onConsoleOutput.fire(log); + const cancelled = LLSE_Events.onConsoleOutput.fire(log); _tickCallback(); if (cancelled) { return CANCEL; } -}) +}); + +////////////// MobSpawn ////////////// +{ + const original = symhook("?spawnMob@Spawner@@QEAAPEAVMob@@AEAVBlockSource@@AEBUActorDefinitionIdentifier@@PEAVActor@@AEBVVec3@@_N44@Z", + Mob, null, Spawner, BlockSource, ActorDefinitionIdentifier, Actor, Vec3, bool_t, bool_t, bool_t) + ((thiz, region, id, spawner, pos, naturalSpawn, surface, fromSpawner) => { + const cancelled = LLSE_Events.onMobSpawn.fire(id.canonicalName.str, FloatPos$newPos(pos, region.getDimensionId())); + _tickCallback(); + if (cancelled) { + return null; + } + return original(thiz, region, id, spawner, pos, naturalSpawn, surface, fromSpawner); + }); +} // 怍ε…₯tick events.levelTick.on(() => { - LXL_Events.onTick.fire(); + LLSE_Events.onTick.fire(); _tickCallback(); -}) \ No newline at end of file +}); \ No newline at end of file diff --git a/src/api/gui.ts b/src/api/gui.ts index 9e812ce..bbf5fbb 100644 --- a/src/api/gui.ts +++ b/src/api/gui.ts @@ -1,7 +1,7 @@ import { CustomForm, FormButton, FormDropdown, FormInput, FormLabel, FormSlider, FormStepSlider, FormToggle, SimpleForm } from "bdsx/bds/form"; import { PrivateFields } from "./api_help"; -export class LXL_SimpleForm { +export class LLSE_SimpleForm { [PrivateFields]: SimpleForm; setTitle(title: string) { @@ -25,12 +25,12 @@ export class LXL_SimpleForm { } export function newSimpleForm() { - const newp = new LXL_SimpleForm(); + const newp = new LLSE_SimpleForm(); newp[PrivateFields] = new SimpleForm(); return newp; } -export class LXL_CustomForm { +export class LLSE_CustomForm { [PrivateFields]: CustomForm; setTitle(title: string) { @@ -70,7 +70,7 @@ export class LXL_CustomForm { } export function newCustomForm() { - const newp = new LXL_CustomForm(); + const newp = new LLSE_CustomForm(); newp[PrivateFields] = new CustomForm(); return newp; } \ No newline at end of file diff --git a/src/api/index.ts b/src/api/index.ts index 99fbbfb..7b1d506 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1,23 +1,23 @@ import { ClearInterval, SetInterval, SetTimeout } from "./api_help"; import { DirectionAngle, FloatPos, getBDSVersion, IntPos, newFloatPos, newIntPos } from "./base"; -import { getBlock, LXL_Block, setBlock, spawnParticle } from "./block"; -import { LXL_BlockEntity } from "./block_entity"; +import { getBlock, LLSE_Block, setBlock, spawnParticle } from "./block"; +import { LLSE_BlockEntity } from "./block_entity"; import { LLSE_Command, LLSE_CommandOrigin, LLSE_CommandOutput, newCommand, OriginType, ParamOption, ParamType, PermType, regConsoleCmd, regPlayerCmd, runcmd, runcmdEx, sendCmdOutput } from "./command"; -import { LXL_Container } from "./container"; +import { LLSE_Container } from "./container"; import { data, IniConfigFile, JsonConfigFile, KVDatabase, money } from "./data"; -import { LXL_Device } from "./device"; -import { explode, getAllEntities, LXL_Entity, spawnMob } from "./entity"; +import { LLSE_Device } from "./device"; +import { explode, getAllEntities, LLSE_Entity, spawnMob } from "./entity"; import { listen } from "./event"; import { File } from "./file_system"; import { Format } from "./game_utils"; -import { LXL_CustomForm, LXL_SimpleForm, newCustomForm, newSimpleForm } from "./gui"; -import { LXL_Item, newItem, spawnItem } from "./item"; +import { LLSE_CustomForm, LLSE_SimpleForm, newCustomForm, newSimpleForm } from "./gui"; +import { LLSE_Item, newItem, spawnItem } from "./item"; import { ll } from "./ll"; import { logger } from "./logger"; import { NBT, NbtByte, NbtByteArray, NbtCompound, NbtDouble, NbtEnd, NbtFloat, NbtInt, NbtList, NbtLong, NbtShort, NbtString } from "./nbt"; import { network, WSClient } from "./network"; -import { broadcast, getOnlinePlayers, getPlayer, LXL_Player } from "./player"; -import { clearDisplayObjective, getAllScoreObjectives, getDisplayObjective, getScoreObjective, LXL_Objective, newScoreObjective, removeScoreObjective } from "./scoreboard"; +import { broadcast, getOnlinePlayers, getPlayer, LLSE_Player } from "./player"; +import { clearDisplayObjective, getAllScoreObjectives, getDisplayObjective, getScoreObjective, LLSE_Objective, newScoreObjective, removeScoreObjective } from "./scoreboard"; import { colorLog, fastLog, log } from "./script"; import { crashBDS as crash, setMotd } from "./server"; import { system } from "./system"; @@ -92,21 +92,21 @@ const bindings = { IntPos, FloatPos, DirectionAngle, - LXL_Block, + LLSE_Block, KVDatabase, JsonConfigFile, IniConfigFile, - LXL_Device, - LXL_Container, - LXL_Entity, + LLSE_Device, + LLSE_Container, + LLSE_Entity, File, WSClient, - LXL_BlockEntity, - LXL_SimpleForm, - LXL_CustomForm, - LXL_Item, - LXL_Player, - LXL_Objective, + LLSE_BlockEntity, + LLSE_SimpleForm, + LLSE_CustomForm, + LLSE_Item, + LLSE_Player, + LLSE_Objective, NbtEnd, NbtByte, NbtShort, diff --git a/src/api/item.ts b/src/api/item.ts index 09ad197..34e81fc 100644 --- a/src/api/item.ts +++ b/src/api/item.ts @@ -5,10 +5,10 @@ import { bedrockServer } from "bdsx/launcher"; import { LlAPI } from "../dep/native"; import { PrivateFields } from "./api_help"; import { FloatPos, IntPos } from "./base"; -import { Entity$newEntity, LXL_Entity } from "./entity"; +import { Entity$newEntity, LLSE_Entity } from "./entity"; import { NbtCompound } from "./nbt"; -export class LXL_Item { +export class LLSE_Item { [PrivateFields]: ItemStack; getRawPtr() { @@ -25,7 +25,7 @@ export class LXL_Item { aux: number; - set(item: LXL_Item) { + set(item: LLSE_Item) { const itemNew = item[PrivateFields]; if (!itemNew) { return null; @@ -77,7 +77,7 @@ export class LXL_Item { } export function Item$newItem(p: ItemStack) { - const newp = new LXL_Item(); + const newp = new LLSE_Item(); newp[PrivateFields] = p; Object.defineProperty(newp, "name", { value: p.getCustomName() }); Object.defineProperty(newp, "type", { value: LlAPI.ItemStack.getTypeName(p) }); @@ -87,8 +87,8 @@ export function Item$newItem(p: ItemStack) { return newp; } -export function newItem(name: string, count: number): LXL_Item | null; -export function newItem(nbt: NbtCompound): LXL_Item | null; +export function newItem(name: string, count: number): LLSE_Item | null; +export function newItem(nbt: NbtCompound): LLSE_Item | null; export function newItem(a0: any, a1?: any) { if (typeof a0 === "string") { const item = ItemStack.constructWith(a0, a1); @@ -109,9 +109,9 @@ export function newItem(a0: any, a1?: any) { } } -export function spawnItem(item: LXL_Item, pos: IntPos | FloatPos): LXL_Entity; -export function spawnItem(item: LXL_Item, x: number, y: number, z: number, dimid: DimensionId): LXL_Entity; -export function spawnItem(item: LXL_Item, a1: any, a2?: any, a3?: any, a4?: any) { +export function spawnItem(item: LLSE_Item, pos: IntPos | FloatPos): LLSE_Entity; +export function spawnItem(item: LLSE_Item, x: number, y: number, z: number, dimid: DimensionId): LLSE_Entity; +export function spawnItem(item: LLSE_Item, a1: any, a2?: any, a3?: any, a4?: any) { let pos: Vec3; let dimId: DimensionId; if (a1 instanceof IntPos || a1 instanceof FloatPos) { diff --git a/src/api/logger.ts b/src/api/logger.ts index 4f73ae4..d5a526c 100644 --- a/src/api/logger.ts +++ b/src/api/logger.ts @@ -1,7 +1,7 @@ import { LlAPI } from "../dep/native"; import { Logger } from "../utils/logger"; import { PrivateFields, StringifyValue, TimeNow } from "./api_help"; -import { LXL_Player } from "./player"; +import { LLSE_Player } from "./player"; export const logger = { [PrivateFields]: { @@ -9,7 +9,7 @@ export const logger = { consoleLevel: 4, filepath: null! as string, fileLevel: 4, - player: null! as LXL_Player, + player: null! as LLSE_Player, playerLevel: 4, title: "", log(mode: string, ...data: any[]) { @@ -69,7 +69,7 @@ export const logger = { } return true; }, - setPlayer(player: LXL_Player | null, logLevel?: number) { + setPlayer(player: LLSE_Player | null, logLevel?: number) { if (player) { this[PrivateFields].player = player; } diff --git a/src/api/player.ts b/src/api/player.ts index d64ce8f..3e18db5 100644 --- a/src/api/player.ts +++ b/src/api/player.ts @@ -13,11 +13,11 @@ import { DirectionAngle$newAngle, FloatPos, FloatPos$newPos, IntPos, IntPos$newP import { Block$newBlock } from "./block"; import { Container$newContainer } from "./container"; import { Device$newDevice } from "./device"; -import { LXL_CustomForm, LXL_SimpleForm } from "./gui"; -import { Item$newItem, LXL_Item } from "./item"; +import { LLSE_CustomForm, LLSE_SimpleForm } from "./gui"; +import { Item$newItem, LLSE_Item } from "./item"; import { NbtCompound } from "./nbt"; -export class LXL_Player { +export class LLSE_Player { private [PrivateFields]?: ServerPlayer; getRawPtr() { @@ -377,7 +377,7 @@ export class LXL_Player { return player.resendAllChunks(); } - giveItem(item: LXL_Item) { + giveItem(item: LLSE_Item) { const player = this[PrivateFields]; if (!player) { return null; @@ -627,7 +627,7 @@ export class LXL_Player { return true; } - sendSimpleForm(title: string, content: string, buttons: string[], images: string[], callback: (player: LXL_Player, id: number | null) => any) { + sendSimpleForm(title: string, content: string, buttons: string[], images: string[], callback: (player: LLSE_Player, id: number | null) => any) { const player = this[PrivateFields]; if (!player) { return null; @@ -653,7 +653,7 @@ export class LXL_Player { return 1; } - sendModalForm(title: string, content: string, button1: string, button2: string, callback: (player: LXL_Player, result: boolean | null) => any) { + sendModalForm(title: string, content: string, button1: string, button2: string, callback: (player: LLSE_Player, result: boolean | null) => any) { const player = this[PrivateFields]; if (!player) { return null; @@ -672,7 +672,7 @@ export class LXL_Player { return 2; } - sendCustomForm(json: string, callback: (player: LXL_Player, result: any[] | null) => any) { + sendCustomForm(json: string, callback: (player: LLSE_Player, result: any[] | null) => any) { const player = this[PrivateFields]; if (!player) { return null; @@ -694,15 +694,15 @@ export class LXL_Player { } } - sendForm(fm: LXL_SimpleForm, callback: (player: LXL_Player, result: number | null) => any): boolean; - sendForm(fm: LXL_CustomForm, callback: (player: LXL_Player, result: any[] | null) => any): boolean; - sendForm(fm: LXL_SimpleForm | LXL_CustomForm, callback: (player: LXL_Player, result: any) => any) { + sendForm(fm: LLSE_SimpleForm, callback: (player: LLSE_Player, result: number | null) => any): boolean; + sendForm(fm: LLSE_CustomForm, callback: (player: LLSE_Player, result: any[] | null) => any): boolean; + sendForm(fm: LLSE_SimpleForm | LLSE_CustomForm, callback: (player: LLSE_Player, result: any) => any) { const player = this[PrivateFields]; if (!player) { return null as any; } - const id = (fm as LXL_SimpleForm)[PrivateFields].sendTo(player.getNetworkIdentifier(), data => { + const id = (fm as LLSE_SimpleForm)[PrivateFields].sendTo(player.getNetworkIdentifier(), data => { try { callback(this, data.response); } catch (e) { @@ -908,13 +908,13 @@ export class LXL_Player { removeScore = this.deleteScore; } -export function Player$newPlayer(p: ServerPlayer): LXL_Player { - const newp = new LXL_Player(); +export function Player$newPlayer(p: ServerPlayer): LLSE_Player { + const newp = new LLSE_Player(); newp[PrivateFields] = p; return newp; } -export function getPlayer(info: string): LXL_Player | null { +export function getPlayer(info: string): LLSE_Player | null { if (bedrockServer.isLaunched() && info) { let target = info.toLowerCase(); const playerList = bedrockServer.level.getPlayers(); @@ -948,7 +948,7 @@ export function getPlayer(info: string): LXL_Player | null { export function getOnlinePlayers() { const players = bedrockServer.level.getPlayers(); - const list = new Array(); + const list = new Array(); for (const p of players) { list.push(Player$newPlayer(p)); } diff --git a/src/api/scoreboard.ts b/src/api/scoreboard.ts index a9bdcb9..0ed6f30 100644 --- a/src/api/scoreboard.ts +++ b/src/api/scoreboard.ts @@ -2,9 +2,9 @@ import { DisplaySlot, Objective } from "bdsx/bds/scoreboard"; import { bedrockServer } from "bdsx/launcher"; import { LlAPI } from "../dep/native"; import { PrivateFields } from "./api_help"; -import { LXL_Player } from "./player"; +import { LLSE_Player } from "./player"; -export class LXL_Objective { +export class LLSE_Objective { [PrivateFields]: Objective; getRawPtr() { @@ -22,29 +22,29 @@ export class LXL_Objective { return !!sb.setDisplayObjective(slot, this[PrivateFields], sortOrder); } - setScore(target: LXL_Player | string, value: number) { + setScore(target: LLSE_Player | string, value: number) { return LlAPI.Scoreboard.setScore(bedrockServer.level.getScoreboard(), typeof target === "string" ? target : target[PrivateFields] as any, this.name, value); } - addScore(target: LXL_Player | string, value: number) { + addScore(target: LLSE_Player | string, value: number) { return LlAPI.Scoreboard.addScore(bedrockServer.level.getScoreboard(), typeof target === "string" ? target : target[PrivateFields] as any, this.name, value); } - reduceScore(target: LXL_Player | string, value: number) { + reduceScore(target: LLSE_Player | string, value: number) { return LlAPI.Scoreboard.reduceScore(bedrockServer.level.getScoreboard(), typeof target === "string" ? target : target[PrivateFields] as any, this.name, value); } - deleteScore(target: LXL_Player | string) { + deleteScore(target: LLSE_Player | string) { return LlAPI.Scoreboard.deleteScore(bedrockServer.level.getScoreboard(), typeof target === "string" ? target : target[PrivateFields] as any, this.name); } - getScore(target: LXL_Player | string) { + getScore(target: LLSE_Player | string) { return LlAPI.Scoreboard.getScore(bedrockServer.level.getScoreboard(), typeof target === "string" ? target : target[PrivateFields] as any, this.name); } } export function Objective$Objective(p: Objective) { - const newp = new LXL_Objective(); + const newp = new LLSE_Objective(); newp[PrivateFields] = p; Object.defineProperty(newp, "name", { value: p.name }); return newp; @@ -91,7 +91,7 @@ export function removeScoreObjective(name: string) { export function getAllScoreObjectives() { const sb = bedrockServer.level.getScoreboard(); const objs = sb.getObjectives(); - const res = new Array(); + const res = new Array(); for (const obj of objs) { if (obj) { res.push(Objective$Objective(obj)); diff --git a/src/dep/BaseLib.js b/src/dep/BaseLib.js index 2c20e96..818b043 100644 --- a/src/dep/BaseLib.js +++ b/src/dep/BaseLib.js @@ -19,8 +19,7 @@ SOFTWARE. */ (function(){ if(typeof require != "undefined") { - // if require already exist, just exit IIFE - return; + log('require already exist'); } let coreModules = new Map([]); @@ -374,4 +373,27 @@ SOFTWARE. } globalThis.require = cjsRequire; -})(); \ No newline at end of file +})(); + +/* +cjs.js end +*/ + + + +/* +For Compatibility +*/ +globalThis.file = File; +globalThis.lxl = ll; +DirectionAngle.prototype.valueOf = DirectionAngle.prototype.toFacing +globalThis.LXL_Block = LLSE_Block +globalThis.LXL_BlockEntity = LLSE_BlockEntity +globalThis.LXL_Container = LLSE_Container +globalThis.LXL_Device = LLSE_Device +globalThis.LXL_Entity = LLSE_Entity +globalThis.LXL_SimpleForm = LLSE_SimpleForm +globalThis.LXL_CustomForm = LLSE_CustomForm +globalThis.LXL_Item = LLSE_Item +globalThis.LXL_Player = LLSE_Player +globalThis.LXL_Objective = LLSE_Objective \ No newline at end of file diff --git a/src/dep/native.ts b/src/dep/native.ts index 621e797..7f8bef5 100644 --- a/src/dep/native.ts +++ b/src/dep/native.ts @@ -2,6 +2,7 @@ import { Actor, Actor as _Actor, ActorDamageCause, ActorDamageSource, ActorUniqu import { Block as _Block, BlockLegacy as _BlockLegacy, BlockSource as _BlockSource } from "bdsx/bds/block"; import { BlockPos as _BlockPos, Vec3, Vec3 as _Vec3 } from "bdsx/bds/blockpos"; import { Command } from "bdsx/bds/command"; +import { MobEffect as _MobEffect } from "bdsx/bds/effects"; import { ArmorSlot, Container as _Container, FillingContainer, ItemStack, ItemStack as _ItemStack } from "bdsx/bds/inventory"; import { Level as _Level } from "bdsx/bds/level"; import { ByteArrayTag, ByteTag, CompoundTag as _CompoundTag, FloatTag, Int64Tag, ListTag, StringTag, Tag as _Tag } from "bdsx/bds/nbt"; @@ -14,11 +15,10 @@ import { StaticPointer, VoidPointer } from "bdsx/core"; import { CxxVector } from "bdsx/cxxvector"; import { bedrockServer } from "bdsx/launcher"; import { ParamType } from "bdsx/makefunc"; -import { nativeClass, NativeClass, nativeField } from "bdsx/nativeclass"; +import { nativeClass, NativeClass, nativeField, NativeStruct } from "bdsx/nativeclass"; import { bool_t, CxxString, float32_t, int32_t, NativeType, uint64_as_float_t, uint8_t, void_t } from "bdsx/nativetype"; import { procHacker } from "bdsx/prochacker"; import { logger, TODO } from "../api/api_help"; -import path = require("path"); export const symcall = ((...args: any[]) => { if (!(symcall as any).cache) { @@ -49,7 +49,7 @@ export const daccess = (ptr: VoidPointer, type: T, offset = export namespace MCAPI { @nativeClass(0x1C) - export class AABB extends NativeClass { + export class AABB extends NativeStruct { @nativeField(Vec3) min: Vec3; @nativeField(Vec3) @@ -112,6 +112,9 @@ export namespace MCAPI { export namespace Mob { export const _hurt: (thiz: _Actor, source: ActorDamageSource, damage: number, knock: boolean, ignite: boolean) => boolean = symcall("?_hurt@Mob@@MEAA_NAEBVActorDamageSource@@M_N1@Z", bool_t, null, _Actor, ActorDamageSource, float32_t, bool_t, bool_t); } + export namespace MobEffect { + export const getResourceName: (thiz: _MobEffect) => string = symcall("?getResourceName@MobEffect@@QEBAAEBV?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@XZ", CxxString, null, _MobEffect); + } @nativeClass(null) export class NpcAction extends NativeClass { @nativeField(VoidPointer) @@ -452,6 +455,8 @@ export namespace LlAPI { return true; } export function getAvgPing(thiz: _Player) { + if (Actor.isSimulatedPlayer(thiz)) + return -1; return bedrockServer.rakPeer.GetAveragePing(thiz.getNetworkIdentifier().address); } export function getDeviceName(thiz: _Player) { @@ -494,11 +499,9 @@ export namespace LlAPI { return daccess(thiz, FillingContainer.ref(), 4192); } export function getRealName(thiz: _Player) { - if (Actor.isSimulatedPlayer(thiz)) { - return thiz.getName(); - } else { - return thiz.getCertificate().getIdentityName(); - } + if (Actor.isSimulatedPlayer(thiz)) + return daccess(thiz, CxxString, 2232); + return thiz.getCertificate().getIdentityName(); } export function giveItem(thiz: _Player, item: ItemStack) { if (!thiz.addItem(item)) { diff --git a/src/utils/money.ts b/src/utils/money.ts index 27d7938..b148038 100644 --- a/src/utils/money.ts +++ b/src/utils/money.ts @@ -1,6 +1,6 @@ import { events } from "bdsx/event"; import { bedrockServer } from "bdsx/launcher"; -import { LXL_Events } from "../api/event"; +import { LLSE_Events } from "../api/event"; import fs = require("fs"); import path = require("path"); @@ -63,7 +63,7 @@ export namespace LLMoney { const _isRealTrans = isRealTrans; isRealTrans = true; if (_isRealTrans) { - const cancelled = LXL_Events.onMoneyTrans.fire(from, to, val); + const cancelled = LLSE_Events.onMoneyTrans.fire(from, to, val); if (cancelled) { return false; } @@ -102,7 +102,7 @@ export namespace LLMoney { } export function Add(xuid: string, money: number) { money = ~~money; - const cancelled = LXL_Events.onMoneyAdd.fire(xuid, money); + const cancelled = LLSE_Events.onMoneyAdd.fire(xuid, money); if (cancelled) { return false; } @@ -112,7 +112,7 @@ export namespace LLMoney { } export function Reduce(xuid: string, money: number) { money = ~~money; - const cancelled = LXL_Events.onMoneyReduce.fire(xuid, money); + const cancelled = LLSE_Events.onMoneyReduce.fire(xuid, money); if (cancelled) { return false; } @@ -122,7 +122,7 @@ export namespace LLMoney { } export function Set(xuid: string, money: number) { money = ~~money; - const cancelled = LXL_Events.onMoneySet.fire(xuid, money); + const cancelled = LLSE_Events.onMoneySet.fire(xuid, money); if (cancelled) { return false; }