diff --git a/lib/GMLIB_API-JS.d.ts b/lib/GMLIB_API-JS.d.ts index 18b5fc1..8dfeb69 100644 --- a/lib/GMLIB_API-JS.d.ts +++ b/lib/GMLIB_API-JS.d.ts @@ -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; } \ No newline at end of file diff --git a/lib/GMLIB_API-JS.js b/lib/GMLIB_API-JS.js index 863e5cc..6beaeac 100644 --- a/lib/GMLIB_API-JS.js +++ b/lib/GMLIB_API-JS.js @@ -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.} */ + getItemCanDestroy: ll.import("GMLIB_API", "getItemCanDestroy"), + /** 设置物品冒险模式下可破坏的方块 @type {function(Item,Array.):void} */ + setItemCanDestroy: ll.import("GMLIB_API", "setItemCanDestroy"), + /** 获取物品冒险模式下能放置在什么方块上 @type {function(Item):Array.} */ + getItemCanPlaceOn: ll.import("GMLIB_API", "getItemCanPlaceOn"), + /** 设置物品冒险模式下能放置在什么方块上 @type {function(Item,Array.):void} */ + setItemCanPlaceOn: ll.import("GMLIB_API", "setItemCanPlaceOn") } /** 静态悬浮字类列表 @type {Map} */ @@ -2301,6 +2309,42 @@ LLSE_Item.prototype.setRepairCost = return GMLIB_API.setItemRepairCost(this, cost); } +LLSE_Item.prototype.getCanDestroy = + /** + * 获取冒险模式下能破坏的方块 + * @returns {Array.} 能破坏的方块 + */ + function () { + return GMLIB_API.getItemCanDestroy(this); + } + +LLSE_Item.prototype.setCanDestroy = + /** + * 设置冒险模式下能破坏的方块 + * @param {Array.} blocks 能破坏的方块 + */ + function (blocks) { + GMLIB_API.setItemCanDestroy(this, blocks); + } + +LLSE_Item.prototype.getCanPlaceOn = + /** + * 获取冒险模式下能放置在什么方块上 + * @returns {Array.} 能放置的方块 + */ + function () { + return GMLIB_API.getItemCanPlaceOn(this); + } + +LLSE_Item.prototype.setCanPlaceOn = + /** + * 设置冒险模式下能放置在什么方块上 + * @param {Array.} blocks 能放置的方块 + */ + function (blocks) { + GMLIB_API.setItemCanPlaceOn(this, blocks); + } + module.exports = { StaticFloatingText, DynamicFloatingText, diff --git a/src/CompatibilityApi.cpp b/src/CompatibilityApi.cpp index 4ddfb02..063af08 100644 --- a/src/CompatibilityApi.cpp +++ b/src/CompatibilityApi.cpp @@ -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::vector 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 blocks) -> void { + ((GMLIB_ItemStack*)item)->setCanDestroy(blocks); + } + ); + RemoteCall::exportAs("GMLIB_API", "getItemCanPlaceOn", [](ItemStack const* item) -> std::vector { + std::vector 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 blocks) -> void { + ((GMLIB_ItemStack*)item)->setCanPlaceOn(blocks); + } + ); } \ No newline at end of file