1
0
Fork 0

Fix items stop flowing at last liquid node

This commit is contained in:
Wuzzy 2017-02-16 19:15:59 +01:00
parent 6aa67cd518
commit 515343b0df
1 changed files with 20 additions and 21 deletions

View File

@ -374,23 +374,22 @@ core.register_entity(":__builtin:item", {
local get_flowing_dir = function(self) local get_flowing_dir = function(self)
local pos = self.object:getpos() local pos = self.object:getpos()
local param2 = minetest.get_node(pos).param2 local param2 = minetest.get_node(pos).param2
for i,d in ipairs({-1, 1, -1, 1}) do -- Search for a liquid source, or a flowing liquid node higher than
if i<3 then -- the item's position in the 4 cardinal directions
pos.x = pos.x+d local posses = {
else {x=-1, y=0, z=0},
pos.z = pos.z+d {x=1, y=0, z=0},
end {x=0, y=0, z=-1},
{x=0, y=0, z=1},
local name = minetest.get_node(pos).name }
local par2 = minetest.get_node(pos).param2 for _, p in pairs(posses) do
if name == "mcl_core:water_flowing" and par2 < param2 then local realpos = vector.add(pos, p)
return pos local name = minetest.get_node(realpos).name
end local par2 = minetest.get_node(realpos).param2
if name == "mcl_core:water_source" or (name == "mcl_core:water_flowing" and par2 > param2) then
if i<3 then -- Node found! Since we looked upwards, the flowing
pos.x = pos.x-d -- direction is the *opposite* of what we've found
else return vector.multiply(p, -1)
pos.z = pos.z-d
end end
end end
end end
@ -400,16 +399,16 @@ core.register_entity(":__builtin:item", {
local v = self.object:getvelocity() local v = self.object:getvelocity()
-- Minecraft Wiki: Flowing speed is "about 1.39 meters per second" -- Minecraft Wiki: Flowing speed is "about 1.39 meters per second"
local f = 1.39 local f = 1.39
if vec and vec.x-p.x > 0 then if vec.x > 0 then
self.object:setacceleration({x = 0, y = 0, z = 0}) self.object:setacceleration({x = 0, y = 0, z = 0})
self.object:setvelocity({x = f, y = -0.22, z = 0}) self.object:setvelocity({x = f, y = -0.22, z = 0})
elseif vec and vec.x-p.x < 0 then elseif vec.x < 0 then
self.object:setacceleration({x = 0, y = 0, z = 0}) self.object:setacceleration({x = 0, y = 0, z = 0})
self.object:setvelocity({x = -f, y = -0.22, z = 0}) self.object:setvelocity({x = -f, y = -0.22, z = 0})
elseif vec and vec.z-p.z > 0 then elseif vec.z > 0 then
self.object:setacceleration({x = 0, y = 0, z = 0}) self.object:setacceleration({x = 0, y = 0, z = 0})
self.object:setvelocity({x = 0, y = -0.22, z = f}) self.object:setvelocity({x = 0, y = -0.22, z = f})
elseif vec and vec.z-p.z < 0 then elseif vec.z < 0 then
self.object:setacceleration({x = 0, y = 0, z = 0}) self.object:setacceleration({x = 0, y = 0, z = 0})
self.object:setvelocity({x = 0, y = -0.22, z = -f}) self.object:setvelocity({x = 0, y = -0.22, z = -f})
end end