1
0
Fork 0

Fix mobs able to swim in plants

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

View File

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

View File

@ -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,
defaults to 1.1.
'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
in e.g. "air" or "default:water_source".
'fly_in' holds the node name or a table of node names in which the
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.
'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

View File

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

View File

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

View File

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

View File

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

View File

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