feat: add some methods to block
This commit is contained in:
+26
-1
@@ -117,7 +117,12 @@ const GMLIB_API = {
|
||||
readNbtFromFile: ll.import("GMLIB_API", "readNbtFromFile"),
|
||||
saveNbtToFile: ll.import("GMLIB_API", "saveNbtToFile"),
|
||||
getBlockDestroySpeed: ll.import("GMLIB_API", "getBlockDestroySpeed"),
|
||||
getDestroyBlockSpeed: ll.import("GMLIB_API", "getDestroyBlockSpeed")
|
||||
getDestroyBlockSpeed: ll.import("GMLIB_API", "getDestroyBlockSpeed"),
|
||||
playerDestroyBlock: ll.import("GMLIB_API", "playerDestroyBlock"),
|
||||
itemCanDestroyBlock: ll.import("GMLIB_API", "itemCanDestroyBlock"),
|
||||
itemCanDestroyInCreative: ll.import("GMLIB_API", "itemCanDestroyInCreative"),
|
||||
itemCanDestroySpecial: ll.import("GMLIB_API", "itemCanDestroySpecial"),
|
||||
blockCanDropWithAnyTool: ll.import("GMLIB_API", "blockCanDropWithAnyTool")
|
||||
}
|
||||
|
||||
const mStaticFloatingTextMap = new Map();
|
||||
@@ -960,6 +965,26 @@ LLSE_Item.prototype.getDestroyBlockSpeed = function (block) {
|
||||
return GMLIB_API.getDestroyBlockSpeed(this, block);
|
||||
}
|
||||
|
||||
LLSE_Block.prototype.playerDestroy = function (player) {
|
||||
GMLIB_API.playerDestroyBlock(this, this.pos, player);
|
||||
}
|
||||
|
||||
LLSE_Item.prototype.canDestroy = function (block) {
|
||||
return GMLIB_API.itemCanDestroyBlock(this, block);
|
||||
}
|
||||
|
||||
LLSE_Item.prototype.canDestroyInCreative = function () {
|
||||
return GMLIB_API.itemCanDestroyInCreative(this);
|
||||
}
|
||||
|
||||
LLSE_Item.prototype.canDestroySpecial = function (block) {
|
||||
return GMLIB_API.itemCanDestroySpecial(this, block);
|
||||
}
|
||||
|
||||
LLSE_Block.prototype.canDropWithAnyTool = function () {
|
||||
return GMLIB_API.blockCanDropWithAnyTool(this);
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
StaticFloatingText,
|
||||
DynamicFloatingText,
|
||||
|
||||
@@ -637,4 +637,23 @@ 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);
|
||||
});
|
||||
RemoteCall::exportAs("GMLIB_API", "blockCanDropWithAnyTool", [](Block const* block) -> bool {
|
||||
return block->canDropWithAnyTool();
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user