Merge pull request 'A couple llama fixes' (#2688) from fix_llama_player_inv into master

Reviewed-on: https://git.minetest.land/MineClone2/MineClone2/pulls/2688
This commit is contained in:
cora 2022-10-01 01:21:51 +00:00
commit 3b873a89eb
2 changed files with 32 additions and 34 deletions

View file

@ -74,6 +74,7 @@ function mcl_entity_invs.show_inv_form(ent,player,show_name)
end end
local function drop_inv(ent) local function drop_inv(ent)
if not ent._items then return end
local pos = ent.object:get_pos() local pos = ent.object:get_pos()
for i,it in pairs(ent._items) do 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)) local p = vector.add(pos,vector.new(math.random() - 0.5, math.random()-0.5, math.random()-0.5))

View file

@ -143,45 +143,43 @@ mcl_mobs:register_mob("mobs_mc:llama", {
end end
if mcl_mobs:protect(self, clicker) then return 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 -- 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 if self.tamed and not self.child and self.owner == clicker:get_player_name() then
-- Place carpet
-- Place carpet if minetest.get_item_group(item:get_name(), "carpet") == 1 and not self.carpet then
if minetest.get_item_group(item:get_name(), "carpet") == 1 and not self.carpet then for group, carpetdata in pairs(carpets) do
for group, carpetdata in pairs(carpets) do if minetest.get_item_group(item:get_name(), group) == 1 then
if minetest.get_item_group(item:get_name(), group) == 1 then if not minetest.is_creative_enabled(clicker:get_player_name()) then
if not minetest.is_creative_enabled(clicker:get_player_name()) then item:take_item()
item:take_item() clicker:set_wielded_item(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 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 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 -- detatch player already riding llama
if self.driver and clicker == self.driver then if self.driver and clicker == self.driver then
mcl_mobs.detach(clicker, {x = 1, y = 0, z = 1}) 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) mcl_mobs.attach(self, clicker)
end end
end end
end
end, end,
on_breed = function(parent1, parent2) on_breed = function(parent1, parent2)