From e85c00ea02c7732e7111e885e67784595e61535c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Mon, 27 Jul 2020 19:26:01 +0200 Subject: [PATCH 1/7] Show custom name in UI of Chest and Shulker Box --- mods/ITEMS/mcl_chests/init.lua | 64 +++++++++++++++++++++++++--------- 1 file changed, 48 insertions(+), 16 deletions(-) diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index a200d3d32..0b096e2cd 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -197,6 +197,9 @@ minetest.register_node("mcl_chests:"..basename, { minetest.swap_node(pos, { name = "mcl_chests:"..canonical_basename, param2 = param2 }) end end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, after_dig_node = drop_items_chest, on_blast = on_chest_blast, allow_metadata_inventory_move = protection_check_move, @@ -224,10 +227,15 @@ minetest.register_node("mcl_chests:"..basename, { _mcl_hardness = 2.5, on_rightclick = function(pos, node, clicker) + local name = minetest.get_meta(pos):get_string("name") + if name == "" then + name = S("Chest") + end + minetest.show_formspec(clicker:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, "size[9,8.75]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Chest"))).."]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. mcl_formspec.get_itemslot_bg(0,0.5,9,3).. "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. @@ -270,6 +278,9 @@ minetest.register_node("mcl_chests:"..basename.."_left", { minetest.swap_node(pos, n) end end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, on_destruct = function(pos) local n = minetest.get_node(pos) if n.name == "mcl_chests:"..basename then @@ -345,11 +356,18 @@ minetest.register_node("mcl_chests:"..basename.."_left", { on_rightclick = function(pos, node, clicker) local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "left") + local name = minetest.get_meta(pos):get_string("name") + if name == "" then + name = minetest.get_meta(pos_other):get_string("name") + end + if name == "" then + name = S("Large Chest") + end minetest.show_formspec(clicker:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, "size[9,11.5]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Large Chest"))).."]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,0.5;9,3;]".. mcl_formspec.get_itemslot_bg(0,0.5,9,3).. "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,3.5;9,3;]".. @@ -393,6 +411,9 @@ minetest.register_node("mcl_chests:"..basename.."_right", { minetest.swap_node(pos, n) end end, + after_place_node = function(pos, placer, itemstack, pointed_thing) + minetest.get_meta(pos):set_string("name", itemstack:get_meta():get_string("name")) + end, on_destruct = function(pos) local n = minetest.get_node(pos) if n.name == "mcl_chests:"..basename then @@ -469,12 +490,19 @@ minetest.register_node("mcl_chests:"..basename.."_right", { on_rightclick = function(pos, node, clicker) local pos_other = mcl_util.get_double_container_neighbor_pos(pos, node.param2, "right") + local name = minetest.get_meta(pos_other):get_string("name") + if name == "" then + name = minetest.get_meta(pos):get_string("name") + end + if name == "" then + name = S("Large Chest") + end minetest.show_formspec(clicker:get_player_name(), "mcl_chests:"..canonical_basename.."_"..pos.x.."_"..pos.y.."_"..pos.z, "size[9,11.5]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Large Chest"))).."]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. "list[nodemeta:"..pos_other.x..","..pos_other.y..","..pos_other.z..";main;0,0.5;9,3;]".. mcl_formspec.get_itemslot_bg(0,0.5,9,3).. "list[nodemeta:"..pos.x..","..pos.y..","..pos.z..";main;0,3.5;9,3;]".. @@ -769,8 +797,12 @@ local shulker_mob_textures = { } local canonical_shulker_color = "violet" -local formspec_shulker_box = "size[9,8.75]".. - "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Shulker Box"))).."]".. +local function formspec_shulker_box(name) + if name == "" then + name = S("Shulker Box") + end + return "size[9,8.75]".. + "label[0,0;"..minetest.formspec_escape(minetest.colorize("#313131", name)).."]".. "list[current_name;main;0,0.5;9,3;]".. mcl_formspec.get_itemslot_bg(0,0.5,9,3).. "label[0,4.0;"..minetest.formspec_escape(minetest.colorize("#313131", S("Inventory"))).."]".. @@ -780,6 +812,14 @@ local formspec_shulker_box = "size[9,8.75]".. mcl_formspec.get_itemslot_bg(0,7.74,9,1).. "listring[current_name;main]".. "listring[current_player;main]" +end + +local function set_shulkerbox_meta(nmeta, imeta) + local name = imeta:get_string("name") + nmeta:set_string("description", imeta:get_string("description")) + nmeta:set_string("name", name) + nmeta:set_string("formspec", formspec_shulker_box(name)) +end for color, desc in pairs(boxtypes) do local mob_texture = shulker_mob_textures[color] @@ -822,7 +862,7 @@ for color, desc in pairs(boxtypes) do -- on_place = minetest.rotate_node, on_construct = function(pos) local meta = minetest.get_meta(pos) - meta:set_string("formspec", formspec_shulker_box) + meta:set_string("formspec", formspec_shulker_box(nil)) local inv = meta:get_inventory() inv:set_size("main", 9*3) end, @@ -835,12 +875,7 @@ for color, desc in pairs(boxtypes) do local iinv_main = minetest.deserialize(imetadata) ninv:set_list("main", iinv_main) ninv:set_size("main", 9*3) - - local imeta = stack:get_meta() - local nmeta = minetest.get_meta(droppos) - nmeta:set_string("description", imeta:get_string("description")) - nmeta:set_string("name", imeta:get_string("name")) - + set_shulkerbox_meta(minetest.get_meta(droppos), stack:get_meta()) stack:take_item() end return stack @@ -852,10 +887,7 @@ for color, desc in pairs(boxtypes) do local ninv = nmeta:get_inventory() ninv:set_list("main", iinv_main) ninv:set_size("main", 9*3) - - local imeta = itemstack:get_meta() - nmeta:set_string("description", imeta:get_string("description")) - nmeta:set_string("name", imeta:get_string("name")) + set_shulkerbox_meta(nmeta, itemstack:get_meta()) if minetest.is_creative_enabled(placer:get_player_name()) then if not ninv:is_empty("main") then From a8eca09822128235dfc26f14e10ee2e6cab755c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Elias=20=C3=85str=C3=B6m?= Date: Mon, 27 Jul 2020 19:44:55 +0200 Subject: [PATCH 2/7] Fix on_blast for chorus flower crashing --- mods/ITEMS/mcl_end/chorus_plant.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_end/chorus_plant.lua b/mods/ITEMS/mcl_end/chorus_plant.lua index d9933bcae..f85fdcd82 100644 --- a/mods/ITEMS/mcl_end/chorus_plant.lua +++ b/mods/ITEMS/mcl_end/chorus_plant.lua @@ -111,7 +111,7 @@ mcl_end.check_detach_chorus_plant = function(pos, oldnode, oldmetadata, digger) end mcl_end.check_blast_chorus_plant = function(pos) - minetest.remove(pos) + minetest.remove_node(pos) mcl_end.detach_chorus_plant(pos) end From bdd92c6cdb4380c4301a23fb3f7c3617ce3087ed Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 27 Jul 2020 17:32:48 -0400 Subject: [PATCH 3/7] update poison to swap hudbar icons and remove old dead functions --- mods/ITEMS/mcl_potions/functions.lua | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 0704093cd..afe87c367 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -55,6 +55,9 @@ minetest.register_globalstep(function(dtime) if is_poisoned[player].timer >= is_poisoned[player].dur then is_poisoned[player] = nil + if is_player then + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + end end end @@ -282,6 +285,11 @@ function mcl_potions._reset_player_effects(player) if is_poisoned[player] then is_poisoned[player] = nil + + if player:is_player() then + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + end + end if is_regenerating[player] then @@ -383,19 +391,8 @@ function mcl_potions.make_invisible(player, toggle) end -function mcl_potions.poison(player, toggle) - if not player then return false end - is_poisoned[player:get_player_name()] = toggle -end - -function mcl_potions.regenerate(player, toggle) - - if not player then return false end - is_regenerating[player:get_player_name()] = toggle - -end function mcl_potions._use_potion(item, obj, color) local d = 0.1 @@ -558,6 +555,10 @@ function mcl_potions.poison_func(player, factor, duration) is_poisoned[player] = {step = factor, dur = duration, timer = 0} + if player:is_player() then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") + end + else local victim = is_poisoned[player] From 9a32bdc967290e74326015685dbf016257c2c9cc Mon Sep 17 00:00:00 2001 From: Brandon Date: Mon, 27 Jul 2020 19:17:04 -0400 Subject: [PATCH 4/7] Update HUD for poison/regen. --- mods/ITEMS/mcl_potions/functions.lua | 32 ++++++++++++++++-- .../textures/hbhunger_icon_regen_poison.png | Bin 0 -> 290 bytes .../textures/hudbars_icon_regenerate.png | Bin 0 -> 305 bytes 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png create mode 100644 mods/ITEMS/mcl_potions/textures/hudbars_icon_regenerate.png diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index afe87c367..0c199697a 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -55,7 +55,9 @@ minetest.register_globalstep(function(dtime) if is_poisoned[player].timer >= is_poisoned[player].dur then is_poisoned[player] = nil - if is_player then + if is_regenerating[player] then + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png") + else hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") end end @@ -89,6 +91,13 @@ minetest.register_globalstep(function(dtime) if is_regenerating[player].timer >= is_regenerating[player].dur then is_regenerating[player] = nil + if is_player then + if is_poisoned[player] then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hudbars_bar_health.png") + else + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + end + end end end @@ -284,6 +293,7 @@ function mcl_potions._reset_player_effects(player) end if is_poisoned[player] then + is_poisoned[player] = nil if player:is_player() then @@ -293,7 +303,13 @@ function mcl_potions._reset_player_effects(player) end if is_regenerating[player] then + is_regenerating[player] = nil + + if player:is_player() then + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + end + end if is_strong[player] then @@ -556,7 +572,11 @@ function mcl_potions.poison_func(player, factor, duration) is_poisoned[player] = {step = factor, dur = duration, timer = 0} if player:is_player() then - hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") + if is_regenerating[player] then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png") + else + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") + end end else @@ -577,6 +597,14 @@ function mcl_potions.regeneration_func(player, factor, duration) is_regenerating[player] = {step = factor, dur = duration, timer = 0} + if player:is_player() then + if is_poisoned[player] then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png") + else + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png") + end + end + else local victim = is_regenerating[player] diff --git a/mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png b/mods/ITEMS/mcl_potions/textures/hbhunger_icon_regen_poison.png new file mode 100644 index 0000000000000000000000000000000000000000..d4fe9b4e0783d7ddabcc749e79095e880c49af0d GIT binary patch literal 290 zcmeAS@N?(olHy`uVBq!ia0vp^oFL4>1|%O$WD@{VjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp-1(_iP|F!_&nvL_#t-L4nDj>B=Ab z|NrbG-qx|P9aC~V_WxsmUBHCGg$l~t9*#e>_%}!ieB94}qMrAm{m!rR9@;x!uNRxK zWeB+sLQ1=cZow;M#cygxLU zHu_lZGHY#|xUffX4TlPMk%5n51mk(n4d)$-3S1LfGve4g8yOhhy|YV>ydJU;1|%O$WD@{VjKx9jP7LeL$-D$|EK(yp(|mmy zw18|52FCVG1{RPKAeI7R1_q`DOmGp-1(_iP}w+|$J|L_#t-L4nDj>B=Ab z|NrbG-qx|P9aC~V_WxsmUBHCGg$l~t9tThHuy2qO__&|{L_Fui`L+KiKD2kfUavMI z=f^*09wVhiJO-=^g^Fci8%$y@Uc3-6qsrp%yXW}^vs)Qo^!>iS&(L5`CGT_=!vjeH zf*pq&-@TZT&n6c1 Date: Mon, 27 Jul 2020 19:41:07 -0400 Subject: [PATCH 5/7] Cleanup HUD bar mechanics --- mods/ITEMS/mcl_potions/functions.lua | 44 +++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 0c199697a..80ee46f6f 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -10,6 +10,22 @@ local is_cat = {} local is_fire_proof = {} +local function potions_set_hudbar(player) + + if is_poisoned[player] and is_regenerating[player] then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png") + elseif is_poisoned[player] then + hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hudbars_bar_health.png") + elseif is_regenerating[player] then + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png") + else + hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + end + +end + + + local is_player, entity minetest.register_globalstep(function(dtime) @@ -55,10 +71,8 @@ minetest.register_globalstep(function(dtime) if is_poisoned[player].timer >= is_poisoned[player].dur then is_poisoned[player] = nil - if is_regenerating[player] then - hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png") - else - hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + if is_player then + potions_set_hudbar(player) end end @@ -92,11 +106,7 @@ minetest.register_globalstep(function(dtime) if is_regenerating[player].timer >= is_regenerating[player].dur then is_regenerating[player] = nil if is_player then - if is_poisoned[player] then - hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hudbars_bar_health.png") - else - hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") - end + potions_set_hudbar(player) end end @@ -297,7 +307,7 @@ function mcl_potions._reset_player_effects(player) is_poisoned[player] = nil if player:is_player() then - hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + potions_set_hudbar(player) end end @@ -307,7 +317,7 @@ function mcl_potions._reset_player_effects(player) is_regenerating[player] = nil if player:is_player() then - hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_health.png", nil, "hudbars_bar_health.png") + potions_set_hudbar(player) end end @@ -572,11 +582,7 @@ function mcl_potions.poison_func(player, factor, duration) is_poisoned[player] = {step = factor, dur = duration, timer = 0} if player:is_player() then - if is_regenerating[player] then - hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png") - else - hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") - end + potions_set_hudbar(player) end else @@ -598,11 +604,7 @@ function mcl_potions.regeneration_func(player, factor, duration) is_regenerating[player] = {step = factor, dur = duration, timer = 0} if player:is_player() then - if is_poisoned[player] then - hb.change_hudbar(player, "health", nil, nil, "hbhunger_icon_regen_poison.png", nil, "hudbars_bar_health.png") - else - hb.change_hudbar(player, "health", nil, nil, "hudbars_icon_regenerate.png", nil, "hudbars_bar_health.png") - end + potions_set_hudbar(player) end else From 78bee21a82883fdbf07793d6c30d2a3978e71358 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 28 Jul 2020 17:02:43 -0400 Subject: [PATCH 6/7] Allow dragon's breath to stack to 64 --- mods/ITEMS/mcl_potions/potions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_potions/potions.lua b/mods/ITEMS/mcl_potions/potions.lua index bfbb7c124..402b9a1d4 100644 --- a/mods/ITEMS/mcl_potions/potions.lua +++ b/mods/ITEMS/mcl_potions/potions.lua @@ -111,7 +111,7 @@ local function register_potion(def) _tt_help = get_tt(def._tt, def.effect, dur), _doc_items_longdesc = def._longdesc, _doc_items_usagehelp = how_to_drink, - stack_max = 1, + 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}, From 1563fc7b96f40909bce04ba08b36774bc41d9ae5 Mon Sep 17 00:00:00 2001 From: Brandon Date: Tue, 28 Jul 2020 17:13:54 -0400 Subject: [PATCH 7/7] comment sections of mcl_hunger that "poison" player. This is handled in mcl_potions. --- mods/PLAYER/mcl_hunger/hunger.lua | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index cff54b169..a13e2ae4a 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -98,15 +98,15 @@ local function poisonp(tick, time, time_left, damage, exhaustion, name) if time_left < time then minetest.after(tick, poisonp, tick, time, time_left, damage, exhaustion, name) else - if damage > 0 then - mcl_hunger.poison_damage[name] = mcl_hunger.poison_damage[name] - 1 - end + -- if damage > 0 then + -- mcl_hunger.poison_damage[name] = mcl_hunger.poison_damage[name] - 1 + -- end if exhaustion > 0 then mcl_hunger.poison_hunger [name] = mcl_hunger.poison_hunger[name] - 1 end - if mcl_hunger.poison_damage[name] <= 0 then - mcl_hunger.reset_bars_poison_damage(player) - end + -- if mcl_hunger.poison_damage[name] <= 0 then + -- mcl_hunger.reset_bars_poison_damage(player) + -- end if mcl_hunger.poison_hunger[name] <= 0 then mcl_hunger.reset_bars_poison_hunger(player) end @@ -225,10 +225,10 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso end if do_poison then -- Set poison bars - if poison and poison > 0 then - hb.change_hudbar(user, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") - mcl_hunger.poison_damage[name] = mcl_hunger.poison_damage[name] + 1 - end + -- if poison and poison > 0 then + -- hb.change_hudbar(user, "health", nil, nil, "hbhunger_icon_health_poison.png", nil, "hbhunger_bar_health_poison.png") + -- mcl_hunger.poison_damage[name] = mcl_hunger.poison_damage[name] + 1 + -- end if exhaust and exhaust > 0 then hb.change_hudbar(user, "hunger", nil, nil, "mcl_hunger_icon_foodpoison.png", nil, "mcl_hunger_bar_foodpoison.png") if mcl_hunger.debug then @@ -260,4 +260,3 @@ if mcl_hunger.active then mcl_hunger.exhaust(name, mcl_hunger.EXHAUST_DIG) end) end -