From 0e364fc22c6d9ef19b885e8e450693fa690a1a4a Mon Sep 17 00:00:00 2001 From: cora Date: Fri, 30 Sep 2022 14:12:20 +0200 Subject: [PATCH 1/2] Fix llama inv only being accessible by owner --- mods/ENTITIES/mobs_mc/llama.lua | 65 ++++++++++++++++----------------- 1 file changed, 31 insertions(+), 34 deletions(-) diff --git a/mods/ENTITIES/mobs_mc/llama.lua b/mods/ENTITIES/mobs_mc/llama.lua index cf0399921..f877c8836 100644 --- a/mods/ENTITIES/mobs_mc/llama.lua +++ b/mods/ENTITIES/mobs_mc/llama.lua @@ -143,45 +143,43 @@ mcl_mobs:register_mob("mobs_mc:llama", { end if mcl_mobs:protect(self, clicker) then return end + if self._has_chest and clicker:get_player_control().sneak then + mcl_entity_invs.show_inv_form(self,clicker,"Llama - Strength "..math.floor(self._inv_size / 3)) + return + end -- Make sure tamed llama is mature and being clicked by owner only if self.tamed and not self.child and self.owner == clicker:get_player_name() then - - -- Place carpet - if minetest.get_item_group(item:get_name(), "carpet") == 1 and not self.carpet then - for group, carpetdata in pairs(carpets) do - if minetest.get_item_group(item:get_name(), group) == 1 then - if not minetest.is_creative_enabled(clicker:get_player_name()) then - item:take_item() - clicker:set_wielded_item(item) + -- Place carpet + if minetest.get_item_group(item:get_name(), "carpet") == 1 and not self.carpet then + for group, carpetdata in pairs(carpets) do + if minetest.get_item_group(item:get_name(), group) == 1 then + if not minetest.is_creative_enabled(clicker:get_player_name()) then + item:take_item() + clicker:set_wielded_item(item) + end + local substr = carpetdata[2] + local tex_carpet = "mobs_mc_llama_decor_"..substr..".png" + self.base_texture = table.copy(self.base_texture) + self.base_texture[2] = tex_carpet + self.object:set_properties({ + textures = self.base_texture, + }) + self.carpet = item:get_name() + self.drops = { + {name = "mcl_mobitems:leather", + chance = 1, + min = 0, + max = 2,}, + {name = item:get_name(), + chance = 1, + min = 1, + max = 1,}, + } + return end - local substr = carpetdata[2] - local tex_carpet = "mobs_mc_llama_decor_"..substr..".png" - self.base_texture = table.copy(self.base_texture) - self.base_texture[2] = tex_carpet - self.object:set_properties({ - textures = self.base_texture, - }) - self.carpet = item:get_name() - self.drops = { - {name = "mcl_mobitems:leather", - chance = 1, - min = 0, - max = 2,}, - {name = item:get_name(), - chance = 1, - min = 1, - max = 1,}, - } - return end end - end - if clicker:get_player_control().sneak then - if self._has_chest then - mcl_entity_invs.show_inv_form(self,clicker,"Llama - Strength "..math.floor(self._inv_size / 3)) - end - else -- detatch player already riding llama if self.driver and clicker == self.driver then mcl_mobs.detach(clicker, {x = 1, y = 0, z = 1}) @@ -191,7 +189,6 @@ mcl_mobs:register_mob("mobs_mc:llama", { mcl_mobs.attach(self, clicker) end end - end end, on_breed = function(parent1, parent2) From 0fd1d34aa5f2a2a01c67ff91b1efff29c858f70b Mon Sep 17 00:00:00 2001 From: cora Date: Sat, 1 Oct 2022 00:31:06 +0200 Subject: [PATCH 2/2] Fix possible crash on llama death --- mods/ENTITIES/mcl_entity_invs/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ENTITIES/mcl_entity_invs/init.lua b/mods/ENTITIES/mcl_entity_invs/init.lua index abd467a71..b60e9c18c 100644 --- a/mods/ENTITIES/mcl_entity_invs/init.lua +++ b/mods/ENTITIES/mcl_entity_invs/init.lua @@ -74,6 +74,7 @@ function mcl_entity_invs.show_inv_form(ent,player,show_name) end local function drop_inv(ent) + if not ent._items then return end local pos = ent.object:get_pos() for i,it in pairs(ent._items) do local p = vector.add(pos,vector.new(math.random() - 0.5, math.random()-0.5, math.random()-0.5))