fix for issue #2

This commit is contained in:
superfloh247 2021-06-03 14:51:35 +02:00 committed by GitHub
parent ef2d61c035
commit d7db2cd111
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -417,40 +417,42 @@ function better_fauna.hq_fowl_breed(self, prty)
if mobkit.is_queue_empty_low(self) then if mobkit.is_queue_empty_low(self) then
local pos = mobkit.get_stand_pos(self) local pos = mobkit.get_stand_pos(self)
local tpos = mate:get_pos() local tpos = mate:get_pos()
local dist = vec_dist(pos, tpos) - math.abs(hitbox(self)[4]) if tpos ~= nil and tpos.x ~= nil and tpos.y ~= nil and tpos.z ~= nil then
if dist > 1.5 then local dist = vec_dist(pos, tpos) - math.abs(hitbox(self)[4])
speed_factor = 0.5 if dist > 1.5 then
else speed_factor = 0.5
speed_factor = 0.1 else
end speed_factor = 0.1
mob_core.goto_next_waypoint(self, tpos, speed_factor) end
if dist < 1.75 then mob_core.goto_next_waypoint(self, tpos, speed_factor)
self.breeding_time = self.breeding_time + 1 if dist < 1.75 then
end self.breeding_time = self.breeding_time + 1
if self.breeding_time >= 2 end
or mate:get_luaentity().breeding_time >= 2 then if self.breeding_time >= 2
if self.gender == "female" then or mate:get_luaentity().breeding_time >= 2 then
minetest.add_particlespawner({ if self.gender == "female" then
amount = 6, minetest.add_particlespawner({
time = 0.25, amount = 6,
minpos = {x = pos.x - 7/16, y = pos.y - 5/16, z = pos.z - 7/16}, time = 0.25,
maxpos = {x = pos.x + 7/16, y = pos.y - 5/16, z = pos.z + 7/16}, minpos = {x = pos.x - 7/16, y = pos.y - 5/16, z = pos.z - 7/16},
minvel = vector.new(-1, 2, -1), maxpos = {x = pos.x + 7/16, y = pos.y - 5/16, z = pos.z + 7/16},
maxvel = vector.new(1, 5, 1), minvel = vector.new(-1, 2, -1),
minacc = vector.new(0, -9.81, 0), maxvel = vector.new(1, 5, 1),
maxacc = vector.new(0, -9.81, 0), minacc = vector.new(0, -9.81, 0),
collisiondetection = true, maxacc = vector.new(0, -9.81, 0),
texture = "better_fauna_egg_fragment.png", collisiondetection = true,
}) texture = "better_fauna_egg_fragment.png",
mob_core.spawn_child(pos, self.name) })
mob_core.spawn_child(pos, self.name)
end
self.breeding = false
self.breeding_time = 0
self.breeding_cooldown = 300
mobkit.remember(self, "breeding", self.breeding)
mobkit.remember(self, "breeding_time", self.breeding_time)
mobkit.remember(self, "breeding_cooldown", self.breeding_cooldown)
return true
end end
self.breeding = false
self.breeding_time = 0
self.breeding_cooldown = 300
mobkit.remember(self, "breeding", self.breeding)
mobkit.remember(self, "breeding_time", self.breeding_time)
mobkit.remember(self, "breeding_cooldown", self.breeding_cooldown)
return true
end end
end end
end end
@ -461,42 +463,44 @@ function better_fauna.hq_eat(self, prty)
local func = function(self) local func = function(self)
local pos = mobkit.get_stand_pos(self) local pos = mobkit.get_stand_pos(self)
local under = vector.new(pos.x, pos.y - 1, pos.z) local under = vector.new(pos.x, pos.y - 1, pos.z)
for _, node in ipairs(self.consumable_nodes) do if self.consumable_nodes ~= nil then
if node.name == minetest.get_node(under).name then for _, node in ipairs(self.consumable_nodes) do
minetest.set_node(under, {name = node.replacement}) if node.name == minetest.get_node(under).name then
local def = minetest.registered_nodes[node.name] minetest.set_node(under, {name = node.replacement})
local texture = def.tiles[1] local def = minetest.registered_nodes[node.name]
texture = texture .. "^[resize:8x8" local texture = def.tiles[1]
minetest.add_particlespawner({ texture = texture .. "^[resize:8x8"
amount = 6, minetest.add_particlespawner({
time = 0.1, amount = 6,
minpos = vector.new( time = 0.1,
pos.x - 0.5, minpos = vector.new(
pos.y + 0.1, pos.x - 0.5,
pos.z - 0.5 pos.y + 0.1,
), pos.z - 0.5
maxpos = vector.new( ),
pos.x + 0.5, maxpos = vector.new(
pos.y + 0.1, pos.x + 0.5,
pos.z + 0.5 pos.y + 0.1,
), pos.z + 0.5
minvel = {x=-1, y=1, z=-1}, ),
maxvel = {x=1, y=2, z=1}, minvel = {x=-1, y=1, z=-1},
minacc = {x=0, y=-5, z=0}, maxvel = {x=1, y=2, z=1},
maxacc = {x=0, y=-9, z=0}, minacc = {x=0, y=-5, z=0},
minexptime = 1, maxacc = {x=0, y=-9, z=0},
maxexptime = 1, minexptime = 1,
minsize = 1, maxexptime = 1,
maxsize = 2, minsize = 1,
collisiondetection = true, maxsize = 2,
vertical = false, collisiondetection = true,
texture = texture, vertical = false,
}) texture = texture,
self.gotten = false })
mobkit.remember(self, "gotten", self.gotten) self.gotten = false
return true mobkit.remember(self, "gotten", self.gotten)
else return true
return true else
return true
end
end end
end end
end end