Update mobs_mc, properly implement totem
[MineClone/MineClone2.git] / mods / ENTITIES / mobs_mc / 1_items_default.lua
blobf7f7c2c0b257d3e616b3b9a95a93f1874145b5cb
1 --MCmobs v0.5
2 --maikerumine
3 --made for MC like Survival game
4 --License for code WTFPL and otherwise stated in readmes
7 --dofile(minetest.get_modpath("mobs").."/api.lua")
8 --THIS IS THE MASTER ITEM LIST TO USE WITH DEFAULT
10 -- intllib
11 local MP = minetest.get_modpath(minetest.get_current_modname())
12 local S, NS = dofile(MP.."/intllib.lua")
14 local c = mobs_mc.is_item_variable_overridden
16 -- Blaze
17 if c("blaze_rod") then
18 minetest.register_craftitem("mobs_mc:blaze_rod", {
19 description = S("Blaze Rod"),
20 _doc_items_longdesc = S("This is a crafting component dropped from dead blazes."),
21 wield_image = "mcl_mobitems_blaze_rod.png",
22 inventory_image = "mcl_mobitems_blaze_rod.png",
25 -- Make blaze rod furnace-burnable. 1.5 times the burn time of a coal lump
26 local coalcraft, burntime
27 if minetest.get_modpath("default") then
28 coalcraft = minetest.get_craft_result({method="fuel", width=1, items={"default:coal_lump"}})
29 end
30 if coalcraft then
31 burntime = math.floor(coalcraft.time * 1.5)
32 end
33 if burntime == nil or burntime == 0 then
34 burntime = 60
35 end
37 minetest.register_craft({
38 type = "fuel",
39 burntime = burntime,
40 recipe = "mobs_mc:blaze_rod",
42 end
44 if c("blaze_powder") then
45 minetest.register_craftitem("mobs_mc:blaze_powder", {
46 description = S("Blaze Powder"),
47 _doc_items_longdesc = S("This item is mainly used for brewing potions and crafting."),
48 wield_image = "mcl_mobitems_blaze_powder.png",
49 inventory_image = "mcl_mobitems_blaze_powder.png",
51 end
53 if c("blaze_rod") and c("blaze_powder") then
54 minetest.register_craft({
55 output = "mobs_mc:blaze_powder 2",
56 recipe = {{ "mobs_mc:blaze_rod" }},
58 end
60 -- Chicken
61 if c("chicken_raw") then
62 minetest.register_craftitem("mobs_mc:chicken_raw", {
63 description = S("Raw Chicken"),
64 _doc_items_longdesc = S("Raw chicken is a food item and can be eaten safely. Cooking it will increase its nutritional value."),
65 inventory_image = "mcl_mobitems_chicken_raw.png",
66 groups = { food = 2, eatable = 2 },
67 on_use = minetest.item_eat(2),
69 end
71 if c("chicken_cooked") then
72 minetest.register_craftitem("mobs_mc:chicken_cooked", {
73 description = S("Cooked Chicken"),
74 _doc_items_longdesc = S("A cooked chicken is a healthy food item which can be eaten."),
75 inventory_image = "mcl_mobitems_chicken_cooked.png",
76 groups = { food = 2, eatable = 6 },
77 on_use = minetest.item_eat(6),
79 end
81 if c("chicken_raw") and c("chicken_cooked") then
82 minetest.register_craft({
83 type = "cooking",
84 output = "mobs_mc:chicken_cooked",
85 recipe = "mobs_mc:chicken_raw",
86 cooktime = 5,
88 end
90 if c("feather") then
91 minetest.register_craftitem("mobs_mc:feather", {
92 description = S("Feather"),
93 _doc_items_longdesc = S("Feathers are used in crafting and are dropped from chickens."),
94 inventory_image = "mcl_mobitems_feather.png",
96 end
98 -- Cow and mooshroom
99 if c("beef_raw") then
100 minetest.register_craftitem("mobs_mc:beef_raw", {
101 description = S("Raw Beef"),
102 _doc_items_longdesc = S("Raw beef is the flesh from cows and can be eaten safely. Cooking it will greatly increase its nutritional value."),
103 inventory_image = "mcl_mobitems_beef_raw.png",
104 groups = { food = 2, eatable = 3 },
105 on_use = minetest.item_eat(3),
109 if c("beef_cooked") then
110 minetest.register_craftitem("mobs_mc:beef_cooked", {
111 description = S("Steak"),
112 _doc_items_longdesc = S("Steak is cooked beef from cows and can be eaten."),
113 inventory_image = "mcl_mobitems_beef_cooked.png",
114 groups = { food = 2, eatable = 8 },
115 on_use = minetest.item_eat(8),
119 if c("beef_raw") and c("beef_cooked") then
120 minetest.register_craft({
121 type = "cooking",
122 output = "mobs_mc:beef_cooked",
123 recipe = "mobs_mc:beef_raw",
124 cooktime = 5,
129 if c("milk") then
130 -- milk
131 minetest.register_craftitem("mobs_mc:milk_bucket", {
132 description = S("Milk"),
133 _doc_items_longdesc = S("Milk is a food item obtained by using a bucket on a cow."),
134 inventory_image = "mobs_bucket_milk.png",
135 groups = { food = 3, eatable = 1 },
136 on_use = minetest.item_eat(1, "bucket:bucket_empty"),
137 stack_max = 1,
141 if c("bowl") then
142 minetest.register_craftitem("mobs_mc:bowl", {
143 description = S("Bowl"),
144 _doc_items_longdesc = S("Bowls are mainly used to hold tasty soups."),
145 inventory_image = "mcl_core_bowl.png",
148 minetest.register_craft({
149 output = "mobs_mc:bowl",
150 recipe = {
151 { "group:wood", "", "group:wood" },
152 { "", "group:wood", "", },
156 minetest.register_craft({
157 type = "fuel",
158 recipe = "mobs_mc:bowl",
159 burntime = 5,
163 if c("mushroom_stew") then
164 minetest.register_craftitem("mobs_mc:mushroom_stew", {
165 description = S("Mushroom Stew"),
166 _doc_items_longdesc = S("Mushroom stew is a healthy soup."),
167 inventory_image = "farming_mushroom_stew.png",
168 groups = { food = 3, eatable = 6 },
169 on_use = minetest.item_eat(6, "mobs_mc:bowl"),
170 stack_max = 1,
174 -- Ender dragon
175 if c("dragon_egg") then
177 local dragon_egg_sounds
178 if minetest.get_modpath("default") then
179 dragon_egg_sounds = default.node_sound_stone_defaults()
182 --ender dragon
183 minetest.register_node("mobs_mc:dragon_egg", {
184 description = S("Dragon Egg"),
185 tiles = {
186 "mcl_end_dragon_egg.png",
187 "mcl_end_dragon_egg.png",
188 "mcl_end_dragon_egg.png",
189 "mcl_end_dragon_egg.png",
190 "mcl_end_dragon_egg.png",
191 "mcl_end_dragon_egg.png",
193 drawtype = "nodebox",
194 is_ground_content = false,
195 paramtype = "light",
196 light_source = 1,
197 node_box = {
198 type = "fixed",
199 fixed = {
200 {-0.375, -0.5, -0.375, 0.375, -0.4375, 0.375},
201 {-0.5, -0.4375, -0.5, 0.5, -0.1875, 0.5},
202 {-0.4375, -0.1875, -0.4375, 0.4375, 0, 0.4375},
203 {-0.375, 0, -0.375, 0.375, 0.125, 0.375},
204 {-0.3125, 0.125, -0.3125, 0.3125, 0.25, 0.3125},
205 {-0.25, 0.25, -0.25, 0.25, 0.3125, 0.25},
206 {-0.1875, 0.3125, -0.1875, 0.1875, 0.375, 0.1875},
207 {-0.125, 0.375, -0.125, 0.125, 0.4375, 0.125},
208 {-0.0625, 0.4375, -0.0625, 0.0625, 0.5, 0.0625},
211 selection_box = {
212 type = "regular",
214 groups = {snappy = 1, falling_node = 1, deco_block = 1, not_in_creative_inventory = 1, dig_by_piston = 1 },
215 sounds = dragon_egg_sounds,
216 -- TODO: Make dragon egg teleport on punching
220 local longdesc_craftitem
221 if minetest.get_modpath("doc_items") then
222 longdesc_craftitem = doc.sub.items.temp.craftitem
225 -- Enderman
226 if c("ender_eye") then
227 minetest.register_craftitem("mobs_mc:ender_eye", {
228 description = S("Eye of Ender"),
229 _doc_items_longdesc = longdesc_craftitem,
230 inventory_image = "mcl_end_ender_eye.png",
231 groups = { craftitem = 1 },
235 if c("ender_eye") and c("blaze_powder") and c("blaze_rod") then
236 minetest.register_craft({
237 type = "shapeless",
238 output = 'mobs_mc:ender_eye',
239 recipe = { 'mobs_mc:blaze_powder', 'mobs_mc:blaze_rod'},
243 -- Ghast
244 if c("ghast_tear") then
245 minetest.register_craftitem("mobs_mc:ghast_tear", {
246 description = S("Ghast Tear"),
247 _doc_items_longdesc = S("A ghast tear is an item used in potion brewing. It is dropped from dead ghasts."),
248 wield_image = "mcl_mobitems_ghast_tear.png",
249 inventory_image = "mcl_mobitems_ghast_tear.png",
250 groups = { brewitem = 1 },
254 -- Saddle
255 if c("saddle") then
256 -- Overwrite the saddle from Mobs Redo
257 minetest.register_craftitem(":mobs:saddle", {
258 description = S("Saddle"),
259 _doc_items_longdesc = S("Saddles can be put on horses, donkeys, mules and pigs in order to mount them."),
260 _doc_items_usagehelp = S("Rightclick an animal while holding a saddle to put on the saddle. You can now mount the animal by rightclicking it again."),
261 inventory_image = "mcl_mobitems_saddle.png",
262 stack_max = 1,
266 if c("saddle") and c("lether") and c("string") and c("iron_ingot") then
267 minetest.register_craft({
268 output = "mobs_mc:saddle",
269 recipe = {
270 {"mobs:leather", "mobs:leather", "mobs:leather"},
271 {"farming:string", "", "farming:string"},
272 {"default:steel_ingot", "", "default:steel_ingot"}
277 -- Horse Armor
278 local horse_armor_use = S("Rightclick a horse to put on the horse armor. Donkeys and mules can't wear horse armor.")
279 -- TODO: Balance the horse armor strength, compare with MC armor strength
280 if c("iron_horse_armor") then
281 minetest.register_craftitem("mobs_mc:iron_horse_armor", {
282 description = S("Iron Horse Armor"),
283 _doc_items_longdesc = S("Iron horse armor can be worn by horses to increase their protection from harm a bit."),
284 _doc_items_usagehelp = horse_armor_use,
285 inventory_image = "mobs_mc_iron_horse_armor.png",
286 _horse_overlay_image = "mobs_mc_horse_armor_iron.png",
287 stack_max = 1,
288 groups = { horse_armor = 85 },
291 if c("gold_horse_armor") then
292 minetest.register_craftitem("mobs_mc:gold_horse_armor", {
293 description = S("Golden Horse Armor"),
294 _doc_items_longdesc = S("Golden horse armor can be worn by horses to increase their protection from harm."),
295 _doc_items_usagehelp = horse_armor_use,
296 inventory_image = "mobs_mc_gold_horse_armor.png",
297 _horse_overlay_image = "mobs_mc_horse_armor_gold.png",
298 stack_max = 1,
299 groups = { horse_armor = 60 },
302 if c("diamond_horse_armor") then
303 minetest.register_craftitem("mobs_mc:diamond_horse_armor", {
304 description = S("Diamond Horse Armor"),
305 _doc_items_longdesc = S("Diamond horse armor can be worn by horses to greatly increase their protection from harm."),
306 _doc_items_usagehelp = horse_armor_use,
307 inventory_image = "mobs_mc_diamond_horse_armor.png",
308 _horse_overlay_image = "mobs_mc_horse_armor_diamond.png",
309 stack_max = 1,
310 groups = { horse_armor = 45 },
314 -- Pig
315 if c("porkchop_raw") then
316 minetest.register_craftitem("mobs_mc:porkchop_raw", {
317 description = S("Raw Porkchop"),
318 _doc_items_longdesc = S("A raw porkchop is the flesh from a pig and can be eaten safely. Cooking it will greatly increase its nutritional value."),
319 inventory_image = "mcl_mobitems_porkchop_raw.png",
320 groups = { food = 2, eatable = 3 },
321 on_use = minetest.item_eat(3),
325 if c("porkchop_cooked") then
326 minetest.register_craftitem("mobs_mc:porkchop_cooked", {
327 description = S("Cooked Porkchop"),
328 _doc_items_longdesc = "Cooked porkchop is the cooked flesh of a pig and is used as food.",
329 inventory_image = "mcl_mobitems_porkchop_cooked.png",
330 groups = { food = 2, eatable = 8 },
331 on_use = minetest.item_eat(8),
335 if c("porkchop_raw") and c("porkchop_cooked") then
336 minetest.register_craft({
337 type = "cooking",
338 output = "mobs_mc:porkchop_cooked",
339 recipe = "mobs_mc:porkchop_raw",
340 cooktime = 5,
344 if c("carrot_on_a_stick") then
345 minetest.register_tool("mobs_mc:carrot_on_a_stick", {
346 description = S("Carrot on a Stick"),
347 _doc_items_longdesc = S("A carrot on a stick can be used on saddled pigs to ride them. Pigs will also follow anyone who holds a carrot on a stick near them."),
348 _doc_items_usagehelp = S("Rightclick a saddled pig with the carrot on a stick to mount it. You can now ride it like a horse."),
349 wield_image = "mcl_mobitems_carrot_on_a_stick.png",
350 inventory_image = "mcl_mobitems_carrot_on_a_stick.png",
351 sounds = { breaks = "default_tool_breaks" },
355 -- Poor-man's recipes for carrot on a stick
356 if c("carrot_on_a_stick") and c("stick") and c("string") and minetest.get_modpath("farming") then
357 minetest.register_craft({
358 output = "mobs_mc:carrot_on_a_stick",
359 recipe = {
360 {"", "", "farming:string" },
361 {"", "group:stick", "farming:string" },
362 {"group:stick", "", "farming:bread" },
366 -- FIXME: Identify correct farming mod (check if it includes the carrot item)
367 minetest.register_craft({
368 output = "mobs_mc:carrot_on_a_stick",
369 recipe = {
370 {"", "", "farming:string" },
371 {"", "group:stick", "farming:string" },
372 {"group:stick", "", "farming:carrot" },
377 if c("carrot_on_a_stick") and c("stick") and c("string") and minetest.get_modpath("fishing") and minetest.get_modpath("farming") then
378 minetest.register_craft({
379 type = "shapeless",
380 output = "mobs_mc:carrot_on_a_stick",
381 recipe = {"fishing:pole_wood", "farming:carrot"},
385 -- Rabbit
386 if c("rabbit_raw") then
387 minetest.register_craftitem("mobs_mc:rabbit_raw", {
388 description = S("Raw Rabbit"),
389 _doc_items_longdesc = S("Raw rabbit is a food item from a dead rabbit. It can be eaten safely. Cooking it will increase its nutritional value."),
390 inventory_image = "mcl_mobitems_rabbit_raw.png",
391 groups = { food = 2, eatable = 3 },
392 on_use = minetest.item_eat(3),
396 if c("rabbit_cooked") then
397 minetest.register_craftitem("mobs_mc:rabbit_cooked", {
398 description = S("Cooked Rabbit"),
399 _doc_items_longdesc = S("This is a food item which can be eaten."),
400 inventory_image = "mcl_mobitems_rabbit_cooked.png",
401 groups = { food = 2, eatable = 5 },
402 on_use = minetest.item_eat(5),
406 if c("rabbit_raw") and c("rabbit_cooked") then
407 minetest.register_craft({
408 type = "cooking",
409 output = "mobs_mc:rabbit_cooked",
410 recipe = "mobs_mc:rabbit_raw",
411 cooktime = 5,
415 if c("rabbit_hide") then
416 minetest.register_craftitem("mobs_mc:rabbit_hide", {
417 description = S("Rabbit Hide"),
418 _doc_items_longdesc = S("Rabbit hide is used to create leather."),
419 inventory_image = "mcl_mobitems_rabbit_hide.png"
423 if c("leather") and c("rabbit_hide") then
424 minetest.register_craft({
425 output = "mobs:leather",
426 recipe = {
427 { "mobs_mc:rabbit_hide", "mobs_mc:rabbit_hide" },
428 { "mobs_mc:rabbit_hide", "mobs_mc:rabbit_hide" },
433 if c("rabbit_foot") then
434 minetest.register_craftitem("mobs_mc:rabbit_foot", {
435 description = S("Rabbit's Foot"),
436 _doc_items_longdesc = S("This item is used in brewing."),
437 inventory_image = "mcl_mobitems_rabbit_foot.png"
441 -- Sheep
442 if c("mutton_raw") then
443 minetest.register_craftitem("mobs_mc:mutton_raw", {
444 description = S("Raw Mutton"),
445 _doc_items_longdesc = S("Raw mutton is the flesh from a sheep and can be eaten safely. Cooking it will greatly increase its nutritional value."),
446 inventory_image = "mcl_mobitems_mutton_raw.png",
447 groups = { food = 2, eatable = 4 },
448 on_use = minetest.item_eat(4),
452 if c("mutton_cooked") then
453 minetest.register_craftitem("mobs_mc:mutton_cooked", {
454 description = S("Cooked Mutton"),
455 _doc_items_longdesc = S("Cooked mutton is the cooked flesh from a sheep and is used as food."),
456 inventory_image = "mcl_mobitems_mutton_cooked.png",
457 groups = { food = 2, eatable = 8 },
458 on_use = minetest.item_eat(8),
462 if c("mutton_raw") and c("mutton_cooked") then
463 minetest.register_craft({
464 type = "cooking",
465 output = "mobs_mc:mutton_cooked",
466 recipe = "mobs_mc:mutton_raw",
467 cooktime = 5,
471 -- Shulker
472 if c("shulker_shell") then
473 minetest.register_craftitem("mobs_mc:shulker_shell", {
474 description = S("Shulker Shell"),
475 _doc_items_longdesc = S("Shulker shells are used in crafting. They are dropped from dead shulkers."),
476 inventory_image = "mcl_mobitems_shulker_shell.png",
477 groups = { craftitem = 1 },
481 -- Magma cube
482 if c("magma_cream") then
483 minetest.register_craftitem("mobs_mc:magma_cream", {
484 description = S("Magma Cream"),
485 _doc_items_longdesc = S("Magma cream is a crafting component."),
486 wield_image = "mcl_mobitems_magma_cream.png",
487 inventory_image = "mcl_mobitems_magma_cream.png",
488 groups = { brewitem = 1 },
492 -- Slime
493 if c("slimeball") then
494 minetest.register_craftitem("mobs_mc:slimeball", {
495 description = S("Slimeball"),
496 _doc_items_longdesc = S("Slimeballs are used in crafting. They are dropped from slimes."),
497 inventory_image = "mcl_mobitems_slimeball.png"
499 if minetest.get_modpath("mesecons_materials") then
500 minetest.register_craft({
501 output = "mesecons_materials:glue",
502 recipe = {{ "mobs_mc:slimeball" }},
507 -- Spider
508 if c("spider_eye") then
509 minetest.register_craftitem("mobs_mc:spider_eye", {
510 description = S("Spider Eye"),
511 _doc_items_longdesc = S("Spider eyes are used mainly in crafting and brewing. Spider eyes can be eaten, but they poison you and reduce your health by 2 hit points."),
512 inventory_image = "mcl_mobitems_spider_eye.png",
513 wield_image = "mcl_mobitems_spider_eye.png",
514 -- Simplified poisonous food
515 groups = { food = 2, eatable = -2 },
516 on_use = minetest.item_eat(-2),
520 -- Evoker
521 if c("totem") then
522 local hud_totem = {}
524 -- Totem of Undying
525 minetest.register_craftitem("mobs_mc:totem", {
526 description = S("Totem of Undying"),
527 _doc_items_longdesc = S("A totem of undying is a rare artifact which may safe you from certain death."),
528 _doc_items_usagehelp = S("The totem only works while you hold it in your hand. If you receive fatal damage, you are saved from death and you get a second chance with 1 HP. The totem is destroyed in the process, however."),
529 inventory_image = "mcl_totems_totem.png",
530 wield_image = "mcl_totems_totem.png",
531 stack_max = 1,
534 minetest.register_on_leaveplayer(function(player)
535 hud_totem[player:get_player_name()] = nil
536 end)
538 -- Save the player from death when holding totem of undying in hand
539 minetest.register_on_player_hpchange(function(player, hp_change)
540 local hp = player:get_hp()
541 -- Fatal damage?
542 if hp + hp_change <= 0 then
543 local wield = player:get_wielded_item()
544 if wield:get_name() == "mobs_mc:totem" then
545 local ppos = player:get_pos()
546 local pnname = minetest.get_node(ppos).name
547 -- Some exceptions when _not_ to save the player
548 for n=1, #mobs_mc.misc.totem_fail_nodes do
549 if pnname == mobs_mc.misc.totem_fail_nodes[n] then
550 return hp_change
553 -- Reset breath as well
554 if player:get_breath() < 11 then
555 player:set_breath(10)
557 if not minetest.settings:get_bool("creative_mode") then
558 wield:take_item()
559 player:set_wielded_item(wield)
561 -- Effects
562 minetest.sound_play({name = "mcl_totems_totem", gain=1}, {pos=ppos, max_hear_distance=16})
564 -- Big totem overlay
565 if not hud_totem[player:get_player_name()] then
566 hud_totem[player:get_player_name()] = player:hud_add({
567 hud_elem_type = "image",
568 text = "mcl_totems_totem.png",
569 position = { x=0.5, y=1 },
570 scale = { x=17, y=17 },
571 offset = { x=0, y=-178 },
573 minetest.after(3, function(player)
574 if player and player:is_player() then
575 local name = player:get_player_name()
576 if hud_totem[name] then
577 player:hud_remove(hud_totem[name])
578 hud_totem[name] = nil
581 end, player)
584 -- Set HP to exactly 1
585 return -hp + 1
588 return hp_change
589 end, true)
592 -- Rotten flesh
593 if c("rotten_flesh") then
594 minetest.register_craftitem("mobs_mc:rotten_flesh", {
595 description = S("Rotten Flesh"),
596 _doc_items_longdesc = S("Yuck! This piece of flesh clearly has seen better days. Eating it will only poison you and reduces your health by 4 hit points. But tamed wolves can eat it just fine."),
597 inventory_image = "mcl_mobitems_rotten_flesh.png",
598 -- Simplified poisonous food
599 groups = { food = 2, eatable = -4 },
600 on_use = minetest.item_eat(-4),
604 -- Misc.
605 if c("nether_star") then
606 minetest.register_craftitem("mobs_mc:nether_star", {
607 description = S("Nether Star"),
608 _doc_items_longdesc = S("A nether star is a crafting component. It is dropped from the Wither."),
609 inventory_image = "mcl_mobitems_nether_star.png"
613 if c("snowball") and minetest.get_modpath("default") then
614 minetest.register_craft({
615 output = "mobs_mc:snowball 2",
616 recipe = {
617 {"default:snow"},
620 minetest.register_craft({
621 output = "default:snow 2",
622 recipe = {
623 {"mobs_mc:snowball", "mobs_mc:snowball"},
624 {"mobs_mc:snowball", "mobs_mc:snowball"},
627 -- Change the appearance of default snow to avoid confusion with snowball
628 minetest.override_item("default:snow", {
629 inventory_image = "",
630 wield_image = "",
634 if c("bone") then
635 minetest.register_craftitem("mobs_mc:bone", {
636 description = S("Bone"),
637 _doc_items_longdesc = S("Bones can be used to tame wolves so they will protect you. They are also useful as a crafting ingredient."),
638 _doc_items_usagehelp = S("Hold the bone in your hand near wolves to attract them. Rightclick the wolf to give it a bone and tame it."),
639 inventory_image = "mcl_mobitems_bone.png"
641 if minetest.get_modpath("bones") then
642 minetest.register_craft({
643 output = "mobs_mc:bone 3",
644 recipe = {{ "bones:bones" }},