From 11a661f427a58064a9494c3c60d03816dc1e9e2b Mon Sep 17 00:00:00 2001 From: Gustavo Ramos Rehermann Date: Wed, 9 Feb 2022 03:26:05 -0300 Subject: [PATCH] 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)