From b9074ebe4788d0016a9fd7563b59816b6300c06d Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 14 Oct 2024 09:43:51 +0300 Subject: [PATCH] fix block.get_hitbox with non rotatable blocks --- src/logic/scripting/lua/libs/libblock.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/logic/scripting/lua/libs/libblock.cpp b/src/logic/scripting/lua/libs/libblock.cpp index 193c8520..df388fea 100644 --- a/src/logic/scripting/lua/libs/libblock.cpp +++ b/src/logic/scripting/lua/libs/libblock.cpp @@ -281,7 +281,13 @@ static int l_get_model(lua::State* L) { static int l_get_hitbox(lua::State* L) { if (auto def = require_block(L)) { - auto& hitbox = def->rt.hitboxes[lua::tointeger(L, 2)].at(0); + size_t rotation = lua::tointeger(L, 2); + if (def->rotatable) { + rotation %= def->rotations.MAX_COUNT; + } else { + rotation = 0; + } + auto& hitbox = def->rt.hitboxes[rotation].at(0); lua::createtable(L, 2, 0); lua::pushvec3(L, hitbox.min());