From a92273b930e88e6e1dd7ca6c0da14d357c82fb41 Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Fri, 22 Jan 2021 19:08:01 +0100 Subject: [PATCH] Gold apples give the player effects; Added Enchanted Golden Apples (Swiftnes & Leaping instead of Absorbtion and Resistance) --- mods/ITEMS/mcl_core/craftitems.lua | 36 +++++++++++++++++++++++++----- mods/ITEMS/mcl_core/depends.txt | 1 + 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_core/craftitems.lua b/mods/ITEMS/mcl_core/craftitems.lua index 122445095..b27a6ca6a 100644 --- a/mods/ITEMS/mcl_core/craftitems.lua +++ b/mods/ITEMS/mcl_core/craftitems.lua @@ -144,17 +144,41 @@ minetest.register_craftitem("mcl_core:apple", { _mcl_saturation = 2.4, }) --- TODO: Status effects +local gapple_hunger_restore = minetest.item_eat(4) + +local function eat_gapple(itemstack, placer, pointed_thing) + local regen_duration, absorbtion_factor = 5, 1 + if itemstack:get_name() == "mcl_core:apple_gold_enchanted" then + regen_duration, absorbtion_factor = 20, 4 + mcl_potions.fire_resistance_func(placer, 1, 300) + mcl_potions.leaping_func(placer, 1, 300) + end + mcl_potions.swiftness_func(placer, absorbtion_factor, 120) -- TODO: Absorbtion + mcl_potions.regeneration_func(placer, 2, regen_duration) + return gapple_hunger_restore(itemstack, placer, pointed_thing) +end + minetest.register_craftitem("mcl_core:apple_gold", { - -- TODO: Add special highlight color when this item is special + -- TODO: Add special highlight color description = S("Golden Apple"), _doc_items_longdesc = S("Golden apples are precious food items which can be eaten."), wield_image = "mcl_core_apple_golden.png", inventory_image = "mcl_core_apple_golden.png", stack_max = 64, - -- TODO: Reduce to 4 when it's ready - on_place = minetest.item_eat(20), - on_secondary_use = minetest.item_eat(20), - groups = { food = 2, eatable = 20, can_eat_when_full = 1 }, + on_place = eat_gapple, + on_secondary_use = eat_gapple, + groups = { food = 2, eatable = 4, can_eat_when_full = 1 }, + _mcl_saturation = 9.6, +}) + +minetest.register_craftitem("mcl_core:apple_gold_enchanted", { + description = S("Enchanted Golden Apple"), + _doc_items_longdesc = S("Golden apples are precious food items which can be eaten."), + wield_image = "mcl_core_apple_golden.png" .. mcl_enchanting.overlay, + inventory_image = "mcl_core_apple_golden.png" .. mcl_enchanting.overlay, + stack_max = 64, + on_place = eat_gapple, + on_secondary_use = eat_gapple, + groups = { food = 2, eatable = 4, can_eat_when_full = 1 }, _mcl_saturation = 9.6, }) diff --git a/mods/ITEMS/mcl_core/depends.txt b/mods/ITEMS/mcl_core/depends.txt index 60ece3906..fb9861814 100644 --- a/mods/ITEMS/mcl_core/depends.txt +++ b/mods/ITEMS/mcl_core/depends.txt @@ -5,3 +5,4 @@ mcl_util mcl_worlds doc_items doc? +mcl_enchanting