新增sendInventorySlotPacket接口
This commit is contained in:
Vendored
+10
@@ -1057,6 +1057,16 @@ interface Player {
|
||||
/** 槽位 */
|
||||
slot: number
|
||||
): Item;
|
||||
|
||||
/** (GMLIB)发送更新更新物品数据包 */
|
||||
sendInventorySlotPacket(
|
||||
/** 容器ID */
|
||||
containerId: number,
|
||||
/** 槽位 */
|
||||
slot: number,
|
||||
/** 物品 */
|
||||
item: Item
|
||||
): void;
|
||||
}
|
||||
|
||||
interface Entity {
|
||||
|
||||
+15
-2
@@ -331,7 +331,9 @@ const GMLIB_API = {
|
||||
/** 设置玩家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")
|
||||
getPlayerUIItem: ll.import("GMLIB_API", "getPlayerUIItem"),
|
||||
/** 更新玩家容器物品 @type {function(Player,number,number,Item):void} */
|
||||
sendInventorySlotPacket: ll.import("GMLIB_API","sendInventorySlotPacket")
|
||||
}
|
||||
|
||||
/** 静态悬浮字类列表 @type {Map<number,StaticFloatingText>} */
|
||||
@@ -2445,7 +2447,7 @@ LLSE_Player.prototype.setPlayerUIItem =
|
||||
* @param {Item} item 要设置的物品
|
||||
*/
|
||||
function (slot, item) {
|
||||
return GMLIB_API.setPlayerUIItem(this, slot, item);
|
||||
GMLIB_API.setPlayerUIItem(this, slot, item);
|
||||
}
|
||||
|
||||
LLSE_Player.prototype.getPlayerUIItem =
|
||||
@@ -2458,6 +2460,17 @@ LLSE_Player.prototype.getPlayerUIItem =
|
||||
return GMLIB_API.getPlayerUIItem(this, slot);
|
||||
}
|
||||
|
||||
LLSE_Player.prototype.sendInventorySlotPacket =
|
||||
/**
|
||||
* 发送更新更新物品数据包
|
||||
* @param {number} containerId 容器ID
|
||||
* @param {number} slot 格子槽位
|
||||
* @param {Item} item 物品对象
|
||||
*/
|
||||
function (containerId, slot, item) {
|
||||
GMLIB_API.sendInventorySlotPacket(this, containerId, slot, item);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
StaticFloatingText,
|
||||
DynamicFloatingText,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include "Global.h"
|
||||
#include "magic_enum.hpp"
|
||||
#include "mc/network/packet/InventorySlotPacket.h"
|
||||
#include <map>
|
||||
#include <regex>
|
||||
#include <vector>
|
||||
|
||||
bool isInteger(const std::string& str) {
|
||||
std::regex pattern("^[+-]?\\d+$");
|
||||
@@ -867,4 +871,11 @@ void Export_Compatibility_API() {
|
||||
RemoteCall::exportAs("GMLIB_API", "getPlayerUIItem", [](Player* player, int slot) -> ItemStack* {
|
||||
return const_cast<ItemStack*>(&player->getPlayerUIItem((PlayerUISlot)slot));
|
||||
});
|
||||
RemoteCall::exportAs(
|
||||
"GMLIB_API",
|
||||
"sendInventorySlotPacket",
|
||||
[](Player* player, int containerId, int slot, ItemStack* item) -> void {
|
||||
InventorySlotPacket((ContainerID)containerId, slot, *item).sendTo(*player);
|
||||
}
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user