From c78270e70b47fc416f2be2e4116d84e8789e5494 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 27 Jul 2020 00:45:53 +0400 Subject: [PATCH 01/12] Bed occupation fix --- mods/ITEMS/mcl_beds/functions.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index d73154ee4..abf9683a2 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -115,13 +115,16 @@ local function lay_down(player, pos, bed_pos, state, skip) mcl_beds.player[name] = nil player_in_bed = player_in_bed - 1 end + mcl_beds.pos[name] = nil + mcl_beds.bed_pos[name] = nil + if p then + player:set_pos(p) + end + -- skip here to prevent sending player specific changes (used for leaving players) if skip then return false end - if p then - player:set_pos(p) - end -- physics, eye_offset, etc player:set_eye_offset({x = 0, y = 0, z = 0}, {x = 0, y = 0, z = 0}) @@ -134,8 +137,6 @@ local function lay_down(player, pos, bed_pos, state, skip) player:get_meta():set_string("mcl_beds:sleeping", "false") hud_flags.wielditem = true mcl_player.player_set_animation(player, "stand" , 30) - mcl_beds.pos[name] = nil - mcl_beds.bed_pos[name] = nil -- lay down else @@ -360,7 +361,6 @@ end) minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() lay_down(player, nil, nil, false, true) - mcl_beds.player[name] = nil if check_in_beds() then minetest.after(5, function() if check_in_beds() then From 7d1f8ac314e92374642437e73edb95dfd3db6bc9 Mon Sep 17 00:00:00 2001 From: kay27 Date: Mon, 27 Jul 2020 01:12:10 +0400 Subject: [PATCH 02/12] Velocity check adjusted in mcl_beds --- mods/ITEMS/mcl_beds/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index abf9683a2..3bfe9e578 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -83,7 +83,7 @@ local function lay_down(player, pos, bed_pos, state, skip) end -- No sleeping while moving. Slightly different behaviour than in MC. - if vector.length(player:get_player_velocity()) > 0.001 then + if vector.length(player:get_player_velocity()) > 0.125 then minetest.chat_send_player(name, S("You have to stop moving before going to bed!")) return false end From 0cc179acc6b04c14589921a81c570491bb41db5e Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 27 Jul 2020 07:46:11 +0200 Subject: [PATCH 03/12] Add warning about bed velocity --- mods/ITEMS/mcl_beds/functions.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index 3bfe9e578..de2b75662 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -83,6 +83,9 @@ local function lay_down(player, pos, bed_pos, state, skip) end -- No sleeping while moving. Slightly different behaviour than in MC. + -- FIXME: Velocity threshold should be 0.01 but Minetest 5.3.0 + -- sometimes reports incorrect Y speed. A velocity threshold + -- of 0.125 still seems good enough. if vector.length(player:get_player_velocity()) > 0.125 then minetest.chat_send_player(name, S("You have to stop moving before going to bed!")) return false From 92385364e5434f6f77d192fdfb9b6745507ff73f Mon Sep 17 00:00:00 2001 From: kay27 Date: Thu, 30 Jul 2020 02:01:15 +0400 Subject: [PATCH 04/12] Fix beds #798 attempt 5 --- mods/ITEMS/mcl_beds/functions.lua | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index de2b75662..d93b2b84d 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -202,8 +202,13 @@ local function lay_down(player, pos, bed_pos, state, skip) return true end -local function update_formspecs(finished) - local ges = #minetest.get_connected_players() +local function update_formspecs(finished, players) + local ges + if players then + ges = #players + else + ges = #minetest.get_connected_players() + end local form_n = "size[6,5;true]" local all_in_bed = ges == player_in_bed local night_skip = is_night_skip_enabled() @@ -364,7 +369,14 @@ end) minetest.register_on_leaveplayer(function(player) local name = player:get_player_name() lay_down(player, nil, nil, false, true) - if check_in_beds() then + players = minetest.get_connected_players() + for n, player in ipairs(players) do + if player:get_player_name() == name then + players[n] = nil + break + end + end + if check_in_beds(players) then minetest.after(5, function() if check_in_beds() then update_formspecs(is_night_skip_enabled()) @@ -372,7 +384,7 @@ minetest.register_on_leaveplayer(function(player) end end) end - update_formspecs(false) + update_formspecs(false, players) end) minetest.register_on_player_receive_fields(function(player, formname, fields) From 64f9e39ebdf051f79f3df7ba89945eae52bc200e Mon Sep 17 00:00:00 2001 From: kay27 Date: Thu, 30 Jul 2020 03:59:30 +0400 Subject: [PATCH 05/12] slighty optimize the code --- mods/ITEMS/mcl_beds/functions.lua | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index d93b2b84d..b1a0ce4fd 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -202,13 +202,8 @@ local function lay_down(player, pos, bed_pos, state, skip) return true end -local function update_formspecs(finished, players) - local ges - if players then - ges = #players - else - ges = #minetest.get_connected_players() - end +local function update_formspecs(finished, ges) + local ges = ges or #minetest.get_connected_players() local form_n = "size[6,5;true]" local all_in_bed = ges == player_in_bed local night_skip = is_night_skip_enabled() @@ -384,7 +379,7 @@ minetest.register_on_leaveplayer(function(player) end end) end - update_formspecs(false, players) + update_formspecs(false, #players) end) minetest.register_on_player_receive_fields(function(player, formname, fields) From 3b954980926ef6804fa3d43105313d2c84f532aa Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 31 Jul 2020 10:41:44 +0200 Subject: [PATCH 06/12] Clean up potion/arrow names --- mods/ITEMS/mcl_potions/init.lua | 5 +- mods/ITEMS/mcl_potions/potions.lua | 93 ++++++++++++++++++------------ 2 files changed, 59 insertions(+), 39 deletions(-) diff --git a/mods/ITEMS/mcl_potions/init.lua b/mods/ITEMS/mcl_potions/init.lua index 13152653e..18df5b398 100644 --- a/mods/ITEMS/mcl_potions/init.lua +++ b/mods/ITEMS/mcl_potions/init.lua @@ -277,8 +277,9 @@ minetest.register_craftitem("mcl_potions:river_water", { }) -mcl_potions.register_splash("water", S("Splash Potion"), "#0022FF", {tt="No effect", potion_fun=function() end}) -mcl_potions.register_lingering("water", S("Lingering Potion"), "#0022FF", {tt="No effect", potion_fun=function() end}) +-- TODO: Extinguish fire, damage mobs +mcl_potions.register_splash("water", S("Splash Water Bottle"), "#0022FF", {tt="No effect", potion_fun=function() end}) +mcl_potions.register_lingering("water", S("Lingering Water Bottle"), "#0022FF", {tt="No effect", potion_fun=function() end}) minetest.register_craftitem("mcl_potions:speckled_melon", { description = S("Glistering Melon"), diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index 402b9a1d4..227abd042 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -106,8 +106,15 @@ local function register_potion(def) return function() end end + local desc + if not def.no_potion then + desc = S("@1 Potion", def.description) + else + desc = def.description + end + minetest.register_craftitem("mcl_potions:"..def.name, { - description = S(def.description), + description = desc, _tt_help = get_tt(def._tt, def.effect, dur), _doc_items_longdesc = def._longdesc, _doc_items_usagehelp = how_to_drink, @@ -146,15 +153,17 @@ local function register_potion(def) potion_fun = get_arrow_fun(def.effect, dur/8.), } - if def.color and def.name ~= "dragon_breath" then -- dont' splash dragon's breath... - mcl_potions.register_splash(def.name, S("Splash "..def.description), def.color, splash_def) - mcl_potions.register_lingering(def.name, S("Lingering "..def.description), def.color, ling_def) - mcl_potions.register_arrow(def.name, S("Arrow of "..def.description), def.color, arrow_def) + if def.color and not def.no_throwable then + mcl_potions.register_splash(def.name, S("Splash @1 Potion", def.description), def.color, splash_def) + mcl_potions.register_lingering(def.name, S("Lingering @1 Potion", def.description), def.color, ling_def) + if not def.no_arrow then + mcl_potions.register_arrow(def.name, S("Arrow of @1", def.description), def.color, arrow_def) + end end if def.is_II then - local desc_mod = " II" + local desc_mod = S(" II") local effect_II if def.name == "healing" or def.name == "harming" then @@ -171,7 +180,7 @@ local function register_potion(def) if def.name == "slowness" then dur_2 = 20 effect_II = 0.40 - desc_mod = " IV" + desc_mod = S(" IV") end local on_use = function (itemstack, user, pointed_thing) @@ -182,7 +191,7 @@ local function register_potion(def) end minetest.register_craftitem("mcl_potions:"..def.name.."_2", { - description = S(def.description..desc_mod), + description = S("@1 Potion@2", def.description, desc_mod), _tt_help = get_tt(def._tt_2, effect_II, dur_2), _doc_items_longdesc = def._longdesc, _doc_items_usagehelp = how_to_drink, @@ -230,10 +239,12 @@ local function register_potion(def) potion_fun = get_arrow_fun(effect_II, dur_2/8.), } - if def.color then - mcl_potions.register_splash(def.name.."_2", S("Splash "..def.description..desc_mod), def.color, splash_def_2) - mcl_potions.register_lingering(def.name.."_2", S("Lingering "..def.description..desc_mod), def.color, ling_def_2) - mcl_potions.register_arrow(def.name.."_2", S("Arrow of "..def.description..desc_mod), def.color, arrow_def_2) + if def.color and not def.no_throwable then + mcl_potions.register_splash(def.name.."_2", S("Splash @1@2 Potion", def.description, desc_mod), def.color, splash_def_2) + mcl_potions.register_lingering(def.name.."_2", S("Lingering @1@2 Potion", def.description, desc_mod), def.color, ling_def_2) + if not def.no_arrow then + mcl_potions.register_arrow(def.name.."_2", S("Arrow of @1@2", def.description, desc_mod), def.color, arrow_def_2) + end end end @@ -253,7 +264,7 @@ local function register_potion(def) end minetest.register_craftitem("mcl_potions:"..def.name.."_plus", { - description = S(def.description.." +"), + description = S("@1 + Potion", def.description), _tt_help = get_tt(def._tt_plus, def.effect, dur_pl), _doc_items_longdesc = def._longdesc, _doc_items_usagehelp = how_to_drink, @@ -281,10 +292,12 @@ local function register_potion(def) tt = get_tt(def._tt_pl, def.effect, dur_pl/8.), potion_fun = get_arrow_fun(def.effect, dur_pl/8.), } - if def.color then - mcl_potions.register_splash(def.name.."_plus", S("Splash "..def.description.." +"), def.color, splash_def_pl) - mcl_potions.register_lingering(def.name.."_plus", S("Lingering "..def.description.." +"), def.color, ling_def_pl) - mcl_potions.register_arrow(def.name.."_plus", S("Arrow of"..def.description.." +"), def.color, arrow_def_pl) + if def.color and not def.no_throwable then + mcl_potions.register_splash(def.name.."_plus", S("Splash @1 + Potion", def.description), def.color, splash_def_pl) + mcl_potions.register_lingering(def.name.."_plus", S("Lingering @1 + Potion", def.description), def.color, ling_def_pl) + if not def.no_arrow then + mcl_potions.register_arrow(def.name.."_plus", S("Arrow of @1 +", def.description), def.color, arrow_def_pl) + end end end @@ -309,7 +322,8 @@ end local awkward_def = { name = "awkward", - description = "Awkward Potion", + description = S("Awkward"), + no_arrow = true, _tt = S("No effect"), _longdesc = S("Has an awkward taste and is used for brewing potions."), color = "#0000FF", @@ -319,7 +333,8 @@ local awkward_def = { local mundane_def = { name = "mundane", - description = "Mundane Potion", + description = S("Mundane"), + no_arrow = true, _tt = S("No effect"), longdesc = S("Has a terrible taste and is not useful for brewing potions."), color = "#0000FF", @@ -328,7 +343,8 @@ local mundane_def = { local thick_def = { name = "thick", - description = "Thick Potion", + description = S("Thick"), + no_arrow = true, _tt = S("No effect"), _longdesc = S("Has a bitter taste and is not useful for brewing potions."), color = "#0000FF", @@ -337,7 +353,10 @@ local thick_def = { local dragon_breath_def = { name = "dragon_breath", - description = "Dragon's Breath", + description = S("Dragon's Breath"), + no_arrow = true, + no_potion = true, + no_throwable = true, _tt = S("No effect"), _longdesc = S("Combine with Splash potions to create a Lingering effect"), color = "#BF4567", @@ -348,7 +367,7 @@ local dragon_breath_def = { local healing_def = { name = "healing", - description = "Healing Potion", + description = S("Healing"), _tt = S("+2 Hearts"), _tt_2 = S("+4 Hearts"), _longdesc = S("Drink to heal yourself"), @@ -361,7 +380,7 @@ local healing_def = { local harming_def = { name = "harming", - description = "Harming Potion", + description = S("Harming"), _tt = S("-3 Hearts"), _tt_II = S("-6 Hearts"), _longdesc = S("Drink to heal yourself"), @@ -374,7 +393,7 @@ local harming_def = { local night_vision_def = { name = "night_vision", - description = "Night Vision Potion", + description = S("Night Vision"), _tt = nil, _longdesc = S("Drink to see in the dark."), color = "#1010AA", @@ -386,7 +405,7 @@ local night_vision_def = { local swiftness_def = { name = "swiftness", - description = "Swiftness Potion", + description = S("Swiftness"), _tt = nil, _longdesc = S("Drink to increase your speed."), color = "#009999", @@ -399,7 +418,7 @@ local swiftness_def = { local slowness_def = { name = "slowness", - description = "Slowness Potion", + description = S("Slowness"), _tt = nil, _longdesc = S("Drink to become sluggish"), color = "#000080", @@ -413,7 +432,7 @@ local slowness_def = { local leaping_def = { name = "leaping", - description = "Leaping Potion", + description = S("Leaping"), _tt = nil, _longdesc = S("Drink to leap tall buildings in a single bound!"), color = "#00CC33", @@ -426,7 +445,7 @@ local leaping_def = { local poison_def = { name = "poison", - description = "Poison Potion", + description = S("Poison"), _tt = nil, _longdesc = S("Poison mobs or players with this dangerous potion."), color = "#447755", @@ -440,7 +459,7 @@ local poison_def = { local regeneration_def = { name = "regeneration", - description = "Regeneration Potion", + description = S("Regeneration"), _tt = nil, _longdesc = S("Regenerate mobs or players with this healing potion over time."), color = "#B52CC2", @@ -453,7 +472,7 @@ local regeneration_def = { local invisibility_def = { name = "invisibility", - description = "Invisibility Potion", + description = S("Invisibility"), _tt = nil, _longdesc = S("Drink and become invisibile to mobs and players."), color = "#B0B0B0", @@ -464,7 +483,7 @@ local invisibility_def = { local water_breathing_def = { name = "water_breathing", - description = "Water Breathing Potion", + description = S("Water Breathing"), _tt = nil, _longdesc = S("Drink and breath underwater."), color = "#0000AA", @@ -475,7 +494,7 @@ local water_breathing_def = { local fire_resistance_def = { name = "fire_resistance", - description = "Fire Resistance Potion", + description = S("Fire Resistance"), _tt = nil, _longdesc = S("Drink and resist fire damage."), color = "#D0A040", @@ -499,7 +518,7 @@ end -- minetest.register_craftitem("mcl_potions:weakness", { --- description = S("Weakness Potion"), +-- description = S("Weakness"), -- _tt_help = S("-4 HP damage | 1:30"), -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#6600AA"), @@ -523,7 +542,7 @@ end -- }) -- -- minetest.register_craftitem("mcl_potions:weakness_plus", { --- description = S("Weakness Potion +"), +-- description = S("Weakness +"), -- _tt_help = S("-4 HP damage | 4:00"), -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#7700BB"), @@ -547,7 +566,7 @@ end -- }) -- -- minetest.register_craftitem("mcl_potions:strength", { --- description = S("Strength Potion"), +-- description = S("Strength"), -- _tt_help = S("+3 HP damage | 3:00"), -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444D4"), @@ -571,7 +590,7 @@ end -- }) -- -- minetest.register_craftitem("mcl_potions:strength_2", { --- description = S("Strength Potion II"), +-- description = S("Strength II"), -- _tt_help = S("+6 HP damage | 1:30"), -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444E4"), @@ -595,7 +614,7 @@ end -- }) -- -- minetest.register_craftitem("mcl_potions:strength_plus", { --- description = S("Strength Potion +"), +-- description = S("Strength +"), -- _tt_help = S("+3 HP damage | 8:00"), -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444F4"), From 5af124d732c74f8f7e086235daa4dbcf228703c8 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 31 Jul 2020 10:43:42 +0200 Subject: [PATCH 07/12] Tweak potion tooltips --- mods/ITEMS/mcl_potions/potions.lua | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index 227abd042..c82d4ef1d 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -66,10 +66,10 @@ local function register_potion(def) if effect and def.is_dur then _tt = perc_string(effect).." | "..time_string(dur) if def.name == "poison" or def.name == "regeneration" then - _tt = "1/2 Heart/"..effect.."sec | "..time_string(dur) + _tt = "1/2 heart/"..effect.."s | "..time_string(dur) end elseif def.name == "healing" or def.name == "harming" then - _tt = (effect / 2).." Hearts" + _tt = (effect / 2).." hearts" else _tt = tt or time_string(dur) or S("No effect") end @@ -368,8 +368,8 @@ local dragon_breath_def = { local healing_def = { name = "healing", description = S("Healing"), - _tt = S("+2 Hearts"), - _tt_2 = S("+4 Hearts"), + _tt = S("+2 hearts"), + _tt_2 = S("+4 hearts"), _longdesc = S("Drink to heal yourself"), color = "#CC0000", effect = 4, @@ -381,8 +381,8 @@ local healing_def = { local harming_def = { name = "harming", description = S("Harming"), - _tt = S("-3 Hearts"), - _tt_II = S("-6 Hearts"), + _tt = S("-3 hearts"), + _tt_II = S("-6 hearts"), _longdesc = S("Drink to heal yourself"), color = "#660099", effect = -6, From eec9cd90120bb003caade00cb282ca780d060bd5 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 31 Jul 2020 10:45:22 +0200 Subject: [PATCH 08/12] Mark night vision arrows as WIP --- mods/MISC/mcl_wip/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/MISC/mcl_wip/init.lua b/mods/MISC/mcl_wip/init.lua index c72907bd6..351714474 100644 --- a/mods/MISC/mcl_wip/init.lua +++ b/mods/MISC/mcl_wip/init.lua @@ -36,6 +36,8 @@ local wip_items = { -- "mcl_potions:strength_lingering", -- "mcl_potions:strength_plus_lingering", -- "mcl_potions:strength_2_lingering", + "mcl_potions:night_vision_arrow", + "mcl_potions:night_vision_plus_arrow", } local experimental_items = { } From 23dc977cec9d61d281485d8dc1efc8515b781fe1 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 31 Jul 2020 15:20:59 +0200 Subject: [PATCH 09/12] Add IRC channel --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d72daef03..cb74c5a35 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,3 +80,8 @@ Depending on what you add, the chances for inclusion vary: Report all bugs and missing Minecraft features here: + +## Direct discussion +We have an IRC channel! Join us on #mineclone2 in freenode.net. + + From c63c92f597f0ea67707bf2ff25f0d865dba0ea5b Mon Sep 17 00:00:00 2001 From: MysticTempest Date: Fri, 31 Jul 2020 08:35:40 -0500 Subject: [PATCH 10/12] Copy upstream's pathfinding out of water, then copy & rework the cliff check into a check for land mobs to avoid water. --- mods/ENTITIES/mcl_mobs/api.lua | 106 +++++++++++++++++++++++---------- 1 file changed, 76 insertions(+), 30 deletions(-) diff --git a/mods/ENTITIES/mcl_mobs/api.lua b/mods/ENTITIES/mcl_mobs/api.lua index ec691c624..2d45bb257 100644 --- a/mods/ENTITIES/mcl_mobs/api.lua +++ b/mods/ENTITIES/mcl_mobs/api.lua @@ -724,6 +724,42 @@ local is_at_cliff_or_danger = function(self) end +-- copy the 'mob facing cliff_or_danger check' from above, and rework to avoid water +local is_at_water_danger = function(self) + + + if not self.object:get_luaentity() then + return false + end + local yaw = self.object:get_yaw() + local dir_x = -sin(yaw) * (self.collisionbox[4] + 0.5) + local dir_z = cos(yaw) * (self.collisionbox[4] + 0.5) + local pos = self.object:get_pos() + local ypos = pos.y + self.collisionbox[2] -- just above floor + + local free_fall, blocker = minetest.line_of_sight( + {x = pos.x + dir_x, y = ypos, z = pos.z + dir_z}, + {x = pos.x + dir_x, y = ypos - 3, z = pos.z + dir_z}) + if free_fall then + return true + else + local bnode = minetest.get_node(blocker) + local waterdanger = is_node_waterhazard(self, bnode.name) + if + waterdanger and (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) then + return false + elseif waterdanger and (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) == false then + return true + else + local def = minetest.registered_nodes[bnode.name] + return (not def and def.walkable) + end + end + + return false +end + + -- get node but use fallback for nil or unknown local node_ok = function(pos, fallback) @@ -2049,40 +2085,40 @@ local do_states = function(self, dtime) local is_in_danger = false if lp then - - local is_in_danger = false - - -- if mob is flying, only check for node it is currently in (no contact with node below) - if flight_check(self) then - is_in_danger = is_node_dangerous(self, self.standing_in) - elseif (is_node_dangerous(self, self.standing_in) or - is_node_dangerous(self, self.standing_on)) or (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) then - is_in_danger = true - end - -- If mob in or on dangerous block, look for land - if is_in_danger then - lp = minetest.find_node_near(s, 5, {"group:solid"}) + if (is_node_dangerous(self, self.standing_in) or + is_node_dangerous(self, self.standing_on)) or (is_node_waterhazard(self, self.standing_in) or is_node_waterhazard(self, self.standing_on)) and (not self.fly) then + is_in_danger = true - -- did we find land? - if lp then + -- If mob in or on dangerous block, look for land + if is_in_danger then + -- Better way to find shore - copied from upstream + lp = minetest.find_nodes_in_area_under_air( + {x = s.x - 5, y = s.y - 0.5, z = s.z - 5}, + {x = s.x + 5, y = s.y + 1, z = s.z + 5}, + {"group:solid"}) - local vec = { - x = lp.x - s.x, - z = lp.z - s.z - } + lp = #lp > 0 and lp[random(#lp)] + + -- did we find land? + if lp then - yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate + local vec = { + x = lp.x - s.x, + z = lp.z - s.z + } - if lp.x > s.x then yaw = yaw + pi end + yaw = (atan(vec.z / vec.x) + pi / 2) - self.rotate - -- look towards land and jump/move in that direction - yaw = set_yaw(self, yaw, 6) - do_jump(self) - set_velocity(self, self.walk_velocity) - else - yaw = yaw + random(-0.5, 0.5) - end + + if lp.x > s.x then yaw = yaw + pi end + + -- look towards land and move in that direction + yaw = set_yaw(self, yaw, 6) + set_velocity(self, self.walk_velocity) + + end + end -- A danger is near but mob is not inside else @@ -3218,8 +3254,6 @@ local mob_step = function(self, dtime) breed(self) - follow_flop(self) - if do_states(self, dtime) then return end @@ -3228,6 +3262,18 @@ local mob_step = function(self, dtime) runaway_from(self) + if is_at_water_danger(self) and self.state ~= "attack" then + if random(1, 10) <= 6 then + set_velocity(self, 0) + self.state = "stand" + set_animation(self, "stand") + yaw = yaw + random(-0.5, 0.5) + yaw = set_yaw(self, yaw, 8) + end + end + + follow_flop(self) + if is_at_cliff_or_danger(self) then set_velocity(self, 0) self.state = "stand" From fb3fade4eb563f42c8f67630c282a3eb80b50591 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Aug 2020 02:15:19 +0200 Subject: [PATCH 11/12] Remove dead code in mcl_brewing --- mods/ITEMS/mcl_brewing/init.lua | 89 +++------------------------------ 1 file changed, 8 insertions(+), 81 deletions(-) diff --git a/mods/ITEMS/mcl_brewing/init.lua b/mods/ITEMS/mcl_brewing/init.lua index c796606b9..717e660e4 100644 --- a/mods/ITEMS/mcl_brewing/init.lua +++ b/mods/ITEMS/mcl_brewing/init.lua @@ -4,7 +4,6 @@ local function active_brewing_formspec(fuel_percent, brew_percent) return "size[9,8.75]".. "background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory.png]".. - -- "background[-0.19,-0.25;9.5,9.5;mcl_brewing_inventory_active.png]".. "label[4,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Brewing Stand"))).."]".. "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. "list[current_player;main;0,4.5;9,3;9]".. @@ -375,7 +374,7 @@ minetest.register_node("mcl_brewing:stand_000", { _doc_items_longdesc = S("The stand allows you to brew potions!"), _doc_items_usagehelp = doc_string, _tt_help = S("Brew Potions"), - groups = {pickaxey=1, falling_node=1, brewitem=1, not_in_creative_inventory = 0, not_in_craft_guide = 0}, + groups = {pickaxey=1, falling_node=1, brewitem=1 }, tiles = tiles, drop = "mcl_brewing:stand", paramtype = "light", @@ -392,32 +391,16 @@ minetest.register_node("mcl_brewing:stand_000", { {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base {-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base - -- {-7/16, -6/16 ,-7/16 , -6/16, 1/16, -6/16 }, -- bottle 1 - -- {-6/16, -6/16 ,-6/16 , -5/16, 3/16, -5/16 }, -- bottle 1 - -- {-5/16, -6/16 ,-5/16 , -4/16, 3/16, -4/16 }, -- bottle 1 - -- {-4/16, -6/16 ,-4/16 , -3/16, 3/16, -3/16 }, -- bottle 1 - -- {-3/16, -6/16 ,-3/16 , -2/16, 1/16, -2/16 }, -- bottle 1 - {-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1 {-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 - - -- {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2 - -- {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2 - -- {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2 - -- {4/16, -6/16 ,-4/16 , 3/16, 3/16, -3/16 }, -- bottle 2 - -- {3/16, -6/16 ,-3/16 , 2/16, 1/16, -2/16 }, -- bottle 2 - {5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2 {4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2 - -- {0/16, -6/16 , 2/16 , 1/16, 1/16, 7/16 }, -- bottle 3 - -- {0/16, 1/16 , 3/16 , 1/16, 3/16, 6/16 }, -- bottle 3 - {0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3 {0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3 {0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3 @@ -427,7 +410,6 @@ minetest.register_node("mcl_brewing:stand_000", { _mcl_blast_resistance = 1, _mcl_hardness = 1, on_destruct = on_destruct, - -- after_dig_node = after_dig, allow_metadata_inventory_take = allow_take, allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, @@ -458,7 +440,7 @@ minetest.register_node("mcl_brewing:stand_100", { description = S("Brewing Stand"), _doc_items_create_entry = false, _tt_help = S("Brew Potions"), - groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, tiles = tiles, drop = "mcl_brewing:stand", paramtype = "light", @@ -486,21 +468,11 @@ minetest.register_node("mcl_brewing:stand_100", { {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 - - -- {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2 - -- {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2 - -- {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2 - -- {4/16, -6/16 ,-4/16 , 3/16, 3/16, -3/16 }, -- bottle 2 - -- {3/16, -6/16 ,-3/16 , 2/16, 1/16, -2/16 }, -- bottle 2 - {5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2 {4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2 - -- {0/16, -6/16 , 2/16 , 1/16, 1/16, 7/16 }, -- bottle 3 - -- {0/16, 1/16 , 3/16 , 1/16, 3/16, 6/16 }, -- bottle 3 - {0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3 {0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3 {0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3 @@ -510,7 +482,6 @@ minetest.register_node("mcl_brewing:stand_100", { _mcl_blast_resistance = 1, _mcl_hardness = 1, on_destruct = on_destruct, - -- after_dig_node = after_dig, allow_metadata_inventory_take = allow_take, allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, @@ -541,7 +512,7 @@ minetest.register_node("mcl_brewing:stand_010", { description = S("Brewing Stand"), _doc_items_create_entry = false, _tt_help = S("Brew Potions"), - groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, tiles = tiles, drop = "mcl_brewing:stand", paramtype = "light", @@ -558,12 +529,6 @@ minetest.register_node("mcl_brewing:stand_010", { {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base {-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base - -- {-7/16, -6/16 ,-7/16 , -6/16, 1/16, -6/16 }, -- bottle 1 - -- {-6/16, -6/16 ,-6/16 , -5/16, 3/16, -5/16 }, -- bottle 1 - -- {-5/16, -6/16 ,-5/16 , -4/16, 3/16, -4/16 }, -- bottle 1 - -- {-4/16, -6/16 ,-4/16 , -3/16, 3/16, -3/16 }, -- bottle 1 - -- {-3/16, -6/16 ,-3/16 , -2/16, 1/16, -2/16 }, -- bottle 1 - {-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1 {-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 @@ -581,9 +546,6 @@ minetest.register_node("mcl_brewing:stand_010", { {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2 - -- {0/16, -6/16 , 2/16 , 1/16, 1/16, 7/16 }, -- bottle 3 - -- {0/16, 1/16 , 3/16 , 1/16, 3/16, 6/16 }, -- bottle 3 - {0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3 {0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3 {0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3 @@ -593,7 +555,6 @@ minetest.register_node("mcl_brewing:stand_010", { _mcl_blast_resistance = 1, _mcl_hardness = 1, on_destruct = on_destruct, - -- after_dig_node = after_dig, allow_metadata_inventory_take = allow_take, allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, @@ -624,7 +585,7 @@ minetest.register_node("mcl_brewing:stand_001", { description = S("Brewing Stand"), _doc_items_create_entry = false, _tt_help = S("Brew Potions"), - groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, tiles = tiles, drop = "mcl_brewing:stand", paramtype = "light", @@ -641,24 +602,11 @@ minetest.register_node("mcl_brewing:stand_001", { {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base {-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base - -- {-7/16, -6/16 ,-7/16 , -6/16, 1/16, -6/16 }, -- bottle 1 - -- {-6/16, -6/16 ,-6/16 , -5/16, 3/16, -5/16 }, -- bottle 1 - -- {-5/16, -6/16 ,-5/16 , -4/16, 3/16, -4/16 }, -- bottle 1 - -- {-4/16, -6/16 ,-4/16 , -3/16, 3/16, -3/16 }, -- bottle 1 - -- {-3/16, -6/16 ,-3/16 , -2/16, 1/16, -2/16 }, -- bottle 1 - {-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1 {-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 - - -- {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2 - -- {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2 - -- {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2 - -- {4/16, -6/16 ,-4/16 , 3/16, 3/16, -3/16 }, -- bottle 2 - -- {3/16, -6/16 ,-3/16 , 2/16, 1/16, -2/16 }, -- bottle 2 - {5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2 {4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 @@ -676,7 +624,6 @@ minetest.register_node("mcl_brewing:stand_001", { _mcl_blast_resistance = 1, _mcl_hardness = 1, on_destruct = on_destruct, - -- after_dig_node = after_dig, allow_metadata_inventory_take = allow_take, allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, @@ -707,7 +654,7 @@ minetest.register_node("mcl_brewing:stand_110", { description = S("Brewing Stand"), _doc_items_create_entry = false, _tt_help = S("Brew Potions"), - groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, tiles = tiles, drop = "mcl_brewing:stand", paramtype = "light", @@ -747,9 +694,6 @@ minetest.register_node("mcl_brewing:stand_110", { {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 {2/16, 7/16 ,-2/16 ,1/16, 8/16, -1/16 }, -- line 2 - -- {0/16, -6/16 , 2/16 , 1/16, 1/16, 7/16 }, -- bottle 3 - -- {0/16, 1/16 , 3/16 , 1/16, 3/16, 6/16 }, -- bottle 3 - {0/16, 7/16 , 1/16 , 1/16, 8/16, 3/16 }, -- line 3 {0/16, 6/16 , 3/16 , 1/16, 7/16, 5/16 }, -- line 3 {0/16, 3/16 , 4/16 , 1/16, 6/16, 5/16 }, -- line 3 @@ -759,7 +703,6 @@ minetest.register_node("mcl_brewing:stand_110", { _mcl_blast_resistance = 1, _mcl_hardness = 1, on_destruct = on_destruct, - -- after_dig_node = after_dig, allow_metadata_inventory_take = allow_take, allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, @@ -790,7 +733,7 @@ minetest.register_node("mcl_brewing:stand_101", { description = S("Brewing Stand"), _doc_items_create_entry = false, _tt_help = S("Brew Potions"), - groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, tiles = tiles, drop = "mcl_brewing:stand", paramtype = "light", @@ -818,13 +761,6 @@ minetest.register_node("mcl_brewing:stand_101", { {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 - - -- {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2 - -- {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2 - -- {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2 - -- {4/16, -6/16 ,-4/16 , 3/16, 3/16, -3/16 }, -- bottle 2 - -- {3/16, -6/16 ,-3/16 , 2/16, 1/16, -2/16 }, -- bottle 2 - {5/16, 3/16 ,-5/16 ,4/16, 7/16, -4/16 }, -- line 2 {4/16, 6/16 ,-4/16 ,3/16, 8/16, -3/16 }, -- line 2 {3/16, 7/16 ,-3/16 ,2/16, 8/16, -2/16 }, -- line 2 @@ -842,7 +778,6 @@ minetest.register_node("mcl_brewing:stand_101", { _mcl_blast_resistance = 1, _mcl_hardness = 1, on_destruct = on_destruct, - -- after_dig_node = after_dig, allow_metadata_inventory_take = allow_take, allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, @@ -873,7 +808,7 @@ minetest.register_node("mcl_brewing:stand_011", { description = S("Brewing Stand"), _doc_items_create_entry = false, _tt_help = S("Brew Potions"), - groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, tiles = tiles, drop = "mcl_brewing:stand", paramtype = "light", @@ -890,18 +825,11 @@ minetest.register_node("mcl_brewing:stand_011", { {-8/16, -8/16, -8/16, -2/16, -6/16, -2/16}, -- base {-3/16, -8/16, 2/16, 3/16, -6/16, 8/16}, -- base - -- {-7/16, -6/16 ,-7/16 , -6/16, 1/16, -6/16 }, -- bottle 1 - -- {-6/16, -6/16 ,-6/16 , -5/16, 3/16, -5/16 }, -- bottle 1 - -- {-5/16, -6/16 ,-5/16 , -4/16, 3/16, -4/16 }, -- bottle 1 - -- {-4/16, -6/16 ,-4/16 , -3/16, 3/16, -3/16 }, -- bottle 1 - -- {-3/16, -6/16 ,-3/16 , -2/16, 1/16, -2/16 }, -- bottle 1 - {-5/16, 3/16 ,-5/16 , -4/16, 7/16, -4/16 }, -- line 1 {-4/16, 6/16 ,-4/16 , -3/16, 8/16, -3/16 }, -- line 1 {-3/16, 7/16 ,-3/16 , -2/16, 8/16, -2/16 }, -- line 1 {-2/16, 7/16 ,-2/16 , -1/16, 8/16, -1/16 }, -- line 1 - {7/16, -6/16 ,-7/16 , 6/16, 1/16, -6/16 }, -- bottle 2 {6/16, -6/16 ,-6/16 , 5/16, 3/16, -5/16 }, -- bottle 2 {5/16, -6/16 ,-5/16 , 4/16, 3/16, -4/16 }, -- bottle 2 @@ -956,7 +884,7 @@ minetest.register_node("mcl_brewing:stand_111", { description = S("Brewing Stand"), _doc_items_create_entry = false, _tt_help = S("Brew Potions"), - groups = {pickaxey=1, falling_node=1, brewitem=0, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {pickaxey=1, falling_node=1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, tiles = tiles, drop = "mcl_brewing:stand", paramtype = "light", @@ -1008,7 +936,6 @@ minetest.register_node("mcl_brewing:stand_111", { _mcl_blast_resistance = 1, _mcl_hardness = 1, on_destruct = on_destruct, - -- after_dig_node = after_dig, allow_metadata_inventory_take = allow_take, allow_metadata_inventory_put = allow_put, on_metadata_inventory_put = on_put, From c63028801b0f802e11805935529905bd71828efc Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Sat, 1 Aug 2020 03:20:52 +0200 Subject: [PATCH 12/12] Write potion help texts --- mods/ITEMS/mcl_potions/lingering.lua | 9 +++ mods/ITEMS/mcl_potions/potions.lua | 100 ++++++++++++++++-------- mods/ITEMS/mcl_potions/splash.lua | 9 +++ mods/ITEMS/mcl_potions/tipped_arrow.lua | 10 ++- 4 files changed, 94 insertions(+), 34 deletions(-) diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index 15e0f732a..318d51a68 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -69,9 +69,18 @@ end) function mcl_potions.register_lingering(name, descr, color, def) local id = "mcl_potions:"..name.."_lingering" + local longdesc = def.longdesc + if not def.no_effect then + longdesc = S("A throwable potion that will shatter on impact, where it creates a magic cloud that lingers around for a while. Any player or mob inside the cloud will receive the potion's effect, possibly repeatedly.") + if def.longdesc then + longdesc = longdesc .. "\n" .. def.longdesc + end + end minetest.register_craftitem(id, { description = descr, _tt_help = def.tt, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = S("Use the “Punch” key to throw it."), inventory_image = lingering_image(color), groups = {brewitem=1, not_in_creative_inventory=0}, on_use = function(item, placer, pointed_thing) diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index c82d4ef1d..2f83a1c19 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -9,6 +9,7 @@ local potion_image = function(colorstring, opacity) end local how_to_drink = S("Use the “Place” key to drink it.") +local potion_intro = S("Drinking a potion gives you a particular effect.") local function time_string(dur) if not dur then return nil end @@ -112,16 +113,26 @@ local function register_potion(def) else desc = def.description end + local potion_longdesc = def._longdesc + if not def.no_effect then + potion_longdesc = potion_intro .. "\n" .. def._longdesc + end + local potion_usagehelp + local basic_potion_tt + if def.name ~= "dragon_breath" then + potion_usagehelp = how_to_drink + basic_potion_tt = get_tt(def._tt, def.effect, dur) + end minetest.register_craftitem("mcl_potions:"..def.name, { description = desc, - _tt_help = get_tt(def._tt, def.effect, dur), - _doc_items_longdesc = def._longdesc, - _doc_items_usagehelp = how_to_drink, + _tt_help = basic_potion_tt, + _doc_items_longdesc = potion_longdesc, + _doc_items_usagehelp = potion_usagehelp, stack_max = def.stack_max or 1, inventory_image = def.image or potion_image(def.color), wield_image = def.image or potion_image(def.color), - groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0}, + groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1 }, on_place = on_use, on_secondary_use = on_use, }) @@ -132,25 +143,33 @@ local function register_potion(def) local splash_def = { tt = get_tt(def._tt, def.effect, splash_dur), + longdesc = def._longdesc, potion_fun = get_splash_fun(def.effect, splash_dur), + no_effect = def.no_effect, } local ling_def if def.name == "healing" or def.name == "harming" then ling_def = { tt = get_tt(def._tt, def.effect*mcl_potions.LINGERING_FACTOR, ling_dur), + longdesc = def._longdesc, potion_fun = get_lingering_fun(def.effect*mcl_potions.LINGERING_FACTOR, ling_dur), + no_effect = def.no_effect, } else ling_def = { tt = get_tt(def._tt, def.effect, ling_dur), + longdesc = def._longdesc, potion_fun = get_lingering_fun(def.effect, ling_dur), + no_effect = def.no_effect, } end local arrow_def = { tt = get_tt(def._tt, def.effect, dur/8.), + longdesc = def._longdesc, potion_fun = get_arrow_fun(def.effect, dur/8.), + no_effect = def.no_effect, } if def.color and not def.no_throwable then @@ -193,12 +212,12 @@ local function register_potion(def) minetest.register_craftitem("mcl_potions:"..def.name.."_2", { description = S("@1 Potion@2", def.description, desc_mod), _tt_help = get_tt(def._tt_2, effect_II, dur_2), - _doc_items_longdesc = def._longdesc, - _doc_items_usagehelp = how_to_drink, + _doc_items_longdesc = potion_longdesc, + _doc_items_usagehelp = potion_usagehelp, stack_max = def.stack_max or 1, inventory_image = def.image or potion_image(def.color), wield_image = def.image or potion_image(def.color), - groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0}, + groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1}, on_place = on_use, on_secondary_use = on_use, }) @@ -211,12 +230,16 @@ local function register_potion(def) if def.name == "healing" then splash_def_2 = { tt = get_tt(def._tt_2, 7, splash_dur_2), + longdesc = def._longdesc, potion_fun = get_splash_fun(7, splash_dur_2), + no_effect = def.no_effect, } else splash_def_2 = { tt = get_tt(def._tt_2, effect_II, splash_dur_2), + longdesc = def._longdesc, potion_fun = get_splash_fun(effect_II, splash_dur_2), + no_effect = def.no_effect, } end @@ -225,18 +248,24 @@ local function register_potion(def) if def.name == "healing" or def.name == "harming" then ling_def_2 = { tt = get_tt(def._tt_2, effect_II*mcl_potions.LINGERING_FACTOR, ling_dur_2), + longdesc = def._longdesc, potion_fun = get_lingering_fun(effect_II*mcl_potions.LINGERING_FACTOR, ling_dur_2), + no_effect = def.no_effect, } else ling_def_2 = { tt = get_tt(def._tt_2, effect_II, ling_dur_2), + longdesc = def._longdesc, potion_fun = get_lingering_fun(effect_II, ling_dur_2), + no_effect = def.no_effect, } end local arrow_def_2 = { tt = get_tt(def._tt_2, effect_II, dur_2/8.), + longdesc = def._longdesc, potion_fun = get_arrow_fun(effect_II, dur_2/8.), + no_effect = def.no_effect, } if def.color and not def.no_throwable then @@ -266,12 +295,12 @@ local function register_potion(def) minetest.register_craftitem("mcl_potions:"..def.name.."_plus", { description = S("@1 + Potion", def.description), _tt_help = get_tt(def._tt_plus, def.effect, dur_pl), - _doc_items_longdesc = def._longdesc, - _doc_items_usagehelp = how_to_drink, + _doc_items_longdesc = potion_longdesc, + _doc_items_usagehelp = potion_usagehelp, stack_max = 1, inventory_image = def.image or potion_image(def.color), wield_image = def.image or potion_image(def.color), - groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0}, + groups = def.groups or {brewitem=1, food=3, can_eat_when_full=1}, on_place = on_use, on_secondary_use = on_use, }) @@ -282,15 +311,21 @@ local function register_potion(def) local splash_def_pl = { tt = get_tt(def._tt_plus, def.effect, splash_dur_pl), + longdesc = def._longdesc, potion_fun = get_splash_fun(def.effect, splash_dur_pl), + no_effect = def.no_effect, } local ling_def_pl = { tt = get_tt(def._tt_plus, def.effect, ling_dur_pl), + longdesc = def._longdesc, potion_fun = get_lingering_fun(def.effect, ling_dur_pl), + no_effect = def.no_effect, } local arrow_def_pl = { tt = get_tt(def._tt_pl, def.effect, dur_pl/8.), + longdesc = def._longdesc, potion_fun = get_arrow_fun(def.effect, dur_pl/8.), + no_effect = def.no_effect, } if def.color and not def.no_throwable then mcl_potions.register_splash(def.name.."_plus", S("Splash @1 + Potion", def.description), def.color, splash_def_pl) @@ -324,10 +359,11 @@ local awkward_def = { name = "awkward", description = S("Awkward"), no_arrow = true, + no_effect = true, _tt = S("No effect"), _longdesc = S("Has an awkward taste and is used for brewing potions."), color = "#0000FF", - groups = {brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0}, + groups = {brewitem=1, food=3, can_eat_when_full=1}, on_use = minetest.item_eat(0, "mcl_potions:glass_bottle"), } @@ -335,8 +371,9 @@ local mundane_def = { name = "mundane", description = S("Mundane"), no_arrow = true, + no_effect = true, _tt = S("No effect"), - longdesc = S("Has a terrible taste and is not useful for brewing potions."), + _longdesc = S("Has a terrible taste and is not useful for brewing potions."), color = "#0000FF", on_use = minetest.item_eat(0, "mcl_potions:glass_bottle"), } @@ -345,6 +382,7 @@ local thick_def = { name = "thick", description = S("Thick"), no_arrow = true, + no_effect = true, _tt = S("No effect"), _longdesc = S("Has a bitter taste and is not useful for brewing potions."), color = "#0000FF", @@ -357,10 +395,10 @@ local dragon_breath_def = { no_arrow = true, no_potion = true, no_throwable = true, - _tt = S("No effect"), - _longdesc = S("Combine with Splash potions to create a Lingering effect"), + no_effect = true, + _longdesc = S("This item is used in brewing and can be combined with splash potions to create lingering potions."), color = "#BF4567", - groups = { brewitem = 1, not_in_creative_inventory = 0 }, + groups = { brewitem = 1 }, on_use = nil, stack_max = 64, } @@ -370,7 +408,7 @@ local healing_def = { description = S("Healing"), _tt = S("+2 hearts"), _tt_2 = S("+4 hearts"), - _longdesc = S("Drink to heal yourself"), + _longdesc = S("Instantly heals."), color = "#CC0000", effect = 4, on_use = mcl_potions.healing_func, @@ -383,7 +421,7 @@ local harming_def = { description = S("Harming"), _tt = S("-3 hearts"), _tt_II = S("-6 hearts"), - _longdesc = S("Drink to heal yourself"), + _longdesc = S("Instantly deals damage."), color = "#660099", effect = -6, on_use = mcl_potions.healing_func, @@ -395,7 +433,7 @@ local night_vision_def = { name = "night_vision", description = S("Night Vision"), _tt = nil, - _longdesc = S("Drink to see in the dark."), + _longdesc = S("Grants the ability to see in darkness."), color = "#1010AA", effect = nil, is_dur = true, @@ -407,7 +445,7 @@ local swiftness_def = { name = "swiftness", description = S("Swiftness"), _tt = nil, - _longdesc = S("Drink to increase your speed."), + _longdesc = S("Increases walking speed."), color = "#009999", effect = 1.2, is_dur = true, @@ -420,7 +458,7 @@ local slowness_def = { name = "slowness", description = S("Slowness"), _tt = nil, - _longdesc = S("Drink to become sluggish"), + _longdesc = S("Decreases walking speed."), color = "#000080", effect = 0.85, is_dur = true, @@ -434,7 +472,7 @@ local leaping_def = { name = "leaping", description = S("Leaping"), _tt = nil, - _longdesc = S("Drink to leap tall buildings in a single bound!"), + _longdesc = S("Increases jump strength."), color = "#00CC33", effect = 1.15, is_dur = true, @@ -447,7 +485,7 @@ local poison_def = { name = "poison", description = S("Poison"), _tt = nil, - _longdesc = S("Poison mobs or players with this dangerous potion."), + _longdesc = S("Applies the poison effect which deals damage at a regular interval."), color = "#447755", effect = 2.5, is_dur = true, @@ -461,7 +499,7 @@ local regeneration_def = { name = "regeneration", description = S("Regeneration"), _tt = nil, - _longdesc = S("Regenerate mobs or players with this healing potion over time."), + _longdesc = S("Regenerates health over time."), color = "#B52CC2", effect = 2.5, is_dur = true, @@ -474,7 +512,7 @@ local invisibility_def = { name = "invisibility", description = S("Invisibility"), _tt = nil, - _longdesc = S("Drink and become invisibile to mobs and players."), + _longdesc = S("Grants invisibility."), color = "#B0B0B0", is_dur = true, on_use = mcl_potions.invisiblility_func, @@ -485,7 +523,7 @@ local water_breathing_def = { name = "water_breathing", description = S("Water Breathing"), _tt = nil, - _longdesc = S("Drink and breath underwater."), + _longdesc = S("Grants limitless breath underwater."), color = "#0000AA", is_dur = true, on_use = mcl_potions.water_breathing_func, @@ -496,7 +534,7 @@ local fire_resistance_def = { name = "fire_resistance", description = S("Fire Resistance"), _tt = nil, - _longdesc = S("Drink and resist fire damage."), + _longdesc = S("Grants immunity to damage from heat sources like fire."), color = "#D0A040", is_dur = true, on_use = mcl_potions.fire_resistance_func, @@ -523,7 +561,7 @@ end -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#6600AA"), -- inventory_image = potion_image("#6600AA"), --- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, +-- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) @@ -547,7 +585,7 @@ end -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#7700BB"), -- inventory_image = potion_image("#7700BB"), --- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, +-- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) @@ -571,7 +609,7 @@ end -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444D4"), -- inventory_image = potion_image("#D444D4"), --- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, +-- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) @@ -595,7 +633,7 @@ end -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444E4"), -- inventory_image = potion_image("#D444E4"), --- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, +-- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) @@ -619,7 +657,7 @@ end -- _doc_items_longdesc = brewhelp, -- wield_image = potion_image("#D444F4"), -- inventory_image = potion_image("#D444F4"), --- groups = { brewitem=1, food=3, can_eat_when_full=1, not_in_creative_inventory=0 }, +-- groups = { brewitem=1, food=3, can_eat_when_full=1 }, -- stack_max = 1, -- -- on_place = function(itemstack, user, pointed_thing) diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index 8fa205109..779c75ac3 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -11,9 +11,18 @@ end function mcl_potions.register_splash(name, descr, color, def) local id = "mcl_potions:"..name.."_splash" + local longdesc = def.longdesc + if not def.no_effect then + longdesc = S("A throwable potion that will shatter on impact, where it gives all nearby players and mobs a status effect.") + if def.longdesc then + longdesc = longdesc .. "\n" .. def.longdesc + end + end minetest.register_craftitem(id, { description = descr, _tt_help = def.tt, + _doc_items_longdesc = longdesc, + _doc_items_usagehelp = S("Use the “Punch” key to throw it."), inventory_image = splash_image(color), groups = {brewitem=1, not_in_creative_inventory=0}, on_use = function(item, placer, pointed_thing) diff --git a/mods/ITEMS/mcl_potions/tipped_arrow.lua b/mods/ITEMS/mcl_potions/tipped_arrow.lua index 3e935ab39..b338a18e1 100644 --- a/mods/ITEMS/mcl_potions/tipped_arrow.lua +++ b/mods/ITEMS/mcl_potions/tipped_arrow.lua @@ -27,19 +27,23 @@ local function arrow_image(colorstring, opacity) end +local how_to_shoot = minetest.registered_items["mcl_bows:arrow"]._doc_items_usagehelp local mod_awards = minetest.get_modpath("awards") and minetest.get_modpath("mcl_achievements") local mod_button = minetest.get_modpath("mesecons_button") function mcl_potions.register_arrow(name, desc, color, def) + local longdesc = def.longdesc or "" minetest.register_craftitem("mcl_potions:"..name.."_arrow", { description = desc, _tt_help = S("Ammunition").."\n"..S("Damage from bow: 1-10").."\n"..S("Damage from dispenser: 3").."\n"..def.tt, _doc_items_longdesc = S("Arrows are ammunition for bows and dispensers.").."\n".. - S("An arrow fired from a bow has a regular damage of 1-9. At full charge, there's a 20% chance of a critical hit dealing 10 damage instead. An arrow fired from a dispenser always deals 3 damage.").."\n".. - S("Arrows might get stuck on solid blocks and can be retrieved again. They are also capable of pushing wooden buttons."), - _doc_items_usagehelp = S("To use arrows as ammunition for a bow, just put them anywhere in your inventory, they will be used up automatically. To use arrows as ammunition for a dispenser, place them in the dispenser's inventory. To retrieve an arrow that sticks in a block, simply walk close to it."), + S("An arrow fired from a bow has a regular damage of 1-9. At full charge, there's a 20% chance of a critical hit dealing 10 damage instead. An arrow fired from a dispenser always deals 3 damage.").."\n".. + S("Arrows might get stuck on solid blocks and can be retrieved again. They are also capable of pushing wooden buttons.").."\n".. + S("This particular arrow is tipped and will give an effect when it hits a player or mob.").."\n".. + longdesc, + _doc_items_usagehelp = how_to_shoot, inventory_image = "mcl_bows_arrow_inv.png^(mcl_potions_arrow_inv.png^[colorize:"..color..":100)", groups = { ammo=1, ammo_bow=1, brewitem=1}, _on_dispense = function(itemstack, dispenserpos, droppos, dropnode, dropdir)