From dc7b1869b747f829bd984abc63a441707e8442da Mon Sep 17 00:00:00 2001 From: the-real-herowl Date: Sat, 27 Apr 2024 04:28:21 +0200 Subject: [PATCH] Move most of the game to the new API --- mods/ENTITIES/mcl_mobs/physics.lua | 2 +- mods/ENVIRONMENT/mcl_raids/init.lua | 6 +++--- mods/ITEMS/mcl_core/craftitems.lua | 28 ++++++++++++++-------------- mods/ITEMS/mcl_farming/potatoes.lua | 2 +- mods/ITEMS/mcl_fishing/init.lua | 3 ++- mods/ITEMS/mcl_mobitems/init.lua | 2 +- mods/ITEMS/mcl_potions/functions.lua | 1 + mods/ITEMS/mcl_sus_stew/init.lua | 18 +++++++++--------- 8 files changed, 32 insertions(+), 30 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/physics.lua b/mods/ENTITIES/mcl_mobs/physics.lua index 705b22dbb..73aefb509 100644 --- a/mods/ENTITIES/mcl_mobs/physics.lua +++ b/mods/ENTITIES/mcl_mobs/physics.lua @@ -684,7 +684,7 @@ function mob_class:do_env_damage() self.object:set_velocity({x = 0, y = 0, z = 0}) -- wither rose effect elseif self.standing_in == "mcl_flowers:wither_rose" then - mcl_potions.withering_func(self.object, 1, 2) + mcl_potions.give_effect_by_level("withering", self.object, 2, 2) end local nodef = minetest.registered_nodes[self.standing_in] diff --git a/mods/ENVIRONMENT/mcl_raids/init.lua b/mods/ENVIRONMENT/mcl_raids/init.lua index 208ee93e0..1b762b0e9 100644 --- a/mods/ENVIRONMENT/mcl_raids/init.lua +++ b/mods/ENVIRONMENT/mcl_raids/init.lua @@ -104,11 +104,11 @@ function mcl_raids.promote_to_raidcaptain(c) -- object mcl_raids.drop_obanner(pos) if cmi_cause and cmi_cause.type == "punch" and cmi_cause.puncher:is_player() then awards.unlock(cmi_cause.puncher:get_player_name(), "mcl:voluntary_exile") - local lv = mcl_potions.get_effect(cmi_cause.puncher, "bad_omen") + local lv = mcl_potions.get_effect_level(cmi_cause.puncher, "bad_omen") if not lv then lv = 0 else lv = lv.factor end lv = math.max(5,lv + 1) - mcl_potions.bad_omen_func(cmi_cause.puncher,lv,6000) + mcl_potions.give_effect_by_level("bad_omen", cmi_cause.puncher, lv, 6000) end end if old_ondie then return old_ondie(self,pos,cmi_cause) end @@ -310,7 +310,7 @@ mcl_events.register_event("raid",{ self.mobs = {} self.health_max = 1 self.health = 0 - local lv = mcl_potions.get_effect(minetest.get_player_by_name(self.player), "bad_omen") + local lv = mcl_potions.get_effect_level(minetest.get_player_by_name(self.player), "bad_omen") if lv and lv.factor and lv.factor > 1 then self.max_stage = 6 end end, cond_progress = function(self) diff --git a/mods/ITEMS/mcl_core/craftitems.lua b/mods/ITEMS/mcl_core/craftitems.lua index e89fe124a..f95d42ad2 100644 --- a/mods/ITEMS/mcl_core/craftitems.lua +++ b/mods/ITEMS/mcl_core/craftitems.lua @@ -167,17 +167,17 @@ local function eat_gapple(itemstack, placer, pointed_thing) return itemstack end - local regen_duration, absorbtion_factor = 5, 1 + local regen_duration, absorption = 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) + regen_duration, absorption = 20, 4 + mcl_potions.give_effect("fire_resistance", placer, 1, 300) + mcl_potions.give_effect_by_level("leaping", placer, 1, 300) if enable_fapples then - mcl_potions.swiftness_func(placer, absorbtion_factor, 120) + mcl_potions.give_effect_by_level("swiftness", placer, absorption, 120) end end - -- TODO: Absorbtion - mcl_potions.regeneration_func(placer, 2, regen_duration) + mcl_potions.give_effect_by_level("absorption", placer, absorption, 120) + mcl_potions.give_effect_by_level("regeneration", placer, 2, regen_duration) return gapple_hunger_restore(itemstack, placer, pointed_thing) end @@ -206,17 +206,17 @@ local function eat_gapple_delayed(itemstack, placer, pointed_thing) return itemstack end - local regen_duration, absorbtion_factor = 5, 1 + local regen_duration, absorption = 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) + regen_duration, absorption = 20, 4 + mcl_potions.give_effect("fire_resistance", placer, 1, 300) + mcl_potions.give_effect_by_level("leaping", placer, 1, 300) if enable_fapples then - mcl_potions.swiftness_func(placer, absorbtion_factor, 120) + mcl_potions.give_effect_by_level("swiftness", placer, absorption, 120) end end - -- TODO: Absorbtion - mcl_potions.regeneration_func(placer, 2, regen_duration) + mcl_potions.give_effect_by_level("absorption", placer, absorption, 120) + mcl_potions.give_effect_by_level("regeneration", placer, 2, regen_duration) --return gapple_hunger_restore(itemstack, placer, pointed_thing) end diff --git a/mods/ITEMS/mcl_farming/potatoes.lua b/mods/ITEMS/mcl_farming/potatoes.lua index d3f4e4fc0..66c5169c4 100644 --- a/mods/ITEMS/mcl_farming/potatoes.lua +++ b/mods/ITEMS/mcl_farming/potatoes.lua @@ -142,7 +142,7 @@ minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, -- 60% chance of poisoning with poisonous potato if itemstack:get_name() == "mcl_farming:potato_item_poison" then if math.random(1,10) >= 6 then - mcl_potions.poison_func(user, 1, 5) + mcl_potions.give_effect_by_level("poison", user, 1, 5) end end diff --git a/mods/ITEMS/mcl_fishing/init.lua b/mods/ITEMS/mcl_fishing/init.lua index e3bf181f5..163c103a3 100644 --- a/mods/ITEMS/mcl_fishing/init.lua +++ b/mods/ITEMS/mcl_fishing/init.lua @@ -519,7 +519,8 @@ minetest.register_craftitem("mcl_fishing:pufferfish_raw", { minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing) if itemstack:get_name() == "mcl_fishing:pufferfish_raw" then - mcl_potions.poison_func(user, 1/3, 60) + mcl_potions.give_effect_by_level("poison", user, 3, 60) + mcl_potions.give_effect_by_level("nausea", user, 2, 20) end end ) diff --git a/mods/ITEMS/mcl_mobitems/init.lua b/mods/ITEMS/mcl_mobitems/init.lua index 01b9a5039..f74d254ba 100644 --- a/mods/ITEMS/mcl_mobitems/init.lua +++ b/mods/ITEMS/mcl_mobitems/init.lua @@ -580,6 +580,6 @@ minetest.register_craft({ minetest.register_on_item_eat(function (hp_change, replace_with_item, itemstack, user, pointed_thing) -- poisoning with spider eye if itemstack:get_name() == "mcl_mobitems:spider_eye" then - mcl_potions.poison_func(user, 1, 4) + mcl_potions.give_effect_by_level("poison", user, 1, 4) end end) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 4ab98491a..460a1cb8f 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -717,6 +717,7 @@ mcl_potions.register_effect({ return S("danger is imminent") end, particle_color = "#472331", + uses_factor = true, }) mcl_potions.register_effect({ diff --git a/mods/ITEMS/mcl_sus_stew/init.lua b/mods/ITEMS/mcl_sus_stew/init.lua index d34dbbf00..a4c3aae31 100644 --- a/mods/ITEMS/mcl_sus_stew/init.lua +++ b/mods/ITEMS/mcl_sus_stew/init.lua @@ -8,8 +8,8 @@ local eat = minetest.item_eat(6, "mcl_core:bowl") --6 hunger points, player rece local flower_effect = { [ "mcl_flowers:allium" ] = "fire_resistance", [ "mcl_flowers:lily_of_the_valley" ] = "poison", - [ "mcl_flowers:blue_orchid" ] = "hunger", - [ "mcl_flowers:dandelion" ] = "hunger", + [ "mcl_flowers:blue_orchid" ] = "food_poisoning", + [ "mcl_flowers:dandelion" ] = "food_poisoning", [ "mcl_flowers:cornflower" ] = "jump", [ "mcl_flowers:oxeye_daisy" ] = "regeneration", [ "mcl_flowers:poppy" ] = "night_vision" @@ -17,31 +17,31 @@ local flower_effect = { local effects = { [ "fire_resistance" ] = function(itemstack, placer, pointed_thing) - mcl_potions.fire_resistance_func(placer, 1, 4) + mcl_potions.give_effect("fire_resistance", placer, 1, 4) return eat(itemstack, placer, pointed_thing) end, [ "poison" ] = function(itemstack, placer, pointed_thing) - mcl_potions.poison_func(placer, 1, 12) + mcl_potions.give_effect_by_level("poison", placer, 1, 12) return eat(itemstack, placer, pointed_thing) end, - [ "hunger" ] = function(itemstack, placer, pointed_thing, player) - mcl_hunger.item_eat(6, "mcl_core:bowl", 3.5, 0, 100) + [ "food_poisoning" ] = function(itemstack, placer, pointed_thing, player) + mcl_potions.give_effect_by_level("food_poisoning", placer, 10, 12) return eat(itemstack, placer, pointed_thing) end, ["jump"] = function(itemstack, placer, pointed_thing) - mcl_potions.leaping_func(placer, 1, 6) + mcl_potions.give_effect_by_level("leaping", placer, 1, 6) return eat(itemstack, placer, pointed_thing) end, ["regeneration"] = function(itemstack, placer, pointed_thing) - mcl_potions.regeneration_func(placer, 1, 8) + mcl_potions.give_effect_by_level("regeneration", placer, 1, 8) return eat(itemstack, placer, pointed_thing) end, ["night_vision"] = function(itemstack, placer, pointed_thing) - mcl_potions.night_vision_func(placer, 1, 5) + mcl_potions.give_effect("night_vision", placer, 1, 5) return eat(itemstack, placer, pointed_thing) end, }