From 088f8dec2f784147c8e7c65bc13b9d77defd6fc0 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Mon, 19 Jun 2023 16:53:02 +0100 Subject: [PATCH 1/3] Fix server crash for unknown node below. --- mods/PLAYER/mcl_playerplus/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index d4a21508e..5836b6fe2 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -257,7 +257,8 @@ minetest.register_globalstep(function(dtime) local speed_mult = elytra.speed local block_below = minetest.get_node(vector.offset(fly_pos, 0, -0.9, 0)).name - if (not minetest.registered_nodes[block_below].walkable) and (player_vel.y ~= 0) then + local reg_node_below = minetest.registered_nodes[block_below] + if (reg_node_below and not reg_node_below.walkable) and (player_vel.y ~= 0) then speed_mult = speed_mult + direction_mult * elytra_vars.speedup_mult * dtime end speed_mult = speed_mult - elytra_vars.slowdown_mult * clamp(dtime, 0.09, 0.2) -- slow down but don't overdo it From 7d51519f4d4c701571a37a6e7a463a76c0eea880 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Mon, 19 Jun 2023 17:49:20 +0100 Subject: [PATCH 2/3] Fix wool farm crash --- mods/ENTITIES/mobs_mc/sheep.lua | 31 +++++++++++++++++---- mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 4 ++- mods/ITEMS/REDSTONE/mesecons/internal.lua | 2 +- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/sheep.lua b/mods/ENTITIES/mobs_mc/sheep.lua index 6c095fc9b..6eaffa611 100644 --- a/mods/ENTITIES/mobs_mc/sheep.lua +++ b/mods/ENTITIES/mobs_mc/sheep.lua @@ -6,6 +6,8 @@ local S = minetest.get_translator("mobs_mc") --################### SHEEP --################### +local WOOL_REPLACE_RATE = 80 + local colors = { -- group = { wool, textures } unicolor_white = { "mcl_wool:white", "#FFFFFF00" }, @@ -113,7 +115,7 @@ mcl_mobs.register_mob("mobs_mc:sheep", { view_range = 12, -- Eat grass - replace_rate = 80, + replace_rate = WOOL_REPLACE_RATE, replace_delay = 1.3, replace_what = { { "mcl_core:dirt_with_grass", "mcl_core:dirt", -1 }, @@ -121,25 +123,42 @@ mcl_mobs.register_mob("mobs_mc:sheep", { }, -- Properly regrow wool after eating grass on_replace = function(self, pos, oldnode, newnode) + if not self.color or not colors[self.color] then + self.color = "unicolor_white" + end + self.base_texture = sheep_texture(self.color) + + self.drops = { + {name = "mcl_mobitems:mutton", + chance = 1, + min = 1, + max = 2,}, + {name = colors[self.color][1], + chance = 1, + min = 1, + max = 1,}, + } + self.state = "eat" self:set_animation("eat") self:set_velocity(0) + + + minetest.after(self.replace_delay, function() if self and self.object and self.object:get_velocity() and self.health > 0 then self.object:set_velocity(vector.zero()) - if not self.color or not colors[self.color] then - self.color = "unicolor_white" - end self.gotten = false - self.base_texture = sheep_texture(self.color) self.object:set_properties({ textures = self.base_texture }) end end) + minetest.after(2.5, function() - if self and self.object and self.state == 'eat' and self.health > 0 and self.object:get_velocity() then + if self and self.object and self.state == 'eat' and self.health > 0 then self.state = "walk" end end) + end, -- Set random color on spawn diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index dce69f26a..17d9385a2 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -178,7 +178,9 @@ local dispenserdef = { local pos = obj:get_pos() local used, texture = false if entname == "mobs_mc:sheep" then - minetest.add_item(pos, entity.drops[2].name .. " " .. math.random(1, 3)) + if entity.drops[2] then + minetest.add_item(pos, entity.drops[2].name .. " " .. math.random(1, 3)) + end if not entity.color then entity.color = "unicolor_white" end diff --git a/mods/ITEMS/REDSTONE/mesecons/internal.lua b/mods/ITEMS/REDSTONE/mesecons/internal.lua index 06a5d08b9..d7983d353 100644 --- a/mods/ITEMS/REDSTONE/mesecons/internal.lua +++ b/mods/ITEMS/REDSTONE/mesecons/internal.lua @@ -177,7 +177,7 @@ end function mesecon.effector_get_rules(node) local effector = mesecon.get_effector(node.name) - if effector then + if effector and effector.rules then local rules = effector.rules if type(rules) == "function" then return rules(node) From 8b9b4b00e55d8f73d121c1f11230b3c77ebc9937 Mon Sep 17 00:00:00 2001 From: ancientmarinerdev Date: Mon, 19 Jun 2023 17:51:02 +0100 Subject: [PATCH 3/3] Fix elytra crash when flying over unknown node --- mods/PLAYER/mcl_playerplus/init.lua | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/PLAYER/mcl_playerplus/init.lua b/mods/PLAYER/mcl_playerplus/init.lua index 5836b6fe2..69cb00d07 100644 --- a/mods/PLAYER/mcl_playerplus/init.lua +++ b/mods/PLAYER/mcl_playerplus/init.lua @@ -239,10 +239,11 @@ minetest.register_globalstep(function(dtime) elytra.speed = 1 - (direction.y/2 + 0.5) end + local fly_node_walkable = minetest.registered_nodes[fly_node] and minetest.registered_nodes[fly_node].walkable elytra.active = minetest.get_item_group(player:get_inventory():get_stack("armor", 3):get_name(), "elytra") ~= 0 and not parent and (elytra.active or (is_just_jumped and player_velocity.y < -0)) - and ((not minetest.registered_nodes[fly_node].walkable) or fly_node == "ignore") + and ((not fly_node_walkable) or fly_node == "ignore") if elytra.active then if is_just_jumped then -- move the player up when they start flying to give some clearance