diff --git a/lib/GMLIB_API-JS.d.ts b/lib/GMLIB_API-JS.d.ts index 2dbaa2d..7aa1c4a 100644 --- a/lib/GMLIB_API-JS.d.ts +++ b/lib/GMLIB_API-JS.d.ts @@ -1043,6 +1043,20 @@ interface Player { /** (GMLIB)获取玩家盔甲值 */ getArmorValue(): number; + + /** (GMLIB)设置玩家UI栏物品 */ + setPlayerUIItem( + /** 槽位 */ + slot: number, + /** 物品 */ + item: Item + ): void; + + /** (GMLIB)获取玩家UI栏物品 */ + setPlayerUIItem( + /** 槽位 */ + slot: number + ): Item; } interface Entity { diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index 86a58f7..af2dea8 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -327,7 +327,11 @@ const GMLIB_API = { /** 获取物品BUFF效果名称 @type {function(Item):string} */ getItemEffecName: ll.import("GMLIB_API", "getItemEffecName"), /** 物品是否为食物 @type {function(Item):boolean} */ - itemIsFood: ll.import("GMLIB_API", "itemIsFood") + itemIsFood: ll.import("GMLIB_API", "itemIsFood"), + /** 设置玩家UI栏物品 @type {function(Player,number,Item):void} */ + setPlayerUIItem: ll.import("GMLIB_API", "setPlayerUIItem"), + /** 获取玩家UI栏物品 @type {function(Player,number):Item} */ + getPlayerUIItem: ll.import("GMLIB_API", "getPlayerUIItem") } /** 静态悬浮字类列表 @type {Map} */ @@ -2434,6 +2438,26 @@ LLSE_Item.prototype.isFood = return GMLIB_API.itemIsFood(this); } +LLSE_Player.prototype.setPlayerUIItem = + /** + * 设置玩家UI栏物品 + * @param {number} slot 格子槽位 + * @param {Item} item 要设置的物品 + */ + function (slot, item) { + return GMLIB_API.setPlayerUIItem(this, slot, item); + } + +LLSE_Player.prototype.setPlayerUIItem = + /** + * 获取玩家UI栏物品 + * @param {number} slot 格子槽位 + * @returns {Item} 物品对象 + */ + function (slot) { + return GMLIB_API.getPlayerUIItem(this, slot); + } + module.exports = { StaticFloatingText, DynamicFloatingText, diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index 557c5d7..02a607a 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -862,4 +862,10 @@ void Export_Compatibility_API() { } return false; }); + RemoteCall::exportAs("GMLIB_API", "setPlayerUIItem", [](Player* player, int slot, ItemStack const* item) -> void { + player->setPlayerUIItem((PlayerUISlot)slot, *item); + }); + RemoteCall::exportAs("GMLIB_API", "getPlayerUIItem", [](Player* player, int slot) -> void { + player->getPlayerUIItem((PlayerUISlot)slot); + }); } \ No newline at end of file