Disable villager trading again
[MineClone/MineClone2.git] / mods / ENTITIES / mobs_mc / rabbit.lua
blob0a15f3c785a1a9852ac621e74242538198fd27c6
1 --License for code WTFPL and otherwise stated in readmes
3 -- intllib
4 local MP = minetest.get_modpath(minetest.get_current_modname())
5 local S, NS = dofile(MP.."/intllib.lua")
7 local rabbit = {
8 type = "animal",
9 passive = true,
10 reach = 1,
12 hp_min = 3,
13 hp_max = 3,
14 collisionbox = {-0.2, -0.01, -0.2, 0.2, 0.49, 0.2},
16 visual = "mesh",
17 mesh = "mobs_mc_rabbit.b3d",
18 textures = {
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},
27 sounds = {},
28 makes_footstep_sound = false,
29 walk_velocity = 1,
30 run_velocity = 3.7,
31 floats = 1,
32 runaway = true,
33 jump = true,
34 drops = {
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},
39 water_damage = 1,
40 lava_damage = 4,
41 light_damage = 0,
42 fear_height = 4,
43 animation = {
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,
51 view_range = 8,
52 -- Eat carrots and reduce their growth stage by 1
53 replace_rate = 10,
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
60 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
72 end
73 end,
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
85 -- 8 armor points
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
97 end
98 end
100 mobs:register_mob("mobs_mc:killer_bunny", killer_bunny)
102 -- Mob spawning rules.
103 -- Different skins depending on spawn location
105 local spawn = {
106 name = "mobs_mc:rabbit",
107 neighbors = {"air"},
108 chance = 15000,
109 active_object_count = 99,
110 min_light = 0,
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)
128 local texture
129 local r = math.random(1, 100)
130 -- 80% white fur
131 if r <= 80 then
132 texture = "mobs_mc_rabbit_white.png"
133 -- 20% black and white fur
134 else
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)
145 local texture
146 local r = math.random(1, 100)
147 -- 50% brown fur
148 if r <= 50 then
149 texture = "mobs_mc_rabbit_brown.png"
150 -- 40% salt fur
151 elseif r <= 90 then
152 texture = "mobs_mc_rabbit_salt.png"
153 -- 10% black fur
154 else
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)
162 -- Spawn egg
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
169 -- compatibility
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")