make api compatible with minetesty 0.4 and 5.0 and also multicraft 2.0.3

* stupid tenplus1 does not care others only him. so i sustitute
 the crap of modernish using equivalent to vector.offset that is just
 movement to the collisionbox offset
* more on https://git.minetest.io/minetest-stuffs/minetest-wiki-minenux/src/branch/master/en/backporting/minetest-engine-api.md#vector-offset
* closes #108
main
mckaygerhard 2024-04-09 22:06:09 -04:00
parent a5fb5d0100
commit 03b478fcdd
1 changed files with 6 additions and 5 deletions

11
api.lua
View File

@ -1171,19 +1171,20 @@ end
function mob_class:is_inside(itemtable)
local cb
if self.object:get_properties() then
if not self.collisionbox then
if self.object:get_properties().collisionbox then
cb = self.object:get_properties().collisionbox
else
cb = self.collisionbox
return false
end
else
else
cb = self.collisionbox
end
local pos = self.object:get_pos()
local vo1 = {}
local nn = minetest.find_nodes_in_area(
vector.offset(pos, cb[1], cb[2], cb[3]),
vector.offset(pos, cb[4], cb[5], cb[6]), itemtable)
{x = pos.x + cb[1], y = pos.y + cb[2], z = pos.z + cb[3]},
{x = pos.x + cb[4], y = pos.y + cb[5], z = pos.z + cb[6]}, itemtable)
if nn and #nn > 0 then return true else return false end
end