From ddbc3353a25eaeb110b862c6afb1e4fb93b9fb29 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 02:44:39 -0300 Subject: [PATCH 01/16] Change item on flowing water physics adding momentum and drag (experimental) --- mods/ENTITIES/mcl_item_entity/init.lua | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 678f8e2b7..9f50f9806 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -27,6 +27,8 @@ local mcl_item_entity = {} local item_drop_settings = {} --settings table item_drop_settings.dug_buffer = 0.65 -- the warm up period before a dug item can be collected item_drop_settings.age = 1.0 --how old a dropped item (_insta_collect==false) has to be before collecting +item_drop_settings.fluid_flow_rate = 1.39 --the speed of a flowing fluid, used when computing push and drag forces of water on items; default is tuned to Minecraft +item_drop_settings.fluid_drag = 0.8 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.radius_collect = 0.2 --radius of collection @@ -778,11 +780,26 @@ minetest.register_entity(":__builtin:item", { -- Just to make sure we don't manipulate the speed for no reason if vec.x ~= 0 or vec.y ~= 0 or vec.z ~= 0 then -- Minecraft Wiki: Flowing speed is "about 1.39 meters per second" - local f = 1.39 - -- Set new item moving speed into the direciton of the liquid - local newv = vector.multiply(vec, f) + local f = item_drop_settings.fluid_flow_rate --1.39 + + -- Apply the force of the flowing liquid onto the item's velocity + local newv = vector.multiply(vec, f) self.object:set_acceleration({x = 0, y = 0, z = 0}) - self.object:set_velocity({x = newv.x, y = -0.22, z = newv.z}) + + local oldvel = self.object:get_velocity() -- v is vector, vel is velocity + + -- drag + newv.x = newv.x - (oldvel.x - newv.x) * item_drop_settings.fluid_drag + newv.y = newv.y - (oldvel.y - newv.y) * item_drop_settings.fluid_drag + newv.z = newv.z - (oldvel.z - newv.z) * item_drop_settings.fluid_drag + + newv.y = newv.y + -0.22 -- (keep slight downward thrust from previous version of code) + -- NOTE: is there any particular reason we have this, anyway? + -- since fluid drag is now on, we could as well just + -- apply gravity here; drag will slow down the fall + -- realistically + + self.object:set_velocity({x = oldvel.x + newv.x, y = oldvel.y + newv.y, z = oldvel.z + newv.z}) self.physical_state = true self._flowing = true From 77bfc6c17449ab756d351d00e0827a09b7a5e0f5 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:03:01 -0300 Subject: [PATCH 02/16] Scale fluid flow forces on items with dtime --- mods/ENTITIES/mcl_item_entity/init.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 9f50f9806..89ab3a4e7 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -789,9 +789,9 @@ minetest.register_entity(":__builtin:item", { local oldvel = self.object:get_velocity() -- v is vector, vel is velocity -- drag - newv.x = newv.x - (oldvel.x - newv.x) * item_drop_settings.fluid_drag - newv.y = newv.y - (oldvel.y - newv.y) * item_drop_settings.fluid_drag - newv.z = newv.z - (oldvel.z - newv.z) * item_drop_settings.fluid_drag + newv.x = newv.x - (oldvel.x - newv.x) * item_drop_settings.fluid_drag * dtime + newv.y = newv.y - (oldvel.y - newv.y) * item_drop_settings.fluid_drag * dtime + newv.z = newv.z - (oldvel.z - newv.z) * item_drop_settings.fluid_drag * dtime newv.y = newv.y + -0.22 -- (keep slight downward thrust from previous version of code) -- NOTE: is there any particular reason we have this, anyway? @@ -799,7 +799,7 @@ minetest.register_entity(":__builtin:item", { -- apply gravity here; drag will slow down the fall -- realistically - self.object:set_velocity({x = oldvel.x + newv.x, y = oldvel.y + newv.y, z = oldvel.z + newv.z}) + self.object:set_velocity({x = oldvel.x + newv.x * dtime, y = oldvel.y + newv.y * dtime, z = oldvel.z + newv.z * dtime}) self.physical_state = true self._flowing = true From 2aa565ac21e718b24d6e08898c24e540f9cc26b4 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:07:02 -0300 Subject: [PATCH 03/16] Add ground drag force to avoid items stuck on ledges --- mods/ENTITIES/mcl_item_entity/init.lua | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 89ab3a4e7..b343b3e13 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -28,7 +28,8 @@ local item_drop_settings = {} --settings table item_drop_settings.dug_buffer = 0.65 -- the warm up period before a dug item can be collected item_drop_settings.age = 1.0 --how old a dropped item (_insta_collect==false) has to be before collecting item_drop_settings.fluid_flow_rate = 1.39 --the speed of a flowing fluid, used when computing push and drag forces of water on items; default is tuned to Minecraft -item_drop_settings.fluid_drag = 0.8 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) +item_drop_settings.fluid_drag = 0.2 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) +item_drop_settings.ground_drag = 0.6 --how much friction with the ground slows items sliding on it item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.radius_collect = 0.2 --radius of collection @@ -832,7 +833,22 @@ minetest.register_entity(":__builtin:item", { end end end - disable_physics(self.object, self) + --disable_physics(self.object, self) + -- apply ground drag + local oldvel = self.object:get_velocity() + + -- ignore momentum if it's tiny + if math.abs(oldvel.x) < 0.05 and math.abs(oldvel.z) < 0.05 then + disable_physics(self.object, self) + return + end + + local newvel = { + x = oldvel.x - oldvel.x * ground_drag * dtime, + y = oldvel.y, + z = oldvel.z - oldvel.z * ground_drag * dtime + } + self.object:set_velocity(new_vel) end else if self._magnet_active == false then From 4105e076705e77392924173cf0ca56c30a249527 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:09:44 -0300 Subject: [PATCH 04/16] Fix ground drag var reference in item physics --- mods/ENTITIES/mcl_item_entity/init.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index b343b3e13..2225bcef0 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -790,9 +790,10 @@ minetest.register_entity(":__builtin:item", { local oldvel = self.object:get_velocity() -- v is vector, vel is velocity -- drag - newv.x = newv.x - (oldvel.x - newv.x) * item_drop_settings.fluid_drag * dtime - newv.y = newv.y - (oldvel.y - newv.y) * item_drop_settings.fluid_drag * dtime - newv.z = newv.z - (oldvel.z - newv.z) * item_drop_settings.fluid_drag * dtime + local fluid_drag = item_drop_settings.fluid_drag + newv.x = newv.x - (oldvel.x - newv.x) * fluid_drag * dtime + newv.y = newv.y - (oldvel.y - newv.y) * fluid_drag * dtime + newv.z = newv.z - (oldvel.z - newv.z) * fluid_drag * dtime newv.y = newv.y + -0.22 -- (keep slight downward thrust from previous version of code) -- NOTE: is there any particular reason we have this, anyway? @@ -843,6 +844,7 @@ minetest.register_entity(":__builtin:item", { return end + local ground_drag = item_drop_settings.ground_drag local newvel = { x = oldvel.x - oldvel.x * ground_drag * dtime, y = oldvel.y, From 6f6b70dedcd12aabf21819dbc9ec2135ba29fe79 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:12:56 -0300 Subject: [PATCH 05/16] Fix typo in passing newvel to set_velocity in item phys --- mods/ENTITIES/mcl_item_entity/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 2225bcef0..25f3c32e8 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -850,7 +850,7 @@ minetest.register_entity(":__builtin:item", { y = oldvel.y, z = oldvel.z - oldvel.z * ground_drag * dtime } - self.object:set_velocity(new_vel) + self.object:set_velocity(newvel) end else if self._magnet_active == false then From bce9e59e828136017e9cf478306b467ecea371a1 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:15:42 -0300 Subject: [PATCH 06/16] Adjust default drag values --- mods/ENTITIES/mcl_item_entity/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 25f3c32e8..13e45d21e 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -28,8 +28,8 @@ local item_drop_settings = {} --settings table item_drop_settings.dug_buffer = 0.65 -- the warm up period before a dug item can be collected item_drop_settings.age = 1.0 --how old a dropped item (_insta_collect==false) has to be before collecting item_drop_settings.fluid_flow_rate = 1.39 --the speed of a flowing fluid, used when computing push and drag forces of water on items; default is tuned to Minecraft -item_drop_settings.fluid_drag = 0.2 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) -item_drop_settings.ground_drag = 0.6 --how much friction with the ground slows items sliding on it +item_drop_settings.fluid_drag = 0.5 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) +item_drop_settings.ground_drag = 1.5 --how much friction with the ground slows items sliding on it item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.radius_collect = 0.2 --radius of collection From 44f327b60b053540e9c1d9b67ffe01e655aaf3f6 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:17:36 -0300 Subject: [PATCH 07/16] Adjust default drag values, round 2 --- mods/ENTITIES/mcl_item_entity/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 13e45d21e..0ed05302e 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -28,8 +28,8 @@ local item_drop_settings = {} --settings table item_drop_settings.dug_buffer = 0.65 -- the warm up period before a dug item can be collected item_drop_settings.age = 1.0 --how old a dropped item (_insta_collect==false) has to be before collecting item_drop_settings.fluid_flow_rate = 1.39 --the speed of a flowing fluid, used when computing push and drag forces of water on items; default is tuned to Minecraft -item_drop_settings.fluid_drag = 0.5 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) -item_drop_settings.ground_drag = 1.5 --how much friction with the ground slows items sliding on it +item_drop_settings.fluid_drag = 1.8 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) +item_drop_settings.ground_drag = 2.5 --how much friction with the ground slows items sliding on it item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.radius_collect = 0.2 --radius of collection From 11a661f427a58064a9494c3c60d03816dc1e9e2b Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:26:05 -0300 Subject: [PATCH 08/16] Let item entity ground friction change when on slippery floors --- mods/ENTITIES/mcl_item_entity/init.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 0ed05302e..7435348ab 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -30,6 +30,7 @@ item_drop_settings.age = 1.0 --how old a dropped item (_insta_ item_drop_settings.fluid_flow_rate = 1.39 --the speed of a flowing fluid, used when computing push and drag forces of water on items; default is tuned to Minecraft item_drop_settings.fluid_drag = 1.8 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) item_drop_settings.ground_drag = 2.5 --how much friction with the ground slows items sliding on it +item_drop_settings.slippery_drag_factor = 0.4 --scales item friction with the ground on slippery floors (e.g. ice) item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.radius_collect = 0.2 --radius of collection @@ -845,9 +846,14 @@ minetest.register_entity(":__builtin:item", { end local ground_drag = item_drop_settings.ground_drag + + if minetest.registered_nodes[nn].slippery then + ground_drag = ground_drag * item_drop_settings.slippery_drag_factor + end + local newvel = { x = oldvel.x - oldvel.x * ground_drag * dtime, - y = oldvel.y, + y = 0, z = oldvel.z - oldvel.z * ground_drag * dtime } self.object:set_velocity(newvel) From 96b8552ae479e8f66b22f83f1bfc00dbc68df33a Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:34:23 -0300 Subject: [PATCH 09/16] Make items shot by dispensers and droppers always go forward --- mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 19 ++++++++++++++++--- mods/ITEMS/REDSTONE/mcl_droppers/init.lua | 14 +++++++++++++- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 0cd0608c4..1fa4df137 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -260,9 +260,22 @@ local dispenserdef = { end else -- Drop item otherwise - minetest.add_item(droppos, dropitem) - stack:take_item() - inv:set_stack("main", stack_id, stack) + -- Drop item normally + local dropitemobj = minetest.add_item(droppos, dropitem) + stack:take_item() + inv:set_stack("main", stack_id, stack) + + -- Set item velocity (overrides the default random drop direction) + local shoot_force = 1.3 + + local newv = minetest.facedir_to_dir(node.param2) + newv = { + x = newv.x * shoot_force, + y = newv.y * shoot_force, + z = newv.z * shoot_force + } + + dropitemobj.set_velocity(newv) end end diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index abb351091..852231836 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -134,9 +134,21 @@ local dropperdef = { -- No container? if not dropped and not dropnodedef.groups.container then -- Drop item normally - minetest.add_item(droppos, dropitem) + local dropitemobj = minetest.add_item(droppos, dropitem) stack:take_item() inv:set_stack("main", stack_id, stack) + + -- Set item velocity (overrides the default random drop direction) + local shoot_force = 1.3 + + local newv = minetest.facedir_to_dir(node.param2) + newv = { + x = newv.x * shoot_force, + y = newv.y * shoot_force, + z = newv.z * shoot_force + } + + dropitemobj.set_velocity(newv) end end end, From 7dbdd70784780fe9c17c816663232a5cdd18322c Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:36:47 -0300 Subject: [PATCH 10/16] Fix set_velocity calls to item entity objs in dropper and dispenser code --- mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 2 +- mods/ITEMS/REDSTONE/mcl_droppers/init.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 1fa4df137..705466a38 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -275,7 +275,7 @@ local dispenserdef = { z = newv.z * shoot_force } - dropitemobj.set_velocity(newv) + dropitemobj:set_velocity(newv) end end diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index 852231836..412c4d577 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -148,7 +148,7 @@ local dropperdef = { z = newv.z * shoot_force } - dropitemobj.set_velocity(newv) + dropitemobj:set_velocity(newv) end end end, From 68fb7433ec63e1d99ad143eda478f9e18336606d Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:43:15 -0300 Subject: [PATCH 11/16] Fix using facedir for shoot dir of items from droppers and dispensers --- mods/ITEMS/REDSTONE/mcl_droppers/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua index 412c4d577..c707bf42e 100644 --- a/mods/ITEMS/REDSTONE/mcl_droppers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_droppers/init.lua @@ -143,9 +143,9 @@ local dropperdef = { local newv = minetest.facedir_to_dir(node.param2) newv = { - x = newv.x * shoot_force, - y = newv.y * shoot_force, - z = newv.z * shoot_force + x = -newv.x * shoot_force, + y = -newv.y * shoot_force, + z = -newv.z * shoot_force } dropitemobj:set_velocity(newv) From 3473f4ae362e8371537c93636735ee7ad11de6ca Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:49:25 -0300 Subject: [PATCH 12/16] Fix item friction reduction on slippery floor --- mods/ENTITIES/mcl_item_entity/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 7435348ab..ab597f443 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -821,8 +821,9 @@ minetest.register_entity(":__builtin:item", { -- If node is not registered or node is walkably solid and resting on nodebox local nn = minetest.get_node({x=p.x, y=p.y-0.5, z=p.z}).name local v = self.object:get_velocity() + local node = nn and minetest.registered_nodes[nn] - if not minetest.registered_nodes[nn] or minetest.registered_nodes[nn].walkable and v.y == 0 then + if not node or node.walkable and v.y == 0 then if self.physical_state then local own_stack = ItemStack(self.object:get_luaentity().itemstring) -- Merge with close entities of the same item @@ -847,7 +848,7 @@ minetest.register_entity(":__builtin:item", { local ground_drag = item_drop_settings.ground_drag - if minetest.registered_nodes[nn].slippery then + if node and minetest.get_item_group(node.name, "slippery") ~= 0 then ground_drag = ground_drag * item_drop_settings.slippery_drag_factor end From 16c63972f91cb19b1c9f5c9a7d94a4a007459426 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:50:35 -0300 Subject: [PATCH 13/16] Adjust ground friction values for item obj physics --- mods/ENTITIES/mcl_item_entity/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index ab597f443..31cfd3637 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -29,8 +29,8 @@ item_drop_settings.dug_buffer = 0.65 -- the warm up period before a d item_drop_settings.age = 1.0 --how old a dropped item (_insta_collect==false) has to be before collecting item_drop_settings.fluid_flow_rate = 1.39 --the speed of a flowing fluid, used when computing push and drag forces of water on items; default is tuned to Minecraft item_drop_settings.fluid_drag = 1.8 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) -item_drop_settings.ground_drag = 2.5 --how much friction with the ground slows items sliding on it -item_drop_settings.slippery_drag_factor = 0.4 --scales item friction with the ground on slippery floors (e.g. ice) +item_drop_settings.ground_drag = 3.0 --how much friction with the ground slows items sliding on it +item_drop_settings.slippery_drag_factor = 0.25 --scales item friction with the ground on slippery floors (e.g. ice) item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.radius_collect = 0.2 --radius of collection From 991eeca033f533d086b931325ac24f9facecf7fd Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:57:56 -0300 Subject: [PATCH 14/16] Let items undergo less waterflow drag on ice floors --- mods/ENTITIES/mcl_item_entity/init.lua | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 31cfd3637..f0b2ca26a 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -31,6 +31,7 @@ item_drop_settings.fluid_flow_rate = 1.39 --the speed of a flowing fluid, item_drop_settings.fluid_drag = 1.8 --how much drag water has on items (how quickly an item's motion will settle onto the water's flow speed) item_drop_settings.ground_drag = 3.0 --how much friction with the ground slows items sliding on it item_drop_settings.slippery_drag_factor = 0.25 --scales item friction with the ground on slippery floors (e.g. ice) +item_drop_settings.slippery_fluid_drag_factor = 0.4 --scales item drag with waterflow on slippery floors (e.g. ice) item_drop_settings.radius_magnet = 2.0 --radius of item magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.xp_radius_magnet = 7.25 --radius of xp magnet. MUST BE LARGER THAN radius_collect! item_drop_settings.radius_collect = 0.2 --radius of collection @@ -792,6 +793,14 @@ minetest.register_entity(":__builtin:item", { -- drag local fluid_drag = item_drop_settings.fluid_drag + + local floornn = minetest.get_node({x=p.x, y=p.y-0.5, z=p.z}).name + local floornode = floornn and minetest.registered_nodes[floornn] + if floornode and minetest.get_item_group(floornode.name, "slippery") then + -- scale fluid drag on slippery floors + fluid_drag = fluid_drag * item_drop_settings.slippery_fluid_drag_factor + end + newv.x = newv.x - (oldvel.x - newv.x) * fluid_drag * dtime newv.y = newv.y - (oldvel.y - newv.y) * fluid_drag * dtime newv.z = newv.z - (oldvel.z - newv.z) * fluid_drag * dtime From 49d5e1a0f6a093bdeeb2311ac3401a1b55a3886a Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 04:01:18 -0300 Subject: [PATCH 15/16] Do not reset item obj velocity upon leaving waterflow --- mods/ENTITIES/mcl_item_entity/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index f0b2ca26a..a348001d6 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -823,7 +823,7 @@ minetest.register_entity(":__builtin:item", { elseif self._flowing == true then -- Disable flowing physics if not on/in flowing liquid self._flowing = false - enable_physics(self.object, self, true) + --enable_physics(self.object, self, true) -- do not reset velocity upon leaving water! return end From 4177632d2103280f2e004d9a798c677bfede2cd1 Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 04:03:37 -0300 Subject: [PATCH 16/16] Fix gravity on items that leave waterflow --- mods/ENTITIES/mcl_item_entity/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index a348001d6..91e152ca1 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -824,6 +824,7 @@ minetest.register_entity(":__builtin:item", { -- Disable flowing physics if not on/in flowing liquid self._flowing = false --enable_physics(self.object, self, true) -- do not reset velocity upon leaving water! + self.object:set_acceleration({x=0,y=-get_gravity(),z=0}) -- resume applying gravity return end