2 local MP
= minetest
.get_modpath(minetest
.get_current_modname())
3 local S
, NS
= dofile(MP
.."/intllib.lua")
6 --################### LLAMA
9 mobs
:register_mob("mobs_mc:llama", {
14 collisionbox
= {-0.45, -0.01, -0.45, 0.45, 1.86, 0.45},
16 mesh
= "mobs_mc_llama.b3d",
17 textures
= { -- 1: chest -- 2: decor (carpet) -- 3: llama base texture
18 {"blank.png", "blank.png", "mobs_mc_llama_brown.png"},
19 {"blank.png", "blank.png", "mobs_mc_llama_creamy.png"},
20 {"blank.png", "blank.png", "mobs_mc_llama_gray.png"},
21 {"blank.png", "blank.png", "mobs_mc_llama_white.png"},
22 {"blank.png", "blank.png", "mobs_mc_llama.png"},
23 -- TODO: Implement carpet (aka decor) on llama
25 visual_size
= {x
=3, y
=3},
26 makes_footstep_sound
= true,
32 {name
= mobs_mc
.items
.leather
,
42 random = "mobs_mc_llama",
43 -- TODO: Death and damage sounds
61 follow
= mobs_mc
.items
.horse
,
63 do_custom
= function(self
, dtime
)
65 -- set needed values if not already present
68 self
.max_speed_forward
= 4
69 self
.max_speed_reverse
= 2
72 self
.driver_attach_at
= {x
= 0, y
= 7.5, z
= -1.5}
73 self
.driver_eye_offset
= {x
= 0, y
= 3, z
= 0}
74 self
.driver_scale
= {x
= 1/self
.visual_size
.x
, y
= 1/self
.visual_size
.y
}
77 -- if driver present allow control of llama
80 mobs
.drive(self
, "walk", "stand", false, dtime
)
82 return false -- skip rest of mob functions
88 on_die
= function(self
, pos
)
90 -- detach from llama properly
92 mobs
.detach(self
.driver
, {x
= 1, y
= 0, z
= 1})
97 on_rightclick
= function(self
, clicker
)
99 -- Make sure player is clicking
100 if not clicker
or not clicker
:is_player() then
104 local item
= clicker
:get_wielded_item()
105 if item
:get_name() == mobs_mc
.items
.hay_bale
then
106 -- Breed with hay bale
107 if mobs
:feed_tame(self
, clicker
, 1, true, false) then return end
109 -- Feed with anything else
110 if mobs
:feed_tame(self
, clicker
, 1, false, true) then return end
112 if mobs
:protect(self
, clicker
) then return end
114 -- Make sure tamed llama is mature and being clicked by owner only
115 if self
.tamed
and not self
.child
and self
.owner
== clicker
:get_player_name() then
117 local inv
= clicker
:get_inventory()
119 -- detatch player already riding llama
120 if self
.driver
and clicker
== self
.driver
then
122 mobs
.detach(clicker
, {x
= 1, y
= 0, z
= 1})
124 -- attach player to llama
125 elseif not self
.driver
then
127 self
.object
:set_properties({stepheight
= 1.1})
128 mobs
.attach(self
, clicker
)
131 -- Used to capture llama
132 elseif not self
.driver
and clicker
:get_wielded_item():get_name() ~= "" then
133 mobs
:capture_mob(self
, clicker
, 0, 5, 60, false, nil)
140 mobs
:spawn_specific("mobs_mc:llama", mobs_mc
.spawn
.savanna
, {"air"}, 0, minetest
.LIGHT_MAX
+1, 30, 15000, 5, mobs_mc
.spawn_height
.water
+15, mobs_mc
.spawn_height
.overworld_max
)
143 mobs
:register_egg("mobs_mc:llama", S("Llama"), "mobs_mc_spawn_icon_llama.png", 0)
145 if minetest
.settings
:get_bool("log_mods") then
146 minetest
.log("action", "MC Llama loaded")