From 13df9ec46c64b77a8ae70a4cd0a2a659b6eadc9a Mon Sep 17 00:00:00 2001 From: cora Date: Thu, 27 Apr 2023 14:43:33 -0600 Subject: [PATCH 1/4] Fix crash when using a named spawn egg --- mods/ENTITIES/mcl_mobs/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_mobs/init.lua b/mods/ENTITIES/mcl_mobs/init.lua index c32fca820..bdc062470 100644 --- a/mods/ENTITIES/mcl_mobs/init.lua +++ b/mods/ENTITIES/mcl_mobs/init.lua @@ -556,7 +556,7 @@ function mcl_mobs.register_egg(mob, desc, background_color, overlay_color, addeg nametag = string.sub(nametag, 1, MAX_MOB_NAME_LENGTH) end ent.nametag = nametag - update_tag(ent) + ent:update_tag() end -- if not in creative then take item From 52e64a6f757bad4ff14126970657c9caec06f5dc Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Wed, 26 Apr 2023 15:24:35 +0100 Subject: [PATCH 2/4] 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 From c48510244e7a3fc7ca76fcba744fe85db5b52e17 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Wed, 26 Apr 2023 20:36:23 +0100 Subject: [PATCH 3/4] Before merging same stacks, move to middle to show merging occurs. --- mods/ENTITIES/mcl_item_entity/init.lua | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index b9c56d6c7..ffecb80d5 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -808,11 +808,17 @@ minetest.register_entity(":__builtin:item", { if total_count > max_count then return false end - -- Merge the remote stack into this one - -- local pos = object:get_pos() - -- pos.y = pos.y + ((total_count - count) / max_count) * 0.15 - -- self.object:move_to(pos) + -- Merge the remote stack into this one + local self_pos = self.object:get_pos() + local pos = object:get_pos() + + --local y = pos.y + ((total_count - count) / max_count) * 0.15 + local x_diff = (self_pos.x - pos.x) / 2 + local z_diff = (self_pos.z - pos.z) / 2 + + local new_pos = vector.offset(pos, x_diff, 0, z_diff) + self.object:move_to(new_pos) self.age = 0 -- Handle as new entity own_stack:set_count(total_count) @@ -833,6 +839,7 @@ minetest.register_entity(":__builtin:item", { self.object:set_acceleration(vector.zero()) return end + self.age = self.age + dtime if self._collector_timer then self._collector_timer = self._collector_timer + dtime @@ -862,6 +869,9 @@ minetest.register_entity(":__builtin:item", { return end + + + if self.is_clock then self.object:set_properties({ textures = { "mcl_clock:clock_" .. (mcl_worlds.clock_works(p) and mcl_clock.old_time or mcl_clock.random_frame) } @@ -911,14 +921,13 @@ minetest.register_entity(":__builtin:item", { local is_on_floor = def and (def.walkable and not def.groups.slippery and v.y == 0) - if not minetest.registered_nodes[nn] - or is_floating or is_on_floor then + if not minetest.registered_nodes[nn] or is_floating or is_on_floor then + local own_stack = ItemStack(self.object:get_luaentity().itemstring) -- Merge with close entities of the same item for _, object in pairs(minetest.get_objects_inside_radius(p, 0.8)) do local obj = object:get_luaentity() - if obj and obj.name == "__builtin:item" - and obj.physical_state == false then + if obj and obj.name == "__builtin:item" and obj.physical_state == false then if self:try_merge_with(own_stack, object, obj) then return end From 938ee7a832c61a64611b997811034e2b4f060a35 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Wed, 26 Apr 2023 22:21:38 +0100 Subject: [PATCH 4/4] Pick highest y and kick it up a little for visual spice and to fix occassional drop falling into floor --- mods/ENTITIES/mcl_item_entity/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index ffecb80d5..149b5ed93 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -818,6 +818,8 @@ minetest.register_entity(":__builtin:item", { local z_diff = (self_pos.z - pos.z) / 2 local new_pos = vector.offset(pos, x_diff, 0, z_diff) + new_pos.y = math.max(self_pos.y, pos.y) + 0.1 + self.object:move_to(new_pos) self.age = 0 -- Handle as new entity