增加4个接口

- getItemCanDestroy
- setItemCanDestroy
- getItemCanPlaceOn
- setItemCanPlaceOn
This commit is contained in:
子沐呀
2024-07-12 03:20:37 +08:00
Unverified
parent 374e5a29e0
commit b9d0900407
3 changed files with 91 additions and 1 deletions
+18
View File
@@ -1211,4 +1211,22 @@ interface Item {
/** 要设置的惩罚等级 */
cost: number
): void;
/** (GMLIB)获取冒险模式下能破坏的方块 */
getCanDestroy(): string[];
/** (GMLIB)设置冒险模式下能破坏的方块 */
setCanDestroy(
/** 能破坏的方块 */
blocks: string[]
): void;
/** (GMLIB)获取冒险模式下能放置在什么方块上 */
getCanPlaceOn(): string[];
/** (GMLIB)设置冒险模式下能放置在什么方块上 */
getCanPlaceOn(
/** 能放置的方块 */
blocks: string[]
): void;
}
+45 -1
View File
@@ -303,7 +303,15 @@ const GMLIB_API = {
/** 获取物品惩罚等级 @type {function(Item):number} */
getItemRepairCost: ll.import("GMLIB_API", "getItemRepairCost"),
/** 设置物品惩罚等级 @type {function(Item,number):void} */
setItemRepairCost: ll.import("GMLIB_API", "setItemRepairCost")
setItemRepairCost: ll.import("GMLIB_API", "setItemRepairCost"),
/** 获取物品冒险模式下可破坏的方块 @type {function(Item):Array.<string>} */
getItemCanDestroy: ll.import("GMLIB_API", "getItemCanDestroy"),
/** 设置物品冒险模式下可破坏的方块 @type {function(Item,Array.<string>):void} */
setItemCanDestroy: ll.import("GMLIB_API", "setItemCanDestroy"),
/** 获取物品冒险模式下能放置在什么方块上 @type {function(Item):Array.<string>} */
getItemCanPlaceOn: ll.import("GMLIB_API", "getItemCanPlaceOn"),
/** 设置物品冒险模式下能放置在什么方块上 @type {function(Item,Array.<string>):void} */
setItemCanPlaceOn: ll.import("GMLIB_API", "setItemCanPlaceOn")
}
/** 静态悬浮字类列表 @type {Map<number,StaticFloatingText>} */
@@ -2301,6 +2309,42 @@ LLSE_Item.prototype.setRepairCost =
return GMLIB_API.setItemRepairCost(this, cost);
}
LLSE_Item.prototype.getCanDestroy =
/**
* 获取冒险模式下能破坏的方块
* @returns {Array.<string>} 能破坏的方块
*/
function () {
return GMLIB_API.getItemCanDestroy(this);
}
LLSE_Item.prototype.setCanDestroy =
/**
* 设置冒险模式下能破坏的方块
* @param {Array.<string>} blocks 能破坏的方块
*/
function (blocks) {
GMLIB_API.setItemCanDestroy(this, blocks);
}
LLSE_Item.prototype.getCanPlaceOn =
/**
* 获取冒险模式下能放置在什么方块上
* @returns {Array.<string>} 能放置的方块
*/
function () {
return GMLIB_API.getItemCanPlaceOn(this);
}
LLSE_Item.prototype.setCanPlaceOn =
/**
* 设置冒险模式下能放置在什么方块上
* @param {Array.<string>} blocks 能放置的方块
*/
function (blocks) {
GMLIB_API.setItemCanPlaceOn(this, blocks);
}
module.exports = {
StaticFloatingText,
DynamicFloatingText,
+28
View File
@@ -804,4 +804,32 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "setItemRepairCost", [](ItemStack const* item, int cost) -> void {
((ItemStackBase*)item)->setRepairCost(cost);
});
RemoteCall::exportAs("GMLIB_API", "getItemCanDestroy", [](ItemStack const* item) -> std::vector<std::string> {
std::vector<std::string> result = {};
for (auto& block : ((GMLIB_ItemStack*)item)->getCanDestroy()) {
result.push_back(block->getTypeName());
}
return result;
});
RemoteCall::exportAs(
"GMLIB_API",
"setItemCanDestroy",
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
((GMLIB_ItemStack*)item)->setCanDestroy(blocks);
}
);
RemoteCall::exportAs("GMLIB_API", "getItemCanPlaceOn", [](ItemStack const* item) -> std::vector<std::string> {
std::vector<std::string> result = {};
for (auto& block : ((GMLIB_ItemStack*)item)->getCanPlaceOn()) {
result.push_back(block->getTypeName());
}
return result;
});
RemoteCall::exportAs(
"GMLIB_API",
"setItemCanPlaceOn",
[](ItemStack const* item, std::vector<std::string> blocks) -> void {
((GMLIB_ItemStack*)item)->setCanPlaceOn(blocks);
}
);
}