Fix mobs able to swim in plants

This commit is contained in:
Wuzzy 2020-01-30 16:52:07 +01:00
parent 834c8cbc3a
commit 61e148ac2e
7 changed files with 18 additions and 26 deletions

@ -344,27 +344,22 @@ local flight_check = function(self)
if not def then return false end -- nil check if not def then return false end -- nil check
if type(self.fly_in) == "string" local fly_in
and nod == self.fly_in then if type(self.fly_in) == "string" then
fly_in = { self.fly_in }
return true
elseif type(self.fly_in) == "table" then elseif type(self.fly_in) == "table" then
fly_in = self.fly_in
for _,fly_in in pairs(self.fly_in) do else
return false
if nod == fly_in then
return true
end
end
end end
-- stops mobs getting stuck inside stairs and plantlike nodes for _,checknode in pairs(fly_in) do
if def.drawtype ~= "airlike" if nod == checknode then
and def.drawtype ~= "liquid" return true
and def.drawtype ~= "flowingliquid" then elseif checknode == "__airlike" and def.walkable == false and
return true (def.liquidtype == "none" or minetest.get_item_group(nod, "fake_liquid") == 1) then
return true
end
end end
return false return false
@ -3173,7 +3168,7 @@ minetest.register_entity(name, {
type = def.type, type = def.type,
attack_type = def.attack_type, attack_type = def.attack_type,
fly = def.fly, fly = def.fly,
fly_in = def.fly_in or "air", fly_in = def.fly_in or {"air", "__airlike"},
owner = def.owner or "", owner = def.owner or "",
order = def.order or "", order = def.order or "",
on_die = def.on_die, on_die = def.on_die,

@ -52,8 +52,10 @@ functions needed for the mob to work properly which contains the following:
'stepheight' height of a block that your mob can easily walk up onto, 'stepheight' height of a block that your mob can easily walk up onto,
defaults to 1.1. defaults to 1.1.
'fly' when true allows your mob to fly around instead of walking. 'fly' when true allows your mob to fly around instead of walking.
'fly_in' holds the node name that the mob flies (or swims) around 'fly_in' holds the node name or a table of node names in which the
in e.g. "air" or "default:water_source". mob flies (or swims) around in. The special name
'__airlike' stands for all nodes with 'walkable=false'
that are not liquids
'runaway' if true causes animals to turn and run away when hit. 'runaway' if true causes animals to turn and run away when hit.
'view_range' how many nodes in distance the mob can see a player. 'view_range' how many nodes in distance the mob can see a player.
'damage' how many health points the mob does to a player or another 'damage' how many health points the mob does to a player or another

@ -44,7 +44,6 @@ mobs:register_mob("mobs_mc:bat", {
view_range = 16, view_range = 16,
fly = true, fly = true,
fly_in = "air",
}) })

@ -34,7 +34,6 @@ mobs:register_mob("mobs_mc:enderdragon", {
jump_height = 14, jump_height = 14,
stepheight = 1.2, stepheight = 1.2,
fly = true, fly = true,
fly_in = {"air"},
dogshoot_switch = 1, dogshoot_switch = 1,
dogshoot_count_max =5, dogshoot_count_max =5,
dogshoot_count2_max = 5, dogshoot_count2_max = 5,

@ -66,7 +66,6 @@ mobs:register_mob("mobs_mc:ghast", {
jump_height = 4, jump_height = 4,
floats=1, floats=1,
fly = true, fly = true,
fly_in = {"air"},
}) })

@ -52,7 +52,6 @@ mobs:register_mob("mobs_mc:parrot", {
floats = 1, floats = 1,
physical = true, physical = true,
fly = true, fly = true,
fly_in = {"air"},
fear_height = 4, fear_height = 4,
view_range = 16, view_range = 16,
follow = mobs_mc.follow.parrot, follow = mobs_mc.follow.parrot,

@ -85,7 +85,6 @@ mobs:register_mob("mobs_mc:vex", {
end end
end, end,
fly = true, fly = true,
fly_in = {"air"},
}) })