0
0
Fork 0

Fix issue with drops turning black due to clipping into walls and floors

This commit is contained in:
ancientmarinerdev 2023-04-26 15:24:35 +01:00 committed by Johannes Fritz
parent 0568c18081
commit 52e64a6f75
1 changed files with 7 additions and 3 deletions

View File

@ -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