1 --License for code WTFPL and otherwise stated in readmes
4 local MP
= minetest
.get_modpath(minetest
.get_current_modname())
5 local S
, NS
= dofile(MP
.."/intllib.lua")
14 collisionbox
= {-0.2, -0.01, -0.2, 0.2, 0.49, 0.2},
17 mesh
= "mobs_mc_rabbit.b3d",
19 {"mobs_mc_rabbit_brown.png"},
20 {"mobs_mc_rabbit_gold.png"},
21 {"mobs_mc_rabbit_white.png"},
22 {"mobs_mc_rabbit_white_splotched.png"},
23 {"mobs_mc_rabbit_salt.png"},
24 {"mobs_mc_rabbit_black.png"},
26 visual_size
= {x
=1.5, y
=1.5},
28 makes_footstep_sound
= false,
35 {name
= mobs_mc
.items
.rabbit_raw
, chance
= 1, min = 0, max = 1},
36 {name
= mobs_mc
.items
.rabbit_hide
, chance
= 1, min = 0, max = 1},
37 {name
= mobs_mc
.items
.rabbit_foot
, chance
= 10, min = 1, max = 1},
44 speed_normal
= 25, speed_run
= 50,
45 stand_start
= 0, stand_end
= 0,
46 walk_start
= 0, walk_end
= 20,
47 run_start
= 0, run_end
= 20,
49 -- Follow (yellow) dangelions, carrots and golden carrots
50 follow
= mobs_mc
.follow
.rabbit
,
52 -- Eat carrots and reduce their growth stage by 1
54 replace_what
= mobs_mc
.replace
.rabbit
,
55 on_rightclick
= function(self
, clicker
)
56 -- Feed, tame protect or capture
57 if mobs
:feed_tame(self
, clicker
, 1, true, true) then return end
58 if mobs
:protect(self
, clicker
) then return end
59 if mobs
:capture_mob(self
, clicker
, 0, 50, 80, false, nil) then return end
61 do_custom
= function(self
)
62 -- Easter egg: Change texture if rabbit is named “Toast”
63 if self
.nametag
== "Toast" and not self
._has_toast_texture
then
64 self
._original_rabbit_texture
= self
.base_texture
65 self
.base_texture
= { "mobs_mc_rabbit_toast.png" }
66 self
.object
:set_properties({ textures
= self
.base_texture
})
67 self
._has_toast_texture
= true
68 elseif self
.nametag
~= "Toast" and self
._has_toast_texture
then
69 self
.base_texture
= self
._original_rabbit_texture
70 self
.object
:set_properties({ textures
= self
.base_texture
})
71 self
._has_toast_texture
= false
76 mobs
:register_mob("mobs_mc:rabbit", rabbit
)
78 -- The killer bunny (Only with spawn egg)
79 local killer_bunny
= table.copy(rabbit
)
80 killer_bunny
.type = "monster"
81 killer_bunny
.attack_type
= "dogfight"
82 killer_bunny
.specific_attack
= { "player", "mobs_mc:wolf", "mobs_mc:dog" }
83 killer_bunny
.damage
= 8
84 killer_bunny
.passive
= false
86 killer_bunny
.armor
= 50
87 killer_bunny
.textures
= { "mobs_mc_rabbit_caerbannog.png" }
88 killer_bunny
.view_range
= 16
89 killer_bunny
.replace_rate
= nil
90 killer_bunny
.replace_what
= nil
91 killer_bunny
.on_rightclick
= nil
92 killer_bunny
.run_velocity
= 6
93 killer_bunny
.do_custom
= function(self
)
94 if not self
._killer_bunny_nametag_set
then
95 self
.nametag
= "The Killer Bunny"
96 self
._killer_bunny_nametag_set
= true
100 mobs
:register_mob("mobs_mc:killer_bunny", killer_bunny
)
102 -- Mob spawning rules.
103 -- Different skins depending on spawn location
106 name
= "mobs_mc:rabbit",
109 active_object_count
= 99,
111 max_light
= minetest
.LIGHT_MAX
+1,
112 min_height
= mobs_mc
.spawn_height
.overworld_min
,
113 max_height
= mobs_mc
.spawn_height
.overworld_max
,
116 local spawn_desert
= table.copy(spawn
)
117 spawn_desert
.nodes
= mobs_mc
.spawn
.desert
118 spawn_desert
.on_spawn
= function(self
, pos
)
119 local texture
= "mobs_mc_rabbit_gold.png"
120 self
.base_texture
= { "mobs_mc_rabbit_gold.png" }
121 self
.object
:set_properties({textures
= self
.base_texture
})
123 mobs
:spawn(spawn_desert
)
125 local spawn_snow
= table.copy(spawn
)
126 spawn_snow
.nodes
= mobs_mc
.spawn
.snow
127 spawn_snow
.on_spawn
= function(self
, pos
)
129 local r
= math
.random(1, 100)
132 texture
= "mobs_mc_rabbit_white.png"
133 -- 20% black and white fur
135 texture
= "mobs_mc_rabbit_white_splotched.png"
137 self
.base_texture
= { texture
}
138 self
.object
:set_properties({textures
= self
.base_texture
})
140 mobs
:spawn(spawn_snow
)
142 local spawn_grass
= table.copy(spawn
)
143 spawn_grass
.nodes
= mobs_mc
.spawn
.grassland
144 spawn_grass
.on_spawn
= function(self
, pos
)
146 local r
= math
.random(1, 100)
149 texture
= "mobs_mc_rabbit_brown.png"
152 texture
= "mobs_mc_rabbit_salt.png"
155 texture
= "mobs_mc_rabbit_black.png"
157 self
.base_texture
= { texture
}
158 self
.object
:set_properties({textures
= self
.base_texture
})
160 mobs
:spawn(spawn_grass
)
163 mobs
:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0)
165 -- Note: This spawn egg does not exist in Minecraft
166 mobs
:register_egg("mobs_mc:killer_bunny", S("Killer Bunny"), "mobs_mc_spawn_icon_rabbit.png^[colorize:#FF0000:192", 0) -- TODO: Update inventory image
170 mobs
:alias_mob("mobs:bunny", "mobs_mc:rabbit")
172 if minetest
.settings
:get_bool("log_mods") then
173 minetest
.log("action", "MC Bunny loaded")