feat: add playerWillDestroy,attack,pullInEntity

This commit is contained in:
子沐呀
2024-05-31 18:41:49 +08:00
Unverified
parent 28be308aba
commit 0872c064bb
2 changed files with 26 additions and 1 deletions
+16 -1
View File
@@ -123,7 +123,10 @@ const GMLIB_API = {
itemCanDestroyInCreative: ll.import("GMLIB_API", "itemCanDestroyInCreative"), itemCanDestroyInCreative: ll.import("GMLIB_API", "itemCanDestroyInCreative"),
itemCanDestroySpecial: ll.import("GMLIB_API", "itemCanDestroySpecial"), itemCanDestroySpecial: ll.import("GMLIB_API", "itemCanDestroySpecial"),
blockCanDropWithAnyTool: ll.import("GMLIB_API", "blockCanDropWithAnyTool"), blockCanDropWithAnyTool: ll.import("GMLIB_API", "blockCanDropWithAnyTool"),
blockIsAlwaysDestroyable: ll.import("GMLIB_API", "blockIsAlwaysDestroyable") blockIsAlwaysDestroyable: ll.import("GMLIB_API", "blockIsAlwaysDestroyable"),
blockPlayerWillDestroy: ll.import("GMLIB_API", "blockPlayerWillDestroy"),
playerAttack: ll.import("GMLIB_API", "playerAttack"),
playerPullInEntity: ll.import("GMLIB_API", "playerPullInEntity")
} }
const FloatingTextList = []; const FloatingTextList = [];
@@ -1003,6 +1006,18 @@ LLSE_Block.prototype.isAlwaysDestroyable = function () {
return GMLIB_API.blockIsAlwaysDestroyable(this); return GMLIB_API.blockIsAlwaysDestroyable(this);
} }
LLSE_Block.prototype.playerWillDestroy = function (player) {
return GMLIB_API.blockPlayerWillDestroy(this, player, this.pos);
}
LLSE_Player.prototype.attack = function (entity) {
return GMLIB_API.playerAttack(this, entity);
}
LLSE_Player.prototype.pullInEntity = function (entity) {
return GMLIB_API.playerPullInEntity(this, entity);
}
module.exports = { module.exports = {
StaticFloatingText, StaticFloatingText,
DynamicFloatingText, DynamicFloatingText,
+10
View File
@@ -658,4 +658,14 @@ void Export_Compatibility_API() {
RemoteCall::exportAs("GMLIB_API", "blockIsAlwaysDestroyable", [](Block const* block) -> bool { RemoteCall::exportAs("GMLIB_API", "blockIsAlwaysDestroyable", [](Block const* block) -> bool {
return block->getMaterial().isAlwaysDestroyable(); return block->getMaterial().isAlwaysDestroyable();
}); });
RemoteCall::exportAs(
"GMLIB_API",
"blockPlayerWillDestroy",
[](Block const* block, Player* player, std::pair<BlockPos, int> pos) -> bool {
return block->playerWillDestroy(*player, pos.first);
}
);
RemoteCall::exportAs("GMLIB_API", "playerAttack", [](Player* player, Actor* entity) -> bool {
return player->attack(*entity, ActorDamageCause::EntityAttack);
});
} }