导出canDestroy,playerDestroy,canDestroyInCreative,canDestroySpecial接口

This commit is contained in:
子沐呀
2024-05-28 17:36:43 +08:00
Unverified
parent 8f9447bcdb
commit 78721df3f0
2 changed files with 40 additions and 1 deletions
+19
View File
@@ -1,4 +1,7 @@
#include "Global.h"
#include "mc/world/Pos.h"
#include "mc/world/level/BlockPos.h"
#include "mc/world/level/BlockSource.h"
#include <regex>
bool isInteger(const std::string& str) {
@@ -636,4 +639,20 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "getDestroyBlockSpeed", [](ItemStack const* item, Block const* block) -> float {
return item->getDestroySpeed(*block);
});
RemoteCall::exportAs(
"GMLIB_API",
"playerDestroyBlock",
[](Block const* block, std::pair<BlockPos, int> pos, Player* player) -> void {
return block->playerDestroy(*player, pos.first);
}
);
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyBlock", [](ItemStack const* item, Block const* block) -> bool {
return item->canDestroy(block);
});
RemoteCall::exportAs("GMLIB_API", "itemCanDestroyInCreative", [](ItemStack const* item) -> bool {
return item->getItem()->canDestroyInCreative();
});
RemoteCall::exportAs("GMLIB_API", "itemCanDestroySpecial", [](ItemStack const* item, Block const* block) -> bool {
return item->canDestroySpecial(*block);
});
}