forked from mtcontrib/minetest-mod-snow
Prod snowballs when they are stuck
This commit is contained in:
parent
5b4e705055
commit
11364a550c
@ -137,14 +137,32 @@ function snow_snowball_ENTITY.on_step(self, dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.physical then
|
if self.physical then
|
||||||
local fell = self.object:getvelocity().y == 0
|
local vel = self.object:getvelocity()
|
||||||
|
local fell = vel.y == 0
|
||||||
if not fell then
|
if not fell then
|
||||||
|
if self.probably_stuck then
|
||||||
|
self.probably_stuck = nil
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
if self.probably_stuck
|
||||||
|
and vel.x == 0
|
||||||
|
and vel.z == 0 then
|
||||||
|
-- add a small velocity to move it from the corner
|
||||||
|
vel.x = math.random() - 0.5
|
||||||
|
vel.z = math.random() - 0.5
|
||||||
|
self.object:set_velocity(vel)
|
||||||
|
self.probably_stuck = nil
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local pos = vector.round(self.object:getpos())
|
local pos = vector.round(self.object:getpos())
|
||||||
if minetest.get_node(pos).name == "air" then
|
if minetest.get_node(pos).name == "air" then
|
||||||
pos.y = pos.y-1
|
pos.y = pos.y-1
|
||||||
if minetest.get_node(pos).name == "air" then
|
if minetest.get_node(pos).name == "air" then
|
||||||
|
if vel.x == 0
|
||||||
|
and vel.z == 0 then
|
||||||
|
self.probably_stuck = true
|
||||||
|
end
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user