diff --git a/lib/GMLIB_API-JS.d.ts b/lib/GMLIB_API-JS.d.ts index 67beb3d..d08a6e3 100644 --- a/lib/GMLIB_API-JS.d.ts +++ b/lib/GMLIB_API-JS.d.ts @@ -785,6 +785,7 @@ declare class JsonConfig { ): void; } +/** JSON语言文件 */ declare class JsonLanguage extends JsonConfig { /** 创建或打开一个 Json 语言文件 */ constructor( @@ -803,6 +804,7 @@ declare class JsonLanguage extends JsonConfig { ): string; } +/** JSON版翻译类 */ declare class JsonI18n { /** 加载翻译数据目录 */ constructor( @@ -895,6 +897,7 @@ declare class Version { static getGmlibVersion(): Version; } +/** 翻译API类 */ declare class I18nAPI { private constructor(); @@ -955,6 +958,7 @@ declare class I18nAPI { ): void; } +/** 玩家信息存储类 */ declare class UserCache { private constructor(); @@ -1020,7 +1024,7 @@ interface Player { /** (GMLIB)清除玩家重生点 */ clearSpawnPoint(): void; - /** 丢出玩家物品 */ + /** (GMLIB)丢出玩家物品 */ dropItem( /** 物品对象 */ item: Item, @@ -1144,10 +1148,10 @@ interface Item { block: Block ): boolean; - /** 获取物品可以拥有的附魔 */ + /** (GMLIB)获取物品可以拥有的附魔 */ getLegalEnchants(): string[] - /** 添加附魔 */ + /** (GMLIB)添加附魔 */ applyEnchant( /** 附魔的命名空间 */ typeName: string, @@ -1157,18 +1161,45 @@ interface Item { allowNonVanilla: boolean | null ): boolean; - /** 删除所有附魔 */ + /** (GMLIB)删除所有附魔 */ removeEnchants(): void; - /** 判断是否拥有附魔 */ + /** (GMLIB)判断是否拥有附魔 */ hasEnchant( /** 附魔的命名空间 */ typeName: string ): boolean; - /** 获取附魔等级 */ + /** (GMLIB)获取附魔等级 */ getEnchantLevel( /** 附魔的命名空间 */ typeName: string ): number; + + /** (GMLIB)物品是否拥有不可破坏标签 */ + isUnbreakable(): boolean; + + /** (GMLIB)设置物品不可破坏标签 */ + setUnbreakable( + /** 是否不可破坏 */ + unbreakable: boolean + ): void; + + /** (GMLIB)物品是否拥有死亡不掉落标签 */ + getShouldKeepOnDeath(): boolean; + + /** (GMLIB)设置物品死亡不掉落标签 */ + setShouldKeepOnDeath( + /** 物品是否死亡不掉落 */ + value: boolean + ): void; + + /** (GMLIB)获取物品的锁定模式 0:无 1:锁定在格子里 2:锁定在背包里 */ + getItemLockMode(): 0 | 1 | 2; + + /** (GMLIB)设置物品的锁定模式 0:无 1:锁定在格子里 2:锁定在背包里 */ + setItemLockMode( + /** 锁定模式 */ + mode: 0 | 1 | 2 + ): void; } \ No newline at end of file diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index ce4deef..fc70b8a 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -289,7 +289,19 @@ const GMLIB_API = { /** 获取实体的RuntimeId @type {function(Entity):number} */ getEntityRuntimeId: ll.import("GMLIB_API", "getEntityRuntimeId"), /** 获取实体命名 @type {function(Entity):string} */ - getEntityNameTag: ll.import("GMLIB_API", "getEntityNameTag") + getEntityNameTag: ll.import("GMLIB_API", "getEntityNameTag"), + /** 物品是否有不可破坏标签 @type {function(Item):boolean} */ + ItemisUnbreakable: ll.import("GMLIB_API", "ItemisUnbreakable"), + /** 设置物品不可破坏标签 @type {function(Item,boolean):void} */ + setItemUnbreakable: ll.import("GMLIB_API", "setItemUnbreakable"), + /** 物品是否死亡不会掉落 @type {function(Item):boolean} */ + getItemShouldKeepOnDeath: ll.import("GMLIB_API", "getItemShouldKeepOnDeath"), + /** 设置物品死亡不掉落 @type {function(Item,boolean):void} */ + setItemShouldKeepOnDeath: ll.import("GMLIB_API", "setItemShouldKeepOnDeath"), + /** 获取物品锁定模式 @type {function(Item):number} */ + getItemLockMode: ll.import("GMLIB_API", "getItemLockMode"), + /** 设置物品锁定模式 @type {function(Item,number):void} */ + setItemLockMode: ll.import("GMLIB_API", "setItemLockMode") } /** 静态悬浮字类列表 @type {Map} */ @@ -2215,6 +2227,60 @@ LLSE_Entity.prototype.getNameTag = return GMLIB_API.getEntityNameTag(this); } +LLSE_Item.prototype.isUnbreakable = + /** + * 物品是否拥有不可破坏标签 + * @returns {boolean} 是否拥有 + */ + function () { + return GMLIB_API.ItemisUnbreakable(this); + } + +LLSE_Item.prototype.setUnbreakable = + /** + * 设置物品不可破坏标签 + * @param {boolean} value 是否不可破坏 + */ + function (value) { + GMLIB_API.setItemUnbreakable(this, value); + } + +LLSE_Item.prototype.getShouldKeepOnDeath = + /** + * 物品是否拥有死亡不掉落标签 + * @returns {boolean} 物品是否拥有死亡不掉落标签 + */ + function () { + return GMLIB_API.getItemShouldKeepOnDeath(this); + } + +LLSE_Item.prototype.setShouldKeepOnDeath = + /** + * 设置物品死亡不掉落标签 + * @param {boolean} value 物品是否死亡不掉落 + */ + function (value) { + GMLIB_API.setItemShouldKeepOnDeath(this, value); + } + +LLSE_Item.prototype.getItemLockMode = + /** + * 获取物品的锁定模式 + * @returns {0|1|2} 锁定的模式 0:无 1:锁定在格子里 2:锁定在背包里 + */ + function () { + return GMLIB_API.getItemLockMode(this) + } + +LLSE_Item.prototype.setItemLockMode = + /** + * 设置物品的锁定模式 + * @param {0|1|2} mode 锁定的模式 0:无 1:锁定在格子里 2:锁定在背包里 + */ + function (mode) { + GMLIB_API.setItemLockMode(this, mode); + } + module.exports = { StaticFloatingText, DynamicFloatingText, diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index f90995a..56ccdd8 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -780,4 +780,22 @@ void Export_Compatibility_API() { RemoteCall::exportAs("GMLIB_API", "getEntityNameTag", [](Actor* entity) -> std::string { return entity->getNameTag(); }); + RemoteCall::exportAs("GMLIB_API", "ItemisUnbreakable", [](ItemStack const* item) -> bool { + return ((GMLIB_ItemStack*)item)->isUnbreakable(); + }); + RemoteCall::exportAs("GMLIB_API", "setItemUnbreakable", [](ItemStack const* item, bool value) -> void { + ((GMLIB_ItemStack*)item)->setUnbreakable(value); + }); + RemoteCall::exportAs("GMLIB_API", "getItemShouldKeepOnDeath", [](ItemStack const* item) -> bool { + return ((GMLIB_ItemStack*)item)->getShouldKeepOnDeath(); + }); + RemoteCall::exportAs("GMLIB_API", "setItemShouldKeepOnDeath", [](ItemStack const* item, bool value) -> void { + ((GMLIB_ItemStack*)item)->setShouldKeepOnDeath(true); + }); + RemoteCall::exportAs("GMLIB_API", "getItemLockMode", [](ItemStack const* item) -> int { + return (int)((GMLIB_ItemStack*)item)->getItemLockMode(); + }); + RemoteCall::exportAs("GMLIB_API", "setItemLockMode", [](ItemStack const* item, int value) -> void { + ((GMLIB_ItemStack*)item)->setItemLockMode((ItemLockMode)value); + }); } \ No newline at end of file