From 52e64a6f757bad4ff14126970657c9caec06f5dc Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Wed, 26 Apr 2023 15:24:35 +0100 Subject: [PATCH] Fix issue with drops turning black due to clipping into walls and floors --- mods/ENTITIES/mcl_item_entity/init.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 3103a1104..b9c56d6c7 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -621,13 +621,17 @@ minetest.register_entity(":__builtin:item", { if speed ~= nil then self.random_velocity = speed end local vel = self.object:get_velocity() + + -- There is perhaps a cleverer way of making this physical so it bounces off the wall like swords. + local max_vel = 6.5 -- Faster than this and it throws it into the wall / floor and turns black because of clipping. + if vel and vel.x == 0 and vel.z == 0 and self.random_velocity > 0 then local v = self.random_velocity - local x = math.random(5, 10) / 10 * v + local x = math.random(5, max_vel) / 10 * v if math.random(0, 10) < 5 then x = -x end - local z = math.random(5, 10) / 10 * v + local z = math.random(5, max_vel) / 10 * v if math.random(0, 10) < 5 then z = -z end - local y = math.random(2, 4) + local y = math.random(1, 2) self.object:set_velocity(vector.new(x, y, z)) end self.random_velocity = 0