新增4接口

- getItemCategoryName
- getItemCustomName
- getItemEffecName
- itemIsFood
This commit is contained in:
子沐呀
2024-07-19 02:30:14 +08:00
Unverified
parent c544569bd8
commit ed472f10d8
3 changed files with 79 additions and 8 deletions
+18 -6
View File
@@ -1034,6 +1034,15 @@ interface Player {
/** (GMLIB)获取玩家的rumtimeId */
getRuntimeId(): number;
/** (GMLIB)获取玩家饱食度 */
getHungry(): number;
/** (GMLIB)获取玩家盔甲覆盖百分比 */
getArmorCoverPercentage(): number;
/** (GMLIB)获取玩家盔甲值 */
getArmorValue(): number;
}
interface Entity {
@@ -1233,12 +1242,15 @@ interface Item {
blocks: string[]
): void;
/** (GMLIB)获取玩家饱食度 */
getHungry(): number;
/** 获取物品分类名称 */
getCategoryName(): string;
/** (GMLIB)获取玩家盔甲覆盖百分比 */
getArmorCoverPercentage(): number;
/** 获取物品的命名 */
getCustomName(): string;
/** (GMLIB)获取玩家盔甲值 */
getArmorValue(): number;
/** 获取物品的BUFF效果名称 */
getEffecName(): string;
/** 物品是否为食物 */
isFood(): boolean;
}
+45 -1
View File
@@ -319,7 +319,15 @@ const GMLIB_API = {
/** 获取玩家盔甲值 @type {function(Player):number} */
getPlayerArmorValue: ll.import("GMLIB_API", "getPlayerArmorValue"),
/** 获取实体主人的UniqueID @type {function(Entity):Entity} */
getEntityOwnerUniqueId: ll.import("GMLIB_API", "getEntityOwnerUniqueId")
getEntityOwnerUniqueId: ll.import("GMLIB_API", "getEntityOwnerUniqueId"),
/** 获取物品分类名称 @type {function(Item):string} */
getItemCategoryName: ll.import("GMLIB_API", "getItemCategoryName"),
/** 获取物品的命名 @type {function(Item):string} */
getItemCustomName: ll.import("GMLIB_API", "getItemCustomName"),
/** 获取物品BUFF效果名称 @type {function(Item):string} */
getItemEffecName: ll.import("GMLIB_API", "getItemEffecName"),
/** 物品是否为食物 @type {function(Item):boolean} */
itemIsFood: ll.import("GMLIB_API", "itemIsFood")
}
/** 静态悬浮字类列表 @type {Map<number,StaticFloatingText>} */
@@ -2390,6 +2398,42 @@ LLSE_Player.prototype.getEntityOwner =
return uniqueId === -1 ? null : Minecraft.getEntityFromUniqueId(uniqueId);
}
LLSE_Item.prototype.getCategoryName =
/**
* 获取物品分类名称
* @returns {string}
*/
function () {
return GMLIB_API.getItemCategoryName(this);
}
LLSE_Item.prototype.getCustomName =
/**
* 获取物品的命名
* @returns {string}
*/
function () {
return GMLIB_API.getItemCustomName(this);
}
LLSE_Item.prototype.getEffecName =
/**
* 获取物品的BUFF效果名称
* @returns {string}
*/
function () {
return GMLIB_API.getItemEffecName(this);
}
LLSE_Item.prototype.isFood =
/**
* 物品是否为食物
* @returns {boolean}
*/
function () {
return GMLIB_API.itemIsFood(this);
}
module.exports = {
StaticFloatingText,
DynamicFloatingText,
+15
View File
@@ -847,4 +847,19 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "getEntityOwnerUniqueId", [](Actor* entity) -> int64 {
return entity->getOwnerId().id;
});
RemoteCall::exportAs("GMLIB_API", "getItemCategoryName", [](ItemStack const* item) -> std::string {
return item->getCategoryName();
});
RemoteCall::exportAs("GMLIB_API", "getItemCustomName", [](ItemStack const* item) -> std::string {
return item->getCustomName();
});
RemoteCall::exportAs("GMLIB_API", "getItemEffecName", [](ItemStack const* item) -> std::string {
return item->getEffectName();
});
RemoteCall::exportAs("GMLIB_API", "itemIsFood", [](ItemStack const* item) -> bool {
if (auto itemDef = item->getItem()) {
return itemDef->isFood();
}
return false;
});
}