From f1229c5401494b7d809817fa43e4d25076451341 Mon Sep 17 00:00:00 2001 From: talamh Date: Sun, 2 May 2021 01:58:40 +0000 Subject: [PATCH 01/74] Added spawn egg for killer rabbitt --- .../mobs_mc_spawn_icon_rabbit_caerbannog.png | Bin 0 -> 1897 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 mods/ENTITIES/mobs_mc/textures/mobs_mc_spawn_icon_rabbit_caerbannog.png diff --git a/mods/ENTITIES/mobs_mc/textures/mobs_mc_spawn_icon_rabbit_caerbannog.png b/mods/ENTITIES/mobs_mc/textures/mobs_mc_spawn_icon_rabbit_caerbannog.png new file mode 100644 index 0000000000000000000000000000000000000000..4244a83c6f0a93ff1f7d65180fd6d56b43e98af3 GIT binary patch literal 1897 zcmV-v2bTDWP) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O1YulI182{O1&N1WN)Wj>8%;H<;s3VuS0|@?KYW zmmM}(W=UmAvR(i0-{Jnj!5qBvK`o{j4;()E#2Fnst|Om!I{bNG56AAjv%C8R!z5_s zdbGIg9d^ceUiP}y$*_lqg;HNH%KI02EyT7q*gLL`gsu&awXn-;A>p;Nzn;tG))ABG zqYHJ7AM5=|11>jjUX){qq#k$AhiXjd8y{Z5Tbn>d&;9R>K0doWl!1x6kQ}(%L@4tj z$!NoQXN;M)EV3+%3aG{IQ1sL0_4V-zx!cf}BD1U*2UO;c{F~ZCB17#+Av|IV<8+T;Z@u_B<0# zLrPT0*$`v}XQf0883%c4lxa{u+e#G>J$F{L%oXBR2ctoZ#1(Rq_<7P`l_X6JVpoKN zz{)okI=4;dc9jepH!_FlAS_0h@>i$(&Y&@7LJ=Kya|K*HBO55DazySR41*#x7OCMR zc%L7SsjEQ2aMEmWFdt>E0QpOxx8RafXu-gM_R1sDwiW#G=JYD!H<&Qhg0IR;^Z3&5fHhx|g6?PQug-im@jMu2TUL$2>JVjJ)Tm z+|=wyJc}R$WSHVKnu?=QtWgX4k#5C0k&@74l-_&0nZM zRQI^rPS^%yVYyRXk>0&FnxL&&4|}Qy>|;&%M(f@gq=T{5_4$b}k9f+$Q^fUg6gfFW zwnkcjn(r*hu3^nfr|$=3&&w&UqcpzM%N~COS(kRf29#~Q5b+2nBlzMqa#wEwL6vJu zVOnjpH5$}!kABV3%@vBpcD{GJweaa8&Lki4GFFpb^0iQDDnknAwvg&Gp4;Au#saK$ zVRvs%JZob+HwYC`f`Yv^%X+@Xe@ySw=uRtWJO_kc(nu|(a&K7EHNmR(bT6(=*FuFA z)h?R*NagX8(x*|^U1*EeEPd=GfD?Mjr#XWL{Qch$%Y_QXTw6&y?#y+B!{VT8uKx1G zr}D|)J2Jk={o|7Vc}|~F@duZ6QWxPwxUB)L%JgzDt?zz{YW5HG@r4cmQA9RD<3UIBDK7$1w-QnX|n=&!S6J#FSNeT0%D6YqIUEif*S>-oYH>emR5}^Fkwg@_oh35b$_S93CGmdz$@Es=#J; zeN9ja714I3q6@tu+)BDBeyF5T)-tFLe)~f-Vq8coja2Q-F895(dJZ}6uSk_y2F|BM z2ufQ4noTQziPQIMt^tazs0rq%XIq2V_qc*JAdmcS!E-OmM6aK8ekfIob4^iObE(#y zUHC(`UzN+Jt^3o7f4Y$32Qj(-0gvB171uc!#sB~S24YJ`L;%PDS^!tH0(VpZ000Sa zNLh0L01FcU01FcV0GgZ_00007bV*G`2jv9<0V4$`wT`m@000?uMObu0Z*6U5Zgc=c za%Ew3Wn>_CX>@2HM@dakSAh-}0004CNklbF5XOHoK`b;JVIM$K99Z8z zgPq_DXerpKg^gMWSBOs`_yF2S;;Kp&{r>lkCK@B4V3=Z)r$1%5iFTC>(}10W(?Yt0g{KT~|LB0{1RiBgp!Ypopv*h^Cyz`N@%B3xU*m=o zt`rm4%`%KJzZ1nVec%Xe6THe6MC2Pa2#BJHEhpZv%>xfW)2*`v&{}%{_i;?3R4HDb z=M{hjU}YMGL~8(+ouB79BEnr9^9gJkL&Mt2MOG*rgJ*!3k+ECA8*mx~W9K~f7fu|v j9Vl0|3LH#0`#-TSNF9Mg)SuCN00000NkvXXu0mjfBRps$ literal 0 HcmV?d00001 From e6b61a1551948352bf7e3dce3f59f7238a5d413e Mon Sep 17 00:00:00 2001 From: talamh Date: Sun, 2 May 2021 02:00:21 +0000 Subject: [PATCH 02/74] Update 'mods/ENTITIES/mobs_mc/rabbit.lua' --- mods/ENTITIES/mobs_mc/rabbit.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ENTITIES/mobs_mc/rabbit.lua b/mods/ENTITIES/mobs_mc/rabbit.lua index 90d5c27bf0..2a9521ecb1 100644 --- a/mods/ENTITIES/mobs_mc/rabbit.lua +++ b/mods/ENTITIES/mobs_mc/rabbit.lua @@ -233,4 +233,4 @@ mobs:spawn(spawn_grass) mobs:register_egg("mobs_mc:rabbit", S("Rabbit"), "mobs_mc_spawn_icon_rabbit.png", 0) -- Note: This spawn egg does not exist in Minecraft -mobs:register_egg("mobs_mc:killer_bunny", S("Killer Bunny"), "mobs_mc_spawn_icon_rabbit.png^[colorize:#FF0000:192", 0) -- TODO: Update inventory image +mobs:register_egg("mobs_mc:killer_bunny", S("Killer Bunny"), "mobs_mc_spawn_icon_rabbit_caerbannog.png", 0) From e9f38c6b90ea33234a75a1a95dc03b94c760f602 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 22 May 2021 10:47:28 +0200 Subject: [PATCH 03/74] WIP raycast base buckets --- mods/ITEMS/mcl_buckets/init.lua | 320 +++++++++++++++++++++----------- 1 file changed, 211 insertions(+), 109 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 7e67eee8e2..3103aeb4fa 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -44,129 +44,166 @@ local place_liquid = function(pos, itemstring) sound_place(itemstring, pos) minetest.add_node(pos, {name=itemstring, param2=fullness}) end +local function give_bucket(new_bucket, itemstack, user) + if itemstack:get_count() == 1 then + return new_bucket + else + local inv = user:get_inventory() + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) + else + minetest.add_item(user:get_pos(), new_bucket) + end + if not minetest.is_creative_enabled(user:get_player_name()) then + itemstack:take_item() + end + return itemstack + end +end + +local function bucket_raycast(user) + local pos = user:get_pos() + pos.y = pos.y + user:get_properties().eye_height + local look_dir = user:get_look_dir() + look_dir = vector.multiply(look_dir, 6) + local pos2 = vector.add(pos, look_dir) + + local ray = raycast(pos, pos2, false, true) + if ray then + for pointed_thing in ray do + if pointed_thing and get_node_group(get_node(pointed_thing.above).name, "_mcl_bucket_pointable") == 1 then + --minetest.chat_send_all("found!") + return {under=pointed_thing.under,above=pointed_thing.above} + end + end + end + return nil +end function mcl_buckets.register_liquid(def) - for i=1, #def.source_take do - mcl_buckets.liquids[def.source_take[i]] = { + for _,source in ipairs(def.source_take) do + mcl_buckets.liquids[source] = { source_place = def.source_place, - source_take = def.source_take[i], + source_take = source, on_take = def.on_take, itemname = def.itemname, } if type(def.source_place) == "string" then - mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[def.source_take[i]] + mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[source] end end - if def.itemname ~= nil then - minetest.register_craftitem(def.itemname, { - description = def.name, - _doc_items_longdesc = def.longdesc, - _doc_items_usagehelp = def.usagehelp, - _tt_help = def.tt_help, - inventory_image = def.inventory_image, - stack_max = 1, - groups = def.groups, - on_place = function(itemstack, user, pointed_thing) - -- Must be pointing to node - if pointed_thing.type ~= "node" then - return - end + if def.itemname == nil or def.itemname == "" then + error(string.format("[mcl_bucket] Invalid itemname then registering [%s]!", def.name)) + end - local node = minetest.get_node(pointed_thing.under) - local place_pos = pointed_thing.under - local nn = node.name - -- Call on_rightclick if the pointed node defines it - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then - return minetest.registered_nodes[nn].on_rightclick(place_pos, node, user, itemstack) or itemstack - end - end + minetest.register_craftitem(def.itemname, { + description = def.name, + _doc_items_longdesc = def.longdesc, + _doc_items_usagehelp = def.usagehelp, + _tt_help = def.tt_help, + inventory_image = def.inventory_image, + stack_max = 1, + groups = def.groups, + on_place = function(itemstack, user, pointed_thing) + -- Must be pointing to node + if pointed_thing.type ~= "node" then + return + end - local node_place - if type(def.source_place) == "function" then - node_place = def.source_place(place_pos) - else - node_place = def.source_place + local node = minetest.get_node(pointed_thing.under) + local place_pos = pointed_thing.under + local nn = node.name + -- Call on_rightclick if the pointed node defines it + if user and not user:get_player_control().sneak then + if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then + return minetest.registered_nodes[nn].on_rightclick(place_pos, node, user, itemstack) or itemstack end - -- Check if pointing to a buildable node - local item = itemstack:get_name() + end - if def.extra_check and def.extra_check(place_pos, user) == false then - -- Fail placement of liquid - elseif minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then - -- buildable; replace the node - local pns = user:get_player_name() - if minetest.is_protected(place_pos, pns) then - minetest.record_protection_violation(place_pos, pns) + local node_place + if type(def.source_place) == "function" then + node_place = def.source_place(place_pos) + else + node_place = def.source_place + end + -- Check if pointing to a buildable node + local item = itemstack:get_name() + + if def.extra_check and def.extra_check(place_pos, user) == false then + -- Fail placement of liquid + elseif minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then + -- buildable; replace the node + local pns = user:get_player_name() + if minetest.is_protected(place_pos, pns) then + minetest.record_protection_violation(place_pos, pns) + return itemstack + end + place_liquid(place_pos, node_place) + if mod_doc and doc.entry_exists("nodes", node_place) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) + end + else + -- not buildable to; place the liquid above + -- check if the node above can be replaced + local abovenode = minetest.get_node(pointed_thing.above) + if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then + local pn = user:get_player_name() + if minetest.is_protected(pointed_thing.above, pn) then + minetest.record_protection_violation(pointed_thing.above, pn) return itemstack end - place_liquid(place_pos, node_place) + place_liquid(pointed_thing.above, node_place) if mod_doc and doc.entry_exists("nodes", node_place) then doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) end else - -- not buildable to; place the liquid above - -- check if the node above can be replaced - local abovenode = minetest.get_node(pointed_thing.above) - if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then - local pn = user:get_player_name() - if minetest.is_protected(pointed_thing.above, pn) then - minetest.record_protection_violation(pointed_thing.above, pn) - return itemstack - end - place_liquid(pointed_thing.above, node_place) - if mod_doc and doc.entry_exists("nodes", node_place) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) - end - else - -- do not remove the bucket with the liquid - return - end - end - - -- Handle bucket item and inventory stuff - if not minetest.is_creative_enabled(user:get_player_name()) then - -- Add empty bucket and put it into inventory, if possible. - -- Drop empty bucket otherwise. - local new_bucket = ItemStack("mcl_buckets:bucket_empty") - if itemstack:get_count() == 1 then - return new_bucket - else - local inv = user:get_inventory() - if inv:room_for_item("main", new_bucket) then - inv:add_item("main", new_bucket) - else - minetest.add_item(user:get_pos(), new_bucket) - end - itemstack:take_item() - return itemstack - end - else + -- do not remove the bucket with the liquid return end - end, - _on_dispense = function(stack, pos, droppos, dropnode, dropdir) - local iname = stack:get_name() - local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" + end - if def.extra_check and def.extra_check(droppos, nil) == false then - -- Fail placement of liquid - elseif buildable then - -- buildable; replace the node - local node_place - if type(def.source_place) == "function" then - node_place = def.source_place(droppos) + -- Handle bucket item and inventory stuff + if not minetest.is_creative_enabled(user:get_player_name()) then + -- Add empty bucket and put it into inventory, if possible. + -- Drop empty bucket otherwise. + local new_bucket = ItemStack("mcl_buckets:bucket_empty") + if itemstack:get_count() == 1 then + return new_bucket + else + local inv = user:get_inventory() + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) else - node_place = def.source_place + minetest.add_item(user:get_pos(), new_bucket) end - place_liquid(droppos, node_place) - stack:set_name("mcl_buckets:bucket_empty") + itemstack:take_item() + return itemstack end - return stack - end, - }) - end + else + return + end + end, + _on_dispense = function(stack, pos, droppos, dropnode, dropdir) + local iname = stack:get_name() + local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" + + if def.extra_check and def.extra_check(droppos, nil) == false then + -- Fail placement of liquid + elseif buildable then + -- buildable; replace the node + local node_place + if type(def.source_place) == "function" then + node_place = def.source_place(droppos) + else + node_place = def.source_place + end + place_liquid(droppos, node_place) + stack:set_name("mcl_buckets:bucket_empty") + end + return stack + end, + }) end minetest.register_craftitem("mcl_buckets:bucket_empty", { @@ -174,26 +211,25 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { _doc_items_longdesc = S("A bucket can be used to collect and release liquids."), _doc_items_usagehelp = S("Punch a liquid source to collect it. You can then use the filled bucket to place the liquid somewhere else."), _tt_help = S("Collects liquids"), - - liquids_pointable = true, + --liquids_pointable = true, inventory_image = "bucket.png", stack_max = 16, on_place = function(itemstack, user, pointed_thing) - -- Must be pointing to node + --[[-- Must be pointing to node if pointed_thing.type ~= "node" then return itemstack end -- Call on_rightclick if the pointed node defines it - local node = minetest.get_node(pointed_thing.under) - local nn = node.name - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then - return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack - end - end + + + local pointed_liquid = bucket_raycast(user) -- Can't steal liquids + if minetest.is_protected(pointed_liquid.above, user:get_player_name()) then + minetest.record_protection_violation(pointed_liquid.under, user:get_player_name()) + return itemstack + end if minetest.is_protected(pointed_thing.above, user:get_player_name()) then minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) return itemstack @@ -208,8 +244,8 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { if not minetest.is_creative_enabled(user:get_player_name()) then new_bucket = ItemStack({name = liquiddef.itemname}) if liquiddef.on_take then - liquiddef.on_take(user) - end + liquiddef.on_take(user) + end end minetest.add_node(pointed_thing.under, {name="air"}) @@ -252,7 +288,73 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { end return itemstack end + end]] + if pointed_thing.type ~= "node" then + return itemstack end + local node = minetest.get_node(pointed_thing.under) + local nn = node.name + if user and not user:get_player_control().sneak then + if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then + return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack + end + end + + local liquid_node = bucket_raycast(user) + if liquid_node then + if minetest.is_protected(liquid_node.above, user:get_player_name()) then + minetest.record_protection_violation(liquid_node.above, user:get_player_name()) + end + local liquid_name = get_node(liquid_node.above).name + if liquid_name then + local liquid_def = mcl_buckets.liquids[liquid_name] + if liquid_def then + local new_bucket + --minetest.chat_send_all("test") + -- Fill bucket, but not in Creative Mode + -- FIXME: remove this line + --if not minetest.is_creative_enabled(user:get_player_name()) then + if not false then + new_bucket = ItemStack({name = liquid_def.itemname}) + if liquid_def.on_take then + liquid_def.on_take(user) + end + end + add_node(liquid_node.above, {name="air"}) + sound_take(nn, liquid_node.above) + + if mod_doc and doc.entry_exists("nodes", liquid_name) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", liquid_name) + end + if new_bucket then + return give_bucket(new_bucket, itemstack, user) + end + else + minetest.log("error", string.format("[mcl_buckets] Node [%s] has invalid group [_mcl_bucket_pointable]!", liquid_name)) + end + end + return itemstack + else + -- FIXME: replace this ugly code by cauldrons API + if nn == "mcl_cauldrons:cauldron_3" then + -- Take water out of full cauldron + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + if not minetest.is_creative_enabled(user:get_player_name()) then + new_bucket = ItemStack("mcl_buckets:bucket_water") + end + sound_take("mcl_core:water_source", pointed_thing.under) + elseif nn == "mcl_cauldrons:cauldron_3r" then + -- Take river water out of full cauldron + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + if not minetest.is_creative_enabled(user:get_player_name()) then + new_bucket = ItemStack("mcl_buckets:bucket_river_water") + end + sound_take("mclx_core:river_water_source", pointed_thing.under) + end + if new_bucket then + return give_bucket(new_bucket, itemstack, user) + end + end end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) -- Fill empty bucket with liquid or drop bucket if no liquid From 5d65c8a3aa58da596befac454eae5ed205e2e510 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 22 May 2021 18:57:51 +0200 Subject: [PATCH 04/74] Working empty bucket --- mods/ITEMS/mcl_buckets/init.lua | 6 ++++++ mods/ITEMS/mcl_core/nodes_liquid.lua | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 3103aeb4fa..327d553c8c 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -11,6 +11,11 @@ local mod_doc = minetest.get_modpath("doc") local mod_mcl_core = minetest.get_modpath("mcl_core") local mod_mclx_core = minetest.get_modpath("mclx_core") +local raycast = minetest.raycast +local get_node = minetest.get_node +local add_node = minetest.add_node +local get_node_group = minetest.get_node_group + if mod_mcl_core then minetest.register_craft({ output = 'mcl_buckets:bucket_empty 1', @@ -355,6 +360,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { return give_bucket(new_bucket, itemstack, user) end end + return itemstack end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) -- Fill empty bucket with liquid or drop bucket if no liquid diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index c49b685eba..47c22c7c6d 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -100,7 +100,7 @@ S("• When water is directly below lava, the water turns into stone."), liquid_range = 7, post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C}, stack_max = 64, - groups = { water=3, liquid=3, puts_out_fire=1, freezes=1, not_in_creative_inventory=1, dig_by_piston=1}, + groups = { water=3, liquid=3, puts_out_fire=1, freezes=1, not_in_creative_inventory=1, dig_by_piston=1, _mcl_bucket_pointable=1}, _mcl_blast_resistance = 100, -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode _mcl_hardness = -1, @@ -203,7 +203,7 @@ S("• When lava is directly above water, the water turns into stone."), _mcl_node_death_message = lava_death_messages, post_effect_color = {a=245, r=208, g=73, b=10}, stack_max = 64, - groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15, fire_damage=1}, + groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15, fire_damage=1, _mcl_bucket_pointable=1}, _mcl_blast_resistance = 100, -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode _mcl_hardness = -1, From 17202115fa2e99fb825dcaf53c73bbaf9a47cb82 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 22 May 2021 18:58:58 +0200 Subject: [PATCH 05/74] cache general functions --- mods/ITEMS/mcl_buckets/init.lua | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 327d553c8c..7f5ab2b16e 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -11,6 +11,10 @@ local mod_doc = minetest.get_modpath("doc") local mod_mcl_core = minetest.get_modpath("mcl_core") local mod_mclx_core = minetest.get_modpath("mclx_core") +local vector = vector +local math = math +local string = string + local raycast = minetest.raycast local get_node = minetest.get_node local add_node = minetest.add_node From 640b0dc4859014f15939cce0be36dd06c2b1419c Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 2 Jun 2021 00:23:11 +0200 Subject: [PATCH 06/74] basic title API working (testing needed) --- mods/HUD/mcl_title/init.lua | 161 ++++++++++++++++++++++++++++++++++++ mods/HUD/mcl_title/mod.conf | 4 + 2 files changed, 165 insertions(+) create mode 100644 mods/HUD/mcl_title/init.lua create mode 100644 mods/HUD/mcl_title/mod.conf diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua new file mode 100644 index 0000000000..9975ff840f --- /dev/null +++ b/mods/HUD/mcl_title/init.lua @@ -0,0 +1,161 @@ +--TODO: use SSCSM to reduce lag and network trafic (just send modchannel messages) +--TODO: exactly mc like layout + +local huds_idx = {} + +huds_idx.title = {} +huds_idx.subtitle = {} +huds_idx.actionbar = {} + +mcl_title = {} +mcl_title.defaults = {fadein = 10, stay = 70, fadeout = 20} +mcl_title.layout = {} +mcl_title.layout.title = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = -1.3}, size = 5} +mcl_title.layout.subtitle = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = 1.9}, size = 2} +mcl_title.layout.actionbar = {position = {x = 0.5, y = 1}, alignment = {x = 0, y = -15}, size = 1} + +local get_color = mcl_util.get_color + +local function gametick_to_secondes(gametick) + return gametick / 20 +end + + +--PARAMS SYSTEM +local player_params = {} + +minetest.register_on_joinplayer(function(player) + player_params[player] = { + stay = gametick_to_secondes(mcl_title.defaults.stay), + --fadeIn = gametick_to_secondes(mcl_title.defaults.fadein), + --fadeOut = gametick_to_secondes(mcl_title.defaults.fadeout), + } +end) + +minetest.register_on_leaveplayer(function(player) + player_params = nil +end) + +function mcl_title.params_set(player, data) + player_params[player] = { + stay = gametick_to_secondes(data.stay) or gametick_to_secondes(mcl_title.defaults.stay), + --fadeIn = gametick_to_secondes(data.fadeIn) or gametick_to_secondes(mcl_title.defaults.fadein), + --fadeOut = gametick_to_secondes(data.fadeOut) or gametick_to_secondes(mcl_title.defaults.fadeout), + } +end + +function mcl_title.params_get(player) + return player_params[player] +end + +--API FUNCTIONS + +function mcl_title.set(player, type, data) + if not data.color then + data.color = "white" + end + local _, hex_color = get_color(data.color) + if not hex_color then + return false + end + + if huds_idx[type][player] then + player:hud_remove(huds_idx[type][player]) + end + + --TODO: enable this code then Fleckenstein's pr get merged + --[[ + local bold + if data.bold == "true" then + bold = true + else + bold = false + end + + local italic + if data.italic == "true" then + italic = true + else + italic = false + end]] + + local stay = mcl_title.params_get(player).stay + + huds_idx[type][player] = player:hud_add({ + hud_elem_type = "text", + position = mcl_title.layout[type].position, + alignment = mcl_title.layout[type].alignment, + text = data.text, + --bold = bold, + --italic = italic, + size = {x = mcl_title.layout[type].size}, + number = hex_color, + z_index = 1100, + }) + + minetest.after(stay, function() + if huds_idx[type][player] then + player:hud_remove(huds_idx[type][player]) + end + huds_idx[type][player] = nil + end) + return true +end + +function mcl_title.remove(player, type) + if huds_idx[type][player] then + player:hud_remove(huds_idx[type][player]) + end + huds_idx[type][player] = nil +end + +function mcl_title.clear(player) + mcl_title.remove(player, "title") + mcl_title.remove(player, "subtitle") + mcl_title.remove(player, "actionbar") +end + +minetest.register_on_dieplayer(function(player) + mcl_title.clear(player) +end) + + +--TEMP STUFF!! +--TODO: remove then testing/tweaking done +minetest.register_chatcommand("title", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.set(player, "title", {text=param, color="gold"}) + end, +}) + +minetest.register_chatcommand("subtitle", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.set(player, "subtitle", {text=param, color="gold"}) + end, +}) + +minetest.register_chatcommand("actionbar", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.set(player, "actionbar", {text=param, color="gold"}) + end, +}) + +minetest.register_chatcommand("timeout", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.params_set(player, {stay = 600}) + end, +}) + +minetest.register_chatcommand("all", { + func = function(name, param) + local player = minetest.get_player_by_name(name) + mcl_title.params_set(player, {stay = 600}) + mcl_title.set(player, "title", {text=param, color="gold"}) + mcl_title.set(player, "subtitle", {text=param, color="gold"}) + mcl_title.set(player, "actionbar", {text=param, color="gold"}) + end, +}) \ No newline at end of file diff --git a/mods/HUD/mcl_title/mod.conf b/mods/HUD/mcl_title/mod.conf new file mode 100644 index 0000000000..0f29a8118c --- /dev/null +++ b/mods/HUD/mcl_title/mod.conf @@ -0,0 +1,4 @@ +name = mcl_title +description = Add an API to add in HUD title +depends = mcl_colors +author = AFCMS \ No newline at end of file From 6b53dda79bf8b31309206ea29b6e84184cc17fc7 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 2 Jun 2021 00:25:15 +0200 Subject: [PATCH 07/74] add todo list --- mods/HUD/mcl_title/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index 9975ff840f..41b4dfc4a7 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -1,4 +1,5 @@ --TODO: use SSCSM to reduce lag and network trafic (just send modchannel messages) +--TODO: fadeIn and fadeOut animation (needs engine change: SSCSM or native support) --TODO: exactly mc like layout local huds_idx = {} From c8102838cb80e5ada8649a7ccf48c1c288a4de2b Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 2 Jun 2021 00:26:10 +0200 Subject: [PATCH 08/74] add missing TODO entry (bold+italic) --- mods/HUD/mcl_title/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index 41b4dfc4a7..807ed19c98 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -65,6 +65,7 @@ function mcl_title.set(player, type, data) end --TODO: enable this code then Fleckenstein's pr get merged + --TODO: be sure API is correctly used --[[ local bold if data.bold == "true" then From 7e64470f7086c2978f0ad48710d6c0f253b6c3cb Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 2 Jun 2021 11:07:31 +0200 Subject: [PATCH 09/74] fix future API usage of bold+italic pr --- mods/HUD/mcl_title/init.lua | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index 807ed19c98..83277b3bf5 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -64,22 +64,10 @@ function mcl_title.set(player, type, data) player:hud_remove(huds_idx[type][player]) end - --TODO: enable this code then Fleckenstein's pr get merged - --TODO: be sure API is correctly used - --[[ - local bold - if data.bold == "true" then - bold = true - else - bold = false - end + --TODO: enable this code then Fleckenstein's pr get merged (in about 5-6 years) - local italic - if data.italic == "true" then - italic = true - else - italic = false - end]] + --if data.bold == nil then data.bold = false end + --if data.italic == nil then data.italic = false end local stay = mcl_title.params_get(player).stay @@ -88,8 +76,8 @@ function mcl_title.set(player, type, data) position = mcl_title.layout[type].position, alignment = mcl_title.layout[type].alignment, text = data.text, - --bold = bold, - --italic = italic, + --bold = data.bold, + --italic = data.italic, size = {x = mcl_title.layout[type].size}, number = hex_color, z_index = 1100, From b9fd1ac227c59407a92ca208d1fd71681c7952f0 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 2 Jun 2021 11:12:15 +0200 Subject: [PATCH 10/74] credit digminecraft for the tutorial --- mods/HUD/mcl_title/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index 83277b3bf5..a2fd82b24c 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -1,3 +1,5 @@ +--Based on https://www.digminecraft.com/game_commands/title_command.php + --TODO: use SSCSM to reduce lag and network trafic (just send modchannel messages) --TODO: fadeIn and fadeOut animation (needs engine change: SSCSM or native support) --TODO: exactly mc like layout From 2603c4768ba34be059b8f3dd175985bc08683cea Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 7 Jun 2021 22:32:05 +0200 Subject: [PATCH 11/74] mcl_title: basic mc like layout (collide with other mods) --- mods/HUD/mcl_title/init.lua | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index a2fd82b24c..ffd740b4a8 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -1,7 +1,11 @@ ---Based on https://www.digminecraft.com/game_commands/title_command.php +--Based on: +--https://www.digminecraft.com/game_commands/title_command.php +--https://youtu.be/oVrtQRO2hpY --TODO: use SSCSM to reduce lag and network trafic (just send modchannel messages) --TODO: fadeIn and fadeOut animation (needs engine change: SSCSM or native support) +--TODO: allow obfuscating text (needs engine change: SSCSM or native support) +--TODO: allow colorizing and styling of part of the text (NEEDS ENGINE CHANGE!!!) --TODO: exactly mc like layout local huds_idx = {} @@ -13,9 +17,9 @@ huds_idx.actionbar = {} mcl_title = {} mcl_title.defaults = {fadein = 10, stay = 70, fadeout = 20} mcl_title.layout = {} -mcl_title.layout.title = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = -1.3}, size = 5} -mcl_title.layout.subtitle = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = 1.9}, size = 2} -mcl_title.layout.actionbar = {position = {x = 0.5, y = 1}, alignment = {x = 0, y = -15}, size = 1} +mcl_title.layout.title = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = -1.3}, size = 7} +mcl_title.layout.subtitle = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = 1.7}, size = 4} +mcl_title.layout.actionbar = {position = {x = 0.5, y = 1}, alignment = {x = 0, y = -11}, size = 2} local get_color = mcl_util.get_color From 40f4287ff200ec20bb2d25650a0b37606bd74b38 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 12 Jun 2021 12:21:01 +0200 Subject: [PATCH 12/74] new buckets fixes --- mods/ITEMS/mcl_buckets/init.lua | 50 ++++++++++++++++------------ mods/ITEMS/mcl_buckets/register.lua | 2 +- mods/ITEMS/mcl_core/nodes_liquid.lua | 4 +-- 3 files changed, 31 insertions(+), 25 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 23d7244e59..f2f61ccfcb 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -18,7 +18,8 @@ local string = string local raycast = minetest.raycast local get_node = minetest.get_node local add_node = minetest.add_node -local get_node_group = minetest.get_node_group +local add_item = minetest.add_item + if mod_mcl_core then minetest.register_craft({ @@ -26,7 +27,7 @@ if mod_mcl_core then recipe = { {"mcl_core:iron_ingot", "", "mcl_core:iron_ingot"}, {"", "mcl_core:iron_ingot", ""}, - } + }, }) end @@ -34,42 +35,47 @@ mcl_buckets = {} mcl_buckets.liquids = {} -- Sound helper functions for placing and taking liquids -local sound_place = function(itemname, pos) +local function sound_place(itemname, pos) local def = minetest.registered_nodes[itemname] if def and def.sounds and def.sounds.place then minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end end -local sound_take = function(itemname, pos) +local function sound_take(itemname, pos) local def = minetest.registered_nodes[itemname] if def and def.sounds and def.sounds.dug then minetest.sound_play(def.sounds.dug, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) end end -local place_liquid = function(pos, itemstring) +local function place_liquid(pos, itemstring) local fullness = minetest.registered_nodes[itemstring].liquid_range sound_place(itemstring, pos) minetest.add_node(pos, {name=itemstring, param2=fullness}) end local function give_bucket(new_bucket, itemstack, user) - if itemstack:get_count() == 1 then - return new_bucket - else - local inv = user:get_inventory() - if inv:room_for_item("main", new_bucket) then - inv:add_item("main", new_bucket) - else - minetest.add_item(user:get_pos(), new_bucket) - end - if not minetest.is_creative_enabled(user:get_player_name()) then - itemstack:take_item() - end + local inv = user:get_inventory() + if minetest.is_creative_enabled(user:get_player_name()) then + --TODO: is a full bucket added if inv doesn't contain one? return itemstack + else + if itemstack:get_count() == 1 then + return new_bucket + else + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) + else + add_item(user:get_pos(), new_bucket) + end + itemstack:take_item() + return itemstack + end end end +local pointable_sources = {} + local function bucket_raycast(user) local pos = user:get_pos() pos.y = pos.y + user:get_properties().eye_height @@ -77,10 +83,10 @@ local function bucket_raycast(user) look_dir = vector.multiply(look_dir, 6) local pos2 = vector.add(pos, look_dir) - local ray = raycast(pos, pos2, false, true) + local ray = raycast(pos, pos2, false, true) if ray then for pointed_thing in ray do - if pointed_thing and get_node_group(get_node(pointed_thing.above).name, "_mcl_bucket_pointable") == 1 then + if pointed_thing and pointable_sources[get_node(pointed_thing.above).name] then --minetest.chat_send_all("found!") return {under=pointed_thing.under,above=pointed_thing.above} end @@ -97,6 +103,7 @@ function mcl_buckets.register_liquid(def) on_take = def.on_take, itemname = def.itemname, } + pointable_sources[source] = true if type(def.source_place) == "string" then mcl_buckets.liquids[def.source_place] = mcl_buckets.liquids[source] end @@ -137,7 +144,7 @@ function mcl_buckets.register_liquid(def) node_place = def.source_place end -- Check if pointing to a buildable node - local item = itemstack:get_name() + --local item = itemstack:get_name() if def.extra_check and def.extra_check(place_pos, user) == false then -- Fail placement of liquid @@ -308,7 +315,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack end end - + local new_bucket local liquid_node = bucket_raycast(user) if liquid_node then if minetest.is_protected(liquid_node.above, user:get_player_name()) then @@ -318,7 +325,6 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { if liquid_name then local liquid_def = mcl_buckets.liquids[liquid_name] if liquid_def then - local new_bucket --minetest.chat_send_all("test") -- Fill bucket, but not in Creative Mode -- FIXME: remove this line diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 863aa074c2..12790598c5 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -3,7 +3,7 @@ local mod_mcl_core = minetest.get_modpath("mcl_core") local mod_mclx_core = minetest.get_modpath("mclx_core") local has_awards = minetest.get_modpath("awards") -local sound_place = function(itemname, pos) +local function sound_place(itemname, pos) local def = minetest.registered_nodes[itemname] if def and def.sounds and def.sounds.place then minetest.sound_play(def.sounds.place, {gain=1.0, pos = pos, pitch = 1 + math.random(-10, 10)*0.005}, true) diff --git a/mods/ITEMS/mcl_core/nodes_liquid.lua b/mods/ITEMS/mcl_core/nodes_liquid.lua index d4234b8acf..0e0f71a112 100644 --- a/mods/ITEMS/mcl_core/nodes_liquid.lua +++ b/mods/ITEMS/mcl_core/nodes_liquid.lua @@ -95,7 +95,7 @@ S("• When water is directly below lava, the water turns into stone."), liquid_range = 7, post_effect_color = {a=209, r=0x03, g=0x3C, b=0x5C}, stack_max = 64, - groups = { water=3, liquid=3, puts_out_fire=1, freezes=1, not_in_creative_inventory=1, dig_by_piston=1, _mcl_bucket_pointable=1}, + groups = { water=3, liquid=3, puts_out_fire=1, freezes=1, not_in_creative_inventory=1, dig_by_piston=1}, _mcl_blast_resistance = 100, -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode _mcl_hardness = -1, @@ -196,7 +196,7 @@ S("• When lava is directly above water, the water turns into stone."), damage_per_second = 4*2, post_effect_color = {a=245, r=208, g=73, b=10}, stack_max = 64, - groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15, fire_damage=1, _mcl_bucket_pointable=1}, + groups = { lava=3, lava_source=1, liquid=2, destroys_items=1, not_in_creative_inventory=1, dig_by_piston=1, set_on_fire=15, fire_damage=1}, _mcl_blast_resistance = 100, -- Hardness intentionally set to infinite instead of 100 (Minecraft value) to avoid problems in creative mode _mcl_hardness = -1, From 30e2e0d70afbbadf9fc7181bfde097ccf6fdd014 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 14 Jun 2021 14:36:17 +0200 Subject: [PATCH 13/74] test values --- mods/ITEMS/mcl_buckets/init.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index f2f61ccfcb..70a219ffbe 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -77,10 +77,11 @@ end local pointable_sources = {} local function bucket_raycast(user) - local pos = user:get_pos() + --local pos = user:get_pos() + local pos = mcl_util.get_object_center(user) pos.y = pos.y + user:get_properties().eye_height local look_dir = user:get_look_dir() - look_dir = vector.multiply(look_dir, 6) + look_dir = vector.multiply(look_dir, 4) local pos2 = vector.add(pos, look_dir) local ray = raycast(pos, pos2, false, true) From 8e931e92f57ce18792a846828e0e942f52f8eef1 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 9 Jul 2021 11:34:23 +0200 Subject: [PATCH 14/74] refactor mcl_title to be more efficient --- mods/HUD/mcl_title/init.lua | 120 +++++++++++++++++++++++++++--------- 1 file changed, 90 insertions(+), 30 deletions(-) diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index ffd740b4a8..48c3a909f7 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -8,8 +8,17 @@ --TODO: allow colorizing and styling of part of the text (NEEDS ENGINE CHANGE!!!) --TODO: exactly mc like layout +--Note that the table storing timeouts use playername as index insteed of player objects (faster) +--This is intended in order to speedup the process of removing HUD elements the the timeout is up + local huds_idx = {} +local hud_hide_timeouts = {} + +hud_hide_timeouts.title = {} +hud_hide_timeouts.subtitle = {} +hud_hide_timeouts.actionbar = {} + huds_idx.title = {} huds_idx.subtitle = {} huds_idx.actionbar = {} @@ -19,10 +28,13 @@ mcl_title.defaults = {fadein = 10, stay = 70, fadeout = 20} mcl_title.layout = {} mcl_title.layout.title = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = -1.3}, size = 7} mcl_title.layout.subtitle = {position = {x = 0.5, y = 0.5}, alignment = {x = 0, y = 1.7}, size = 4} -mcl_title.layout.actionbar = {position = {x = 0.5, y = 1}, alignment = {x = 0, y = -11}, size = 2} +mcl_title.layout.actionbar = {position = {x = 0.5, y = 1}, alignment = {x = 0, y = 0}, size = 1} local get_color = mcl_util.get_color +local string = string +local pairs = pairs + local function gametick_to_secondes(gametick) return gametick / 20 end @@ -32,15 +44,64 @@ end local player_params = {} minetest.register_on_joinplayer(function(player) - player_params[player] = { + local playername = player:get_player_name() + player_params[playername] = { stay = gametick_to_secondes(mcl_title.defaults.stay), --fadeIn = gametick_to_secondes(mcl_title.defaults.fadein), --fadeOut = gametick_to_secondes(mcl_title.defaults.fadeout), - } + } + local _, hex_color = get_color("white") + huds_idx.title[player] = player:hud_add({ + hud_elem_type = "text", + position = mcl_title.layout.title.position, + alignment = mcl_title.layout.title.alignment, + text = "", + --bold = data.bold, + --italic = data.italic, + size = {x = mcl_title.layout.title.size}, + number = hex_color, + z_index = 100, + }) + huds_idx.subtitle[player] = player:hud_add({ + hud_elem_type = "text", + position = mcl_title.layout.subtitle.position, + alignment = mcl_title.layout.subtitle.alignment, + text = "", + --bold = data.bold, + --italic = data.italic, + size = {x = mcl_title.layout.subtitle.size}, + number = hex_color, + z_index = 100, + }) + huds_idx.actionbar[player] = player:hud_add({ + hud_elem_type = "text", + position = mcl_title.layout.actionbar.position, + offset = {x = 0, y = -210}, + alignment = mcl_title.layout.actionbar.alignment, + --bold = data.bold, + --italic = data.italic, + text = "", + size = {x = mcl_title.layout.actionbar.size}, + number = hex_color, + z_index = 100, + }) end) minetest.register_on_leaveplayer(function(player) - player_params = nil + local playername = player:get_player_name() + + --remove player params from the list + player_params[player] = nil + + --remove HUD idx from the list (HUD elements are removed by the engine) + huds_idx.title[player] = nil + huds_idx.subtitle[player] = nil + huds_idx.actionbar[player] = nil + + --remove timers form list + hud_hide_timeouts.title[playername] = nil + hud_hide_timeouts.subtitle[playername] = nil + hud_hide_timeouts.actionbar[playername] = nil end) function mcl_title.params_set(player, data) @@ -66,43 +127,22 @@ function mcl_title.set(player, type, data) return false end - if huds_idx[type][player] then - player:hud_remove(huds_idx[type][player]) - end - --TODO: enable this code then Fleckenstein's pr get merged (in about 5-6 years) --if data.bold == nil then data.bold = false end --if data.italic == nil then data.italic = false end - local stay = mcl_title.params_get(player).stay + player:hud_change(huds_idx[type][player], "text", data.text) + player:hud_change(huds_idx[type][player], "number", hex_color) - huds_idx[type][player] = player:hud_add({ - hud_elem_type = "text", - position = mcl_title.layout[type].position, - alignment = mcl_title.layout[type].alignment, - text = data.text, - --bold = data.bold, - --italic = data.italic, - size = {x = mcl_title.layout[type].size}, - number = hex_color, - z_index = 1100, - }) - - minetest.after(stay, function() - if huds_idx[type][player] then - player:hud_remove(huds_idx[type][player]) - end - huds_idx[type][player] = nil - end) + hud_hide_timeouts[type][player:get_player_name()] = data.stay or mcl_title.params_get(player).stay return true end function mcl_title.remove(player, type) - if huds_idx[type][player] then - player:hud_remove(huds_idx[type][player]) + if player then + player:hud_change(huds_idx[type][player], "text", "") end - huds_idx[type][player] = nil end function mcl_title.clear(player) @@ -115,6 +155,26 @@ minetest.register_on_dieplayer(function(player) mcl_title.clear(player) end) +minetest.register_globalstep(function(dtime) + local new_timeouts = { + title = {}, + subtitle = {}, + actionbar = {}, + } + for element, content in pairs(hud_hide_timeouts) do + for name, timeout in pairs(content) do + timeout = timeout - dtime + if timeout <= 0 then + local player = minetest.get_player_by_name(name) + mcl_title.remove(player, element) + else + new_timeouts[element][name] = timeout + end + end + end + hud_hide_timeouts = new_timeouts +end) + --TEMP STUFF!! --TODO: remove then testing/tweaking done From d2f7d3136028f726d3aaba1ff7e4304e1952aef5 Mon Sep 17 00:00:00 2001 From: Emojigit Date: Sat, 10 Jul 2021 10:16:55 +0800 Subject: [PATCH 15/74] Fix warning in `mcl_end` This fixes: ``` 2021-07-10 10:00:58: WARNING[Main]: get_mapgen_params is deprecated; use get_mapgen_setting instead (at .../../games/MineClone2/mods/ITEMS/mcl_end/chorus_plant.lua:456) ``` --- 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 24307b5ed6..4dc54db186 100644 --- a/mods/ITEMS/mcl_end/chorus_plant.lua +++ b/mods/ITEMS/mcl_end/chorus_plant.lua @@ -453,7 +453,7 @@ function mcl_end.grow_chorus_plant_step(pos, node, pr) end --- ABM --- -local seed = minetest.get_mapgen_params().seed +local seed = minetest.get_mapgen_setting("seed") local pr = PseudoRandom(seed) minetest.register_abm({ label = "Chorus plant growth", From d26b1b1402056b5add6bf25d5e791bfc6c8b1ab1 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 09:10:01 +0200 Subject: [PATCH 16/74] use mcl_util.call_on_rightclick insteed of current implementation --- mods/ITEMS/mcl_buckets/init.lua | 27 ++++++++++++++++----------- mods/ITEMS/mcl_buckets/mod.conf | 2 +- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 70a219ffbe..fdd08bdf92 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -3,6 +3,7 @@ local modname = minetest.get_current_modname() local S = minetest.get_translator(modname) local modpath = minetest.get_modpath(modname) +-- Compatibility with old bucket mod minetest.register_alias("bucket:bucket_empty", "mcl_buckets:bucket_empty") minetest.register_alias("bucket:bucket_water", "mcl_buckets:bucket_water") minetest.register_alias("bucket:bucket_lava", "mcl_buckets:bucket_lava") @@ -11,6 +12,7 @@ local mod_doc = minetest.get_modpath("doc") local mod_mcl_core = minetest.get_modpath("mcl_core") --local mod_mclx_core = minetest.get_modpath("mclx_core") +-- Localize some functions for faster access local vector = vector local math = math local string = string @@ -127,16 +129,15 @@ function mcl_buckets.register_liquid(def) if pointed_thing.type ~= "node" then return end + -- Call on_rightclick if the pointed node defines it + local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) + if new_stack then + return new_stack + end local node = minetest.get_node(pointed_thing.under) local place_pos = pointed_thing.under local nn = node.name - -- Call on_rightclick if the pointed node defines it - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then - return minetest.registered_nodes[nn].on_rightclick(place_pos, node, user, itemstack) or itemstack - end - end local node_place if type(def.source_place) == "function" then @@ -306,16 +307,20 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { return itemstack end end]] + -- Must be pointing to node if pointed_thing.type ~= "node" then return itemstack end + + -- Call on_rightclick if the pointed node defines it + local new_stack = mcl_util.call_on_rightclick(itemstack, user, pointed_thing) + if new_stack then + return new_stack + end + local node = minetest.get_node(pointed_thing.under) local nn = node.name - if user and not user:get_player_control().sneak then - if minetest.registered_nodes[nn] and minetest.registered_nodes[nn].on_rightclick then - return minetest.registered_nodes[nn].on_rightclick(pointed_thing.under, node, user, itemstack) or itemstack - end - end + local new_bucket local liquid_node = bucket_raycast(user) if liquid_node then diff --git a/mods/ITEMS/mcl_buckets/mod.conf b/mods/ITEMS/mcl_buckets/mod.conf index 5a78e70ada..0d7b764b87 100644 --- a/mods/ITEMS/mcl_buckets/mod.conf +++ b/mods/ITEMS/mcl_buckets/mod.conf @@ -1,6 +1,6 @@ name = mcl_buckets author = Kahrl description = -depends = mcl_worlds +depends = mcl_worlds, mcl_util optional_depends = mcl_core, mclx_core, doc From b0127fc1c3cb66ba0e024b9ea4cf82080ea80ced Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 09:18:15 +0200 Subject: [PATCH 17/74] fix bucket dispense function --- mods/ITEMS/mcl_buckets/init.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index fdd08bdf92..95ec974431 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -205,11 +205,16 @@ function mcl_buckets.register_liquid(def) _on_dispense = function(stack, pos, droppos, dropnode, dropdir) local iname = stack:get_name() local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" + if not buildable then return stack end - if def.extra_check and def.extra_check(droppos, nil) == false then - -- Fail placement of liquid - elseif buildable then - -- buildable; replace the node + local result + if def.extra_check then + result = def.extra_check(droppos, nil) + if result == nil then result = true end + else + result = true + end + if result then -- Fail placement of liquid if result is false local node_place if type(def.source_place) == "function" then node_place = def.source_place(droppos) From ca277b6769c8edb1c498c268dd349bd2cd6c72ee Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 11:29:15 +0200 Subject: [PATCH 18/74] mcl_bucket code refactoring + fix extra_check noot working --- mods/ITEMS/mcl_buckets/API.md | 30 +++++- mods/ITEMS/mcl_buckets/init.lua | 144 ++++++++++++++++++++++------ mods/ITEMS/mcl_buckets/register.lua | 26 +---- 3 files changed, 149 insertions(+), 51 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/API.md b/mods/ITEMS/mcl_buckets/API.md index 53f7d36989..4595d8e72a 100644 --- a/mods/ITEMS/mcl_buckets/API.md +++ b/mods/ITEMS/mcl_buckets/API.md @@ -15,7 +15,33 @@ Accept folowing params: * longdesc: long explanatory description (for help) * usagehelp: short usage explanation (for help) * tt_help: very short tooltip help -* extra_check(pos, placer): (optional) function(pos) which can returns false to avoid placing the liquid. Placer is object/player who is placing the liquid, can be nil. +* extra_check(pos, placer): (optional) function(pos) * groups: optional list of item groups -This function can be called from any mod (which depends on this one) \ No newline at end of file + +**Usage exemple:** +```lua +mcl_buckets.register_liquid({ + itemname = "dummy:bucket_dummy", + source_place = "dummy:dummy_source", + source_take = {"dummy:dummy_source"}, + inventory_image = "bucket_dummy.png", + name = S("Dummy liquid Bucket"), + longdesc = S("This bucket is filled with a dummy liquid."), + usagehelp = S("Place it to empty the bucket and create a dummy liquid source."), + tt_help = S("Places a dummy liquid source"), + extra_check = function(pos, placer) + --pos = pos where the liquid should be placed + --placer people who tried to place the bucket (can be nil) + + --no liquid node will be placed + --the bucket will not be emptied + --return false, false + + --liquid node will be placed + --the bucket will be emptied + return true, true + end, + groups = { dummy_group = 123 }, +}) +``` \ No newline at end of file diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 95ec974431..9ae712cedb 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -56,6 +56,7 @@ local function place_liquid(pos, itemstring) sound_place(itemstring, pos) minetest.add_node(pos, {name=itemstring, param2=fullness}) end + local function give_bucket(new_bucket, itemstack, user) local inv = user:get_inventory() if minetest.is_creative_enabled(user:get_player_name()) then @@ -81,6 +82,7 @@ local pointable_sources = {} local function bucket_raycast(user) --local pos = user:get_pos() local pos = mcl_util.get_object_center(user) + --local pos = vector.add(user:get_pos(), user:get_bone_position("Head_Control")) pos.y = pos.y + user:get_properties().eye_height local look_dir = user:get_look_dir() look_dir = vector.multiply(look_dir, 4) @@ -98,6 +100,53 @@ local function bucket_raycast(user) return nil end +local function get_node_place(source_place, place_pos) + local node_place + if type(source_place) == "function" then + node_place = source_place(place_pos) + else + node_place = source_place + end + return node_place +end + +local function get_extra_check(check, pos, user) + local result + local take_bucket + if check then + result, take_bucket = check(pos, user) + if result == nil then result = true end + if take_bucket == nil then take_bucket = true end + else + result = true + take_bucket = true + end + return result, take_bucket +end + +local function get_bucket_drop(itemstack, user, take_bucket) + -- Handle bucket item and inventory stuff + if take_bucket and not minetest.is_creative_enabled(user:get_player_name()) then + -- Add empty bucket and put it into inventory, if possible. + -- Drop empty bucket otherwise. + local new_bucket = ItemStack("mcl_buckets:bucket_empty") + if itemstack:get_count() == 1 then + return new_bucket + else + local inv = user:get_inventory() + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) + else + add_item(user:get_pos(), new_bucket) + end + itemstack:take_item() + return itemstack + end + else + return itemstack + end +end + function mcl_buckets.register_liquid(def) for _,source in ipairs(def.source_take) do mcl_buckets.liquids[source] = { @@ -135,23 +184,75 @@ function mcl_buckets.register_liquid(def) return new_stack end - local node = minetest.get_node(pointed_thing.under) - local place_pos = pointed_thing.under - local nn = node.name + local undernode = get_node(pointed_thing.under) + local abovenode = get_node(pointed_thing.above) + local nn = undernode.name + local buildable1 = minetest.registered_nodes[undernode.name] and minetest.registered_nodes[undernode.name].buildable_to + local buildable2 = minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to + if not buildable1 and not buildable2 then return itemstack end --if both nodes aren't buildable_to, skip + + if buildable1 then + local result, take_bucket = get_extra_check(def.extra_check, pointed_thing.under, user) + if result then + local node_place = get_node_place(def.source_place, pointed_thing.under) + local pns = user:get_player_name() - local node_place - if type(def.source_place) == "function" then - node_place = def.source_place(place_pos) + -- Check protection + if minetest.is_protected(pointed_thing.under, pns) then + minetest.record_protection_violation(pointed_thing.under, pns) + return itemstack + end + + -- Place liquid + place_liquid(pointed_thing.under, node_place) + + -- Update doc mod + if mod_doc and doc.entry_exists("nodes", node_place) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) + end + end + return get_bucket_drop(itemstack, user, take_bucket) + elseif buildable2 then + local result, take_bucket = get_extra_check(def.extra_check, pointed_thing.above, user) + if result then + local node_place = get_node_place(def.source_place, pointed_thing.above) + local pns = user:get_player_name() + + -- Check protection + if minetest.is_protected(pointed_thing.above, pns) then + minetest.record_protection_violation(pointed_thing.above, pns) + return itemstack + end + + -- Place liquid + place_liquid(pointed_thing.above, node_place) + + -- Update doc mod + if mod_doc and doc.entry_exists("nodes", node_place) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) + end + end + return get_bucket_drop(itemstack, user, take_bucket) else - node_place = def.source_place + return itemstack end + -- Check if pointing to a buildable node --local item = itemstack:get_name() - if def.extra_check and def.extra_check(place_pos, user) == false then - -- Fail placement of liquid - elseif minetest.registered_nodes[nn] and minetest.registered_nodes[nn].buildable_to then - -- buildable; replace the node + --[[ + if buildable_to_1 then + if can_place(pos) then + Place + end + else if buildable_to_2 then + if can_place2() then + Place + end + end + ]] + --[[ + if result then -- Fail placement of liquid if result is false local pns = user:get_player_name() if minetest.is_protected(place_pos, pns) then minetest.record_protection_violation(place_pos, pns) @@ -200,28 +301,17 @@ function mcl_buckets.register_liquid(def) end else return - end + end]] end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) local iname = stack:get_name() local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" if not buildable then return stack end - - local result - if def.extra_check then - result = def.extra_check(droppos, nil) - if result == nil then result = true end - else - result = true - end + local result, take_bucket = get_extra_check(def.extra_check, droppos, nil) if result then -- Fail placement of liquid if result is false - local node_place - if type(def.source_place) == "function" then - node_place = def.source_place(droppos) - else - node_place = def.source_place - end - place_liquid(droppos, node_place) + place_liquid(droppos, get_node_place(def.source_place, droppos)) + end + if take_bucket then stack:set_name("mcl_buckets:bucket_empty") end return stack diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 12790598c5..97349533e3 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -53,15 +53,6 @@ if mod_mcl_core then usagehelp = S("Place it to empty the bucket and create a water source."), tt_help = S("Places a water source"), extra_check = function(pos, placer) - -- Check protection - local placer_name = "" - if placer then - placer_name = placer:get_player_name() - end - if placer and minetest.is_protected(pos, placer_name) then - minetest.record_protection_violation(pos, placer_name) - return false - end local nn = minetest.get_node(pos).name -- Pour water into cauldron if minetest.get_item_group(nn, "cauldron") ~= 0 then @@ -70,13 +61,13 @@ if mod_mcl_core then minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3"}) end sound_place("mcl_core:water_source", pos) - return false + return false, true -- Evaporate water if used in Nether (except on cauldron) else local dim = mcl_worlds.pos_to_dimension(pos) if dim == "nether" then minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) - return false + return false, true end end end, @@ -96,15 +87,6 @@ if mod_mclx_core then usagehelp = S("Place it to empty the bucket and create a river water source."), tt_help = S("Places a river water source"), extra_check = function(pos, placer) - -- Check protection - local placer_name = "" - if placer then - placer_name = placer:get_player_name() - end - if placer and minetest.is_protected(pos, placer_name) then - minetest.record_protection_violation(pos, placer_name) - return false - end local nn = minetest.get_node(pos).name -- Pour into cauldron if minetest.get_item_group(nn, "cauldron") ~= 0 then @@ -113,13 +95,13 @@ if mod_mclx_core then minetest.set_node(pos, {name="mcl_cauldrons:cauldron_3r"}) end sound_place("mcl_core:water_source", pos) - return false + return false, true else -- Evaporate water if used in Nether (except on cauldron) local dim = mcl_worlds.pos_to_dimension(pos) if dim == "nether" then minetest.sound_play("fire_extinguish_flame", {pos = pos, gain = 0.25, max_hear_distance = 16}, true) - return false + return false, true end end end, From cd08df175c767fe502065d5327d37ec633c7af2e Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 11:41:09 +0200 Subject: [PATCH 19/74] add better documentation --- mods/ITEMS/mcl_buckets/API.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_buckets/API.md b/mods/ITEMS/mcl_buckets/API.md index 4595d8e72a..abbdb0a074 100644 --- a/mods/ITEMS/mcl_buckets/API.md +++ b/mods/ITEMS/mcl_buckets/API.md @@ -23,7 +23,14 @@ Accept folowing params: ```lua mcl_buckets.register_liquid({ itemname = "dummy:bucket_dummy", - source_place = "dummy:dummy_source", + --source_place = "dummy:dummy_source", + source_place = function(pos) + if condition then + return "dummy:dummy_source" + else + return "dummy:dummy_source_nether" + end + end, source_take = {"dummy:dummy_source"}, inventory_image = "bucket_dummy.png", name = S("Dummy liquid Bucket"), From 88e59d3592b7f56044273296bce96e299cf2de17 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 11:52:27 +0200 Subject: [PATCH 20/74] more mt like API (improved readability) --- mods/ITEMS/mcl_buckets/API.md | 14 +-- mods/ITEMS/mcl_buckets/init.lua | 150 +--------------------------- mods/ITEMS/mcl_buckets/register.lua | 9 +- 3 files changed, 14 insertions(+), 159 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/API.md b/mods/ITEMS/mcl_buckets/API.md index abbdb0a074..93af64acf4 100644 --- a/mods/ITEMS/mcl_buckets/API.md +++ b/mods/ITEMS/mcl_buckets/API.md @@ -1,15 +1,18 @@ # mcl_buckets Add an API to register buckets to mcl -## mcl_buckets.register_liquid(def) +## mcl_buckets.register_liquid(itemname, def) + +Register a new bucket of liquid. + +`itemname` is the itemstring of the new bucket item + +`def` is a table containing the folowing fields: -Register a new liquid -Accept folowing params: * source_place: a string or function. * string: name of the node to place * function(pos): will returns name of the node to place with pos being the placement position * source_take: table of liquid source node names to take -* itemname: itemstring of the new bucket item (or nil if liquid is not takeable) * inventory_image: texture of the new bucket item (ignored if itemname == nil) * name: user-visible bucket description * longdesc: long explanatory description (for help) @@ -21,8 +24,7 @@ Accept folowing params: **Usage exemple:** ```lua -mcl_buckets.register_liquid({ - itemname = "dummy:bucket_dummy", +mcl_buckets.register_liquid("dummy:bucket_dummy", { --source_place = "dummy:dummy_source", source_place = function(pos) if condition then diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 9ae712cedb..11fede8167 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -147,13 +147,13 @@ local function get_bucket_drop(itemstack, user, take_bucket) end end -function mcl_buckets.register_liquid(def) +function mcl_buckets.register_liquid(itemname, def) for _,source in ipairs(def.source_take) do mcl_buckets.liquids[source] = { source_place = def.source_place, source_take = source, on_take = def.on_take, - itemname = def.itemname, + itemname = itemname, } pointable_sources[source] = true if type(def.source_place) == "string" then @@ -161,11 +161,7 @@ function mcl_buckets.register_liquid(def) end end - if def.itemname == nil or def.itemname == "" then - error(string.format("[mcl_bucket] Invalid itemname then registering [%s]!", def.name)) - end - - minetest.register_craftitem(def.itemname, { + minetest.register_craftitem(itemname, { description = def.name, _doc_items_longdesc = def.longdesc, _doc_items_usagehelp = def.usagehelp, @@ -236,72 +232,6 @@ function mcl_buckets.register_liquid(def) else return itemstack end - - -- Check if pointing to a buildable node - --local item = itemstack:get_name() - - --[[ - if buildable_to_1 then - if can_place(pos) then - Place - end - else if buildable_to_2 then - if can_place2() then - Place - end - end - ]] - --[[ - if result then -- Fail placement of liquid if result is false - local pns = user:get_player_name() - if minetest.is_protected(place_pos, pns) then - minetest.record_protection_violation(place_pos, pns) - return itemstack - end - place_liquid(place_pos, node_place) - if mod_doc and doc.entry_exists("nodes", node_place) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) - end - else - -- not buildable to; place the liquid above - -- check if the node above can be replaced - local abovenode = minetest.get_node(pointed_thing.above) - if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then - local pn = user:get_player_name() - if minetest.is_protected(pointed_thing.above, pn) then - minetest.record_protection_violation(pointed_thing.above, pn) - return itemstack - end - place_liquid(pointed_thing.above, node_place) - if mod_doc and doc.entry_exists("nodes", node_place) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) - end - else - -- do not remove the bucket with the liquid - return - end - end - - -- Handle bucket item and inventory stuff - if not minetest.is_creative_enabled(user:get_player_name()) then - -- Add empty bucket and put it into inventory, if possible. - -- Drop empty bucket otherwise. - local new_bucket = ItemStack("mcl_buckets:bucket_empty") - if itemstack:get_count() == 1 then - return new_bucket - else - local inv = user:get_inventory() - if inv:room_for_item("main", new_bucket) then - inv:add_item("main", new_bucket) - else - minetest.add_item(user:get_pos(), new_bucket) - end - itemstack:take_item() - return itemstack - end - else - return - end]] end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) local iname = stack:get_name() @@ -328,80 +258,6 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { inventory_image = "bucket.png", stack_max = 16, on_place = function(itemstack, user, pointed_thing) - --[[-- Must be pointing to node - if pointed_thing.type ~= "node" then - return itemstack - end - - -- Call on_rightclick if the pointed node defines it - - - local pointed_liquid = bucket_raycast(user) - - -- Can't steal liquids - if minetest.is_protected(pointed_liquid.above, user:get_player_name()) then - minetest.record_protection_violation(pointed_liquid.under, user:get_player_name()) - return itemstack - end - if minetest.is_protected(pointed_thing.above, user:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) - return itemstack - end - - -- Check if pointing to a liquid source - local liquiddef = mcl_buckets.liquids[nn] - local new_bucket - if liquiddef and liquiddef.itemname and (nn == liquiddef.source_take) then - - -- Fill bucket, but not in Creative Mode - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack({name = liquiddef.itemname}) - if liquiddef.on_take then - liquiddef.on_take(user) - end - end - - minetest.add_node(pointed_thing.under, {name="air"}) - sound_take(nn, pointed_thing.under) - - if mod_doc and doc.entry_exists("nodes", nn) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", nn) - end - - elseif nn == "mcl_cauldrons:cauldron_3" then - -- Take water out of full cauldron - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack("mcl_buckets:bucket_water") - end - sound_take("mcl_core:water_source", pointed_thing.under) - elseif nn == "mcl_cauldrons:cauldron_3r" then - -- Take river water out of full cauldron - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack("mcl_buckets:bucket_river_water") - end - sound_take("mclx_core:river_water_source", pointed_thing.under) - end - - -- Add liquid bucket and put it into inventory, if possible. - -- Drop new bucket otherwise. - if new_bucket then - if itemstack:get_count() == 1 then - return new_bucket - else - local inv = user:get_inventory() - if inv:room_for_item("main", new_bucket) then - inv:add_item("main", new_bucket) - else - minetest.add_item(user:get_pos(), new_bucket) - end - if not minetest.is_creative_enabled(user:get_player_name()) then - itemstack:take_item() - end - return itemstack - end - end]] -- Must be pointing to node if pointed_thing.type ~= "node" then return itemstack diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 97349533e3..46abce1d0c 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -19,7 +19,7 @@ end]] if mod_mcl_core then -- Lava bucket - mcl_buckets.register_liquid({ + mcl_buckets.register_liquid("mcl_buckets:bucket_lava", { source_place = function(pos) local dim = mcl_worlds.pos_to_dimension(pos) if dim == "nether" then @@ -34,7 +34,6 @@ if mod_mcl_core then awards.unlock(user:get_player_name(), "mcl:hotStuff") end end, - itemname = "mcl_buckets:bucket_lava", inventory_image = "bucket_lava.png", name = S("Lava Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with hot lava, safely contained inside. Use with caution."), @@ -43,10 +42,9 @@ if mod_mcl_core then }) -- Water bucket - mcl_buckets.register_liquid({ + mcl_buckets.register_liquid("mcl_buckets:bucket_water", { source_place = "mcl_core:water_source", source_take = {"mcl_core:water_source"}, - itemname = "mcl_buckets:bucket_water", inventory_image = "bucket_water.png", name = S("Water Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with water."), @@ -77,10 +75,9 @@ end if mod_mclx_core then -- River water bucket - mcl_buckets.register_liquid({ + mcl_buckets.register_liquid("mcl_buckets:bucket_river_water", { source_place = "mclx_core:river_water_source", source_take = {"mclx_core:river_water_source"}, - itemname = "mcl_buckets:bucket_river_water", inventory_image = "bucket_river_water.png", name = S("River Water Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with river water."), From cf5703d528426bbbb810c327ecfe59b0c9867cf0 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 11:53:37 +0200 Subject: [PATCH 21/74] fix luacheck warnings --- mods/ITEMS/mcl_buckets/init.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 11fede8167..a496fb2ff8 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -182,11 +182,10 @@ function mcl_buckets.register_liquid(itemname, def) local undernode = get_node(pointed_thing.under) local abovenode = get_node(pointed_thing.above) - local nn = undernode.name local buildable1 = minetest.registered_nodes[undernode.name] and minetest.registered_nodes[undernode.name].buildable_to local buildable2 = minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to if not buildable1 and not buildable2 then return itemstack end --if both nodes aren't buildable_to, skip - + if buildable1 then local result, take_bucket = get_extra_check(def.extra_check, pointed_thing.under, user) if result then @@ -234,7 +233,6 @@ function mcl_buckets.register_liquid(itemname, def) end end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) - local iname = stack:get_name() local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" if not buildable then return stack end local result, take_bucket = get_extra_check(def.extra_check, droppos, nil) From 6d7aafe0d462bccdb8a7a32f78a27898fb1705d7 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 15:13:40 +0200 Subject: [PATCH 22/74] Revert "more mt like API (improved readability)" This reverts commit 88e59d3592b7f56044273296bce96e299cf2de17. --- mods/ITEMS/mcl_buckets/API.md | 14 ++- mods/ITEMS/mcl_buckets/init.lua | 150 +++++++++++++++++++++++++++- mods/ITEMS/mcl_buckets/register.lua | 9 +- 3 files changed, 159 insertions(+), 14 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/API.md b/mods/ITEMS/mcl_buckets/API.md index 93af64acf4..abbdb0a074 100644 --- a/mods/ITEMS/mcl_buckets/API.md +++ b/mods/ITEMS/mcl_buckets/API.md @@ -1,18 +1,15 @@ # mcl_buckets Add an API to register buckets to mcl -## mcl_buckets.register_liquid(itemname, def) - -Register a new bucket of liquid. - -`itemname` is the itemstring of the new bucket item - -`def` is a table containing the folowing fields: +## mcl_buckets.register_liquid(def) +Register a new liquid +Accept folowing params: * source_place: a string or function. * string: name of the node to place * function(pos): will returns name of the node to place with pos being the placement position * source_take: table of liquid source node names to take +* itemname: itemstring of the new bucket item (or nil if liquid is not takeable) * inventory_image: texture of the new bucket item (ignored if itemname == nil) * name: user-visible bucket description * longdesc: long explanatory description (for help) @@ -24,7 +21,8 @@ Register a new bucket of liquid. **Usage exemple:** ```lua -mcl_buckets.register_liquid("dummy:bucket_dummy", { +mcl_buckets.register_liquid({ + itemname = "dummy:bucket_dummy", --source_place = "dummy:dummy_source", source_place = function(pos) if condition then diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index a496fb2ff8..b75c106963 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -147,13 +147,13 @@ local function get_bucket_drop(itemstack, user, take_bucket) end end -function mcl_buckets.register_liquid(itemname, def) +function mcl_buckets.register_liquid(def) for _,source in ipairs(def.source_take) do mcl_buckets.liquids[source] = { source_place = def.source_place, source_take = source, on_take = def.on_take, - itemname = itemname, + itemname = def.itemname, } pointable_sources[source] = true if type(def.source_place) == "string" then @@ -161,7 +161,11 @@ function mcl_buckets.register_liquid(itemname, def) end end - minetest.register_craftitem(itemname, { + if def.itemname == nil or def.itemname == "" then + error(string.format("[mcl_bucket] Invalid itemname then registering [%s]!", def.name)) + end + + minetest.register_craftitem(def.itemname, { description = def.name, _doc_items_longdesc = def.longdesc, _doc_items_usagehelp = def.usagehelp, @@ -231,6 +235,72 @@ function mcl_buckets.register_liquid(itemname, def) else return itemstack end + + -- Check if pointing to a buildable node + --local item = itemstack:get_name() + + --[[ + if buildable_to_1 then + if can_place(pos) then + Place + end + else if buildable_to_2 then + if can_place2() then + Place + end + end + ]] + --[[ + if result then -- Fail placement of liquid if result is false + local pns = user:get_player_name() + if minetest.is_protected(place_pos, pns) then + minetest.record_protection_violation(place_pos, pns) + return itemstack + end + place_liquid(place_pos, node_place) + if mod_doc and doc.entry_exists("nodes", node_place) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) + end + else + -- not buildable to; place the liquid above + -- check if the node above can be replaced + local abovenode = minetest.get_node(pointed_thing.above) + if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then + local pn = user:get_player_name() + if minetest.is_protected(pointed_thing.above, pn) then + minetest.record_protection_violation(pointed_thing.above, pn) + return itemstack + end + place_liquid(pointed_thing.above, node_place) + if mod_doc and doc.entry_exists("nodes", node_place) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) + end + else + -- do not remove the bucket with the liquid + return + end + end + + -- Handle bucket item and inventory stuff + if not minetest.is_creative_enabled(user:get_player_name()) then + -- Add empty bucket and put it into inventory, if possible. + -- Drop empty bucket otherwise. + local new_bucket = ItemStack("mcl_buckets:bucket_empty") + if itemstack:get_count() == 1 then + return new_bucket + else + local inv = user:get_inventory() + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) + else + minetest.add_item(user:get_pos(), new_bucket) + end + itemstack:take_item() + return itemstack + end + else + return + end]] end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" @@ -256,6 +326,80 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { inventory_image = "bucket.png", stack_max = 16, on_place = function(itemstack, user, pointed_thing) + --[[-- Must be pointing to node + if pointed_thing.type ~= "node" then + return itemstack + end + + -- Call on_rightclick if the pointed node defines it + + + local pointed_liquid = bucket_raycast(user) + + -- Can't steal liquids + if minetest.is_protected(pointed_liquid.above, user:get_player_name()) then + minetest.record_protection_violation(pointed_liquid.under, user:get_player_name()) + return itemstack + end + if minetest.is_protected(pointed_thing.above, user:get_player_name()) then + minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) + return itemstack + end + + -- Check if pointing to a liquid source + local liquiddef = mcl_buckets.liquids[nn] + local new_bucket + if liquiddef and liquiddef.itemname and (nn == liquiddef.source_take) then + + -- Fill bucket, but not in Creative Mode + if not minetest.is_creative_enabled(user:get_player_name()) then + new_bucket = ItemStack({name = liquiddef.itemname}) + if liquiddef.on_take then + liquiddef.on_take(user) + end + end + + minetest.add_node(pointed_thing.under, {name="air"}) + sound_take(nn, pointed_thing.under) + + if mod_doc and doc.entry_exists("nodes", nn) then + doc.mark_entry_as_revealed(user:get_player_name(), "nodes", nn) + end + + elseif nn == "mcl_cauldrons:cauldron_3" then + -- Take water out of full cauldron + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + if not minetest.is_creative_enabled(user:get_player_name()) then + new_bucket = ItemStack("mcl_buckets:bucket_water") + end + sound_take("mcl_core:water_source", pointed_thing.under) + elseif nn == "mcl_cauldrons:cauldron_3r" then + -- Take river water out of full cauldron + minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) + if not minetest.is_creative_enabled(user:get_player_name()) then + new_bucket = ItemStack("mcl_buckets:bucket_river_water") + end + sound_take("mclx_core:river_water_source", pointed_thing.under) + end + + -- Add liquid bucket and put it into inventory, if possible. + -- Drop new bucket otherwise. + if new_bucket then + if itemstack:get_count() == 1 then + return new_bucket + else + local inv = user:get_inventory() + if inv:room_for_item("main", new_bucket) then + inv:add_item("main", new_bucket) + else + minetest.add_item(user:get_pos(), new_bucket) + end + if not minetest.is_creative_enabled(user:get_player_name()) then + itemstack:take_item() + end + return itemstack + end + end]] -- Must be pointing to node if pointed_thing.type ~= "node" then return itemstack diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 46abce1d0c..97349533e3 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -19,7 +19,7 @@ end]] if mod_mcl_core then -- Lava bucket - mcl_buckets.register_liquid("mcl_buckets:bucket_lava", { + mcl_buckets.register_liquid({ source_place = function(pos) local dim = mcl_worlds.pos_to_dimension(pos) if dim == "nether" then @@ -34,6 +34,7 @@ if mod_mcl_core then awards.unlock(user:get_player_name(), "mcl:hotStuff") end end, + itemname = "mcl_buckets:bucket_lava", inventory_image = "bucket_lava.png", name = S("Lava Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with hot lava, safely contained inside. Use with caution."), @@ -42,9 +43,10 @@ if mod_mcl_core then }) -- Water bucket - mcl_buckets.register_liquid("mcl_buckets:bucket_water", { + mcl_buckets.register_liquid({ source_place = "mcl_core:water_source", source_take = {"mcl_core:water_source"}, + itemname = "mcl_buckets:bucket_water", inventory_image = "bucket_water.png", name = S("Water Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with water."), @@ -75,9 +77,10 @@ end if mod_mclx_core then -- River water bucket - mcl_buckets.register_liquid("mcl_buckets:bucket_river_water", { + mcl_buckets.register_liquid({ source_place = "mclx_core:river_water_source", source_take = {"mclx_core:river_water_source"}, + itemname = "mcl_buckets:bucket_river_water", inventory_image = "bucket_river_water.png", name = S("River Water Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with river water."), From ec6086d8e631fc19bd9dfca43eb5109f3125d0e4 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 15:14:23 +0200 Subject: [PATCH 23/74] cleanup --- mods/ITEMS/mcl_buckets/init.lua | 140 -------------------------------- 1 file changed, 140 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index b75c106963..312669c5ef 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -235,72 +235,6 @@ function mcl_buckets.register_liquid(def) else return itemstack end - - -- Check if pointing to a buildable node - --local item = itemstack:get_name() - - --[[ - if buildable_to_1 then - if can_place(pos) then - Place - end - else if buildable_to_2 then - if can_place2() then - Place - end - end - ]] - --[[ - if result then -- Fail placement of liquid if result is false - local pns = user:get_player_name() - if minetest.is_protected(place_pos, pns) then - minetest.record_protection_violation(place_pos, pns) - return itemstack - end - place_liquid(place_pos, node_place) - if mod_doc and doc.entry_exists("nodes", node_place) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) - end - else - -- not buildable to; place the liquid above - -- check if the node above can be replaced - local abovenode = minetest.get_node(pointed_thing.above) - if minetest.registered_nodes[abovenode.name] and minetest.registered_nodes[abovenode.name].buildable_to then - local pn = user:get_player_name() - if minetest.is_protected(pointed_thing.above, pn) then - minetest.record_protection_violation(pointed_thing.above, pn) - return itemstack - end - place_liquid(pointed_thing.above, node_place) - if mod_doc and doc.entry_exists("nodes", node_place) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", node_place) - end - else - -- do not remove the bucket with the liquid - return - end - end - - -- Handle bucket item and inventory stuff - if not minetest.is_creative_enabled(user:get_player_name()) then - -- Add empty bucket and put it into inventory, if possible. - -- Drop empty bucket otherwise. - local new_bucket = ItemStack("mcl_buckets:bucket_empty") - if itemstack:get_count() == 1 then - return new_bucket - else - local inv = user:get_inventory() - if inv:room_for_item("main", new_bucket) then - inv:add_item("main", new_bucket) - else - minetest.add_item(user:get_pos(), new_bucket) - end - itemstack:take_item() - return itemstack - end - else - return - end]] end, _on_dispense = function(stack, pos, droppos, dropnode, dropdir) local buildable = minetest.registered_nodes[dropnode.name].buildable_to or dropnode.name == "mcl_portals:portal" @@ -326,80 +260,6 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { inventory_image = "bucket.png", stack_max = 16, on_place = function(itemstack, user, pointed_thing) - --[[-- Must be pointing to node - if pointed_thing.type ~= "node" then - return itemstack - end - - -- Call on_rightclick if the pointed node defines it - - - local pointed_liquid = bucket_raycast(user) - - -- Can't steal liquids - if minetest.is_protected(pointed_liquid.above, user:get_player_name()) then - minetest.record_protection_violation(pointed_liquid.under, user:get_player_name()) - return itemstack - end - if minetest.is_protected(pointed_thing.above, user:get_player_name()) then - minetest.record_protection_violation(pointed_thing.under, user:get_player_name()) - return itemstack - end - - -- Check if pointing to a liquid source - local liquiddef = mcl_buckets.liquids[nn] - local new_bucket - if liquiddef and liquiddef.itemname and (nn == liquiddef.source_take) then - - -- Fill bucket, but not in Creative Mode - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack({name = liquiddef.itemname}) - if liquiddef.on_take then - liquiddef.on_take(user) - end - end - - minetest.add_node(pointed_thing.under, {name="air"}) - sound_take(nn, pointed_thing.under) - - if mod_doc and doc.entry_exists("nodes", nn) then - doc.mark_entry_as_revealed(user:get_player_name(), "nodes", nn) - end - - elseif nn == "mcl_cauldrons:cauldron_3" then - -- Take water out of full cauldron - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack("mcl_buckets:bucket_water") - end - sound_take("mcl_core:water_source", pointed_thing.under) - elseif nn == "mcl_cauldrons:cauldron_3r" then - -- Take river water out of full cauldron - minetest.set_node(pointed_thing.under, {name="mcl_cauldrons:cauldron"}) - if not minetest.is_creative_enabled(user:get_player_name()) then - new_bucket = ItemStack("mcl_buckets:bucket_river_water") - end - sound_take("mclx_core:river_water_source", pointed_thing.under) - end - - -- Add liquid bucket and put it into inventory, if possible. - -- Drop new bucket otherwise. - if new_bucket then - if itemstack:get_count() == 1 then - return new_bucket - else - local inv = user:get_inventory() - if inv:room_for_item("main", new_bucket) then - inv:add_item("main", new_bucket) - else - minetest.add_item(user:get_pos(), new_bucket) - end - if not minetest.is_creative_enabled(user:get_player_name()) then - itemstack:take_item() - end - return itemstack - end - end]] -- Must be pointing to node if pointed_thing.type ~= "node" then return itemstack From 8fff20eec9f1045c9d16d2a4cdb79c989d627966 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 15:18:12 +0200 Subject: [PATCH 24/74] fix misleading API --- mods/ITEMS/mcl_buckets/init.lua | 12 ++++++------ mods/ITEMS/mcl_buckets/register.lua | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 312669c5ef..17d3334852 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -153,7 +153,7 @@ function mcl_buckets.register_liquid(def) source_place = def.source_place, source_take = source, on_take = def.on_take, - itemname = def.itemname, + bucketname = def.bucketname, } pointable_sources[source] = true if type(def.source_place) == "string" then @@ -161,11 +161,11 @@ function mcl_buckets.register_liquid(def) end end - if def.itemname == nil or def.itemname == "" then + if def.bucketname == nil or def.bucketname == "" then error(string.format("[mcl_bucket] Invalid itemname then registering [%s]!", def.name)) end - minetest.register_craftitem(def.itemname, { + minetest.register_craftitem(def.bucketname, { description = def.name, _doc_items_longdesc = def.longdesc, _doc_items_usagehelp = def.usagehelp, @@ -289,7 +289,7 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { -- FIXME: remove this line --if not minetest.is_creative_enabled(user:get_player_name()) then if not false then - new_bucket = ItemStack({name = liquid_def.itemname}) + new_bucket = ItemStack({name = liquid_def.bucketname}) if liquid_def.on_take then liquid_def.on_take(user) end @@ -337,9 +337,9 @@ minetest.register_craftitem("mcl_buckets:bucket_empty", { local liquiddef = mcl_buckets.liquids[dropnode.name] local new_bucket - if liquiddef and liquiddef.itemname and (dropnode.name == liquiddef.source_take) then + if liquiddef and liquiddef.bucketname and (dropnode.name == liquiddef.source_take) then -- Fill bucket - new_bucket = ItemStack({name = liquiddef.itemname}) + new_bucket = ItemStack({name = liquiddef.bucketname}) sound_take(dropnode.name, droppos) collect_liquid = true end diff --git a/mods/ITEMS/mcl_buckets/register.lua b/mods/ITEMS/mcl_buckets/register.lua index 97349533e3..1a7c8fe141 100644 --- a/mods/ITEMS/mcl_buckets/register.lua +++ b/mods/ITEMS/mcl_buckets/register.lua @@ -34,7 +34,7 @@ if mod_mcl_core then awards.unlock(user:get_player_name(), "mcl:hotStuff") end end, - itemname = "mcl_buckets:bucket_lava", + bucketname = "mcl_buckets:bucket_lava", inventory_image = "bucket_lava.png", name = S("Lava Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with hot lava, safely contained inside. Use with caution."), @@ -46,7 +46,7 @@ if mod_mcl_core then mcl_buckets.register_liquid({ source_place = "mcl_core:water_source", source_take = {"mcl_core:water_source"}, - itemname = "mcl_buckets:bucket_water", + bucketname = "mcl_buckets:bucket_water", inventory_image = "bucket_water.png", name = S("Water Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with water."), @@ -80,7 +80,7 @@ if mod_mclx_core then mcl_buckets.register_liquid({ source_place = "mclx_core:river_water_source", source_take = {"mclx_core:river_water_source"}, - itemname = "mcl_buckets:bucket_river_water", + bucketname = "mcl_buckets:bucket_river_water", inventory_image = "bucket_river_water.png", name = S("River Water Bucket"), longdesc = S("A bucket can be used to collect and release liquids. This one is filled with river water."), From 873a1e73dc58bf38ca4738feb86f4f4ab8c5d2ba Mon Sep 17 00:00:00 2001 From: AFCMS Date: Wed, 14 Jul 2021 15:22:27 +0200 Subject: [PATCH 25/74] fix documentation --- mods/ITEMS/mcl_buckets/API.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_buckets/API.md b/mods/ITEMS/mcl_buckets/API.md index abbdb0a074..94ec48de54 100644 --- a/mods/ITEMS/mcl_buckets/API.md +++ b/mods/ITEMS/mcl_buckets/API.md @@ -9,7 +9,7 @@ Accept folowing params: * string: name of the node to place * function(pos): will returns name of the node to place with pos being the placement position * source_take: table of liquid source node names to take -* itemname: itemstring of the new bucket item (or nil if liquid is not takeable) +* bucketname: itemstring of the new bucket item * inventory_image: texture of the new bucket item (ignored if itemname == nil) * name: user-visible bucket description * longdesc: long explanatory description (for help) @@ -22,7 +22,7 @@ Accept folowing params: **Usage exemple:** ```lua mcl_buckets.register_liquid({ - itemname = "dummy:bucket_dummy", + bucketname = "dummy:bucket_dummy", --source_place = "dummy:dummy_source", source_place = function(pos) if condition then From dc17cc91a3ea225936869d1f01b1bed498efd0e8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Jul 2021 00:01:56 +0200 Subject: [PATCH 26/74] make raycast start from player head --- mods/ITEMS/mcl_buckets/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index 17d3334852..f1d131ea2f 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -81,7 +81,7 @@ local pointable_sources = {} local function bucket_raycast(user) --local pos = user:get_pos() - local pos = mcl_util.get_object_center(user) + local pos = user:get_pos() --local pos = vector.add(user:get_pos(), user:get_bone_position("Head_Control")) pos.y = pos.y + user:get_properties().eye_height local look_dir = user:get_look_dir() From 49bde37a5e80a91f7ad0f03ef371aa32cf7972b8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 15 Jul 2021 01:03:50 +0200 Subject: [PATCH 27/74] rewrite README to markdown --- mods/ITEMS/mcl_buckets/{README.txt => README.md} | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) rename mods/ITEMS/mcl_buckets/{README.txt => README.md} (67%) diff --git a/mods/ITEMS/mcl_buckets/README.txt b/mods/ITEMS/mcl_buckets/README.md similarity index 67% rename from mods/ITEMS/mcl_buckets/README.txt rename to mods/ITEMS/mcl_buckets/README.md index 06862d5894..b783cc1337 100644 --- a/mods/ITEMS/mcl_buckets/README.txt +++ b/mods/ITEMS/mcl_buckets/README.md @@ -1,9 +1,12 @@ -Bucket mod. -Originally taken from Minetest Game, adapted for MineClone 2. +# MineClone2 Bucket (`mcl_bucket`) +Originally taken from Minetest Game, adapted for MineClone2. + +This mod add buckets to the game, including an API to register your own (see `API.md`). + +## License -License of source code: ------------------------ Copyright (C) 2011-2012 Kahrl + Copyright (C) 2011-2012 celeron55, Perttu Ahola This program is free software; you can redistribute it and/or modify From 9d9e21301271da166248a2356b81e0225d738fde Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Sat, 10 Jul 2021 10:54:59 +0200 Subject: [PATCH 28/74] Fix some implicit hard and soft-dependencies These issues were found while testing minetest#8603 and are caused by relying on the undefined mod loading order --- mods/ITEMS/mcl_armor/mod.conf | 2 +- mods/ITEMS/mcl_brewing/mod.conf | 2 +- mods/PLAYER/mcl_playerplus/mod.conf | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_armor/mod.conf b/mods/ITEMS/mcl_armor/mod.conf index 9264e8362f..fad2e494c5 100644 --- a/mods/ITEMS/mcl_armor/mod.conf +++ b/mods/ITEMS/mcl_armor/mod.conf @@ -1,5 +1,5 @@ name = mcl_armor author = stu description = Adds craftable armor that is visible to other players. -depends = mcl_core, mcl_player, mcl_enchanting +depends = mcl_core, mcl_player, mcl_enchanting, mcl_damage optional_depends = mcl_fire, ethereal, bakedclay diff --git a/mods/ITEMS/mcl_brewing/mod.conf b/mods/ITEMS/mcl_brewing/mod.conf index 2c27c979e7..0f6217f098 100644 --- a/mods/ITEMS/mcl_brewing/mod.conf +++ b/mods/ITEMS/mcl_brewing/mod.conf @@ -1,4 +1,4 @@ name = mcl_brewing author = bzoss depends = mcl_init, mcl_formspec, mcl_sounds, mcl_potions, mcl_mobitems -optional_depends = mcl_core, doc, screwdriver +optional_depends = mcl_core, doc, screwdriver, mesecons_mvps diff --git a/mods/PLAYER/mcl_playerplus/mod.conf b/mods/PLAYER/mcl_playerplus/mod.conf index 6989957d77..b77c9e2e5e 100644 --- a/mods/PLAYER/mcl_playerplus/mod.conf +++ b/mods/PLAYER/mcl_playerplus/mod.conf @@ -1,5 +1,5 @@ name = mcl_playerplus author = TenPlus1 description = Adds some simple player-related gameplay effects: Hurt by touching a cactus, suffocation and more. -depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage +depends = mcl_init, mcl_core, mcl_particles, mcl_hunger, playerphysics, mcl_playerinfo, mcl_weather, mcl_spawn, mcl_enchanting, mcl_damage, mcl_sprint From b364faa7c7d76370953f798e207837f4e6b7cfab Mon Sep 17 00:00:00 2001 From: AFCMS Date: Sat, 17 Jul 2021 16:22:46 +0200 Subject: [PATCH 29/74] make bucket use 5 lenght raycast --- mods/ITEMS/mcl_buckets/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_buckets/init.lua b/mods/ITEMS/mcl_buckets/init.lua index f1d131ea2f..931214b95c 100644 --- a/mods/ITEMS/mcl_buckets/init.lua +++ b/mods/ITEMS/mcl_buckets/init.lua @@ -85,7 +85,7 @@ local function bucket_raycast(user) --local pos = vector.add(user:get_pos(), user:get_bone_position("Head_Control")) pos.y = pos.y + user:get_properties().eye_height local look_dir = user:get_look_dir() - look_dir = vector.multiply(look_dir, 4) + look_dir = vector.multiply(look_dir, 5) local pos2 = vector.add(pos, look_dir) local ray = raycast(pos, pos2, false, true) From 48166625d4ddba283d0ca5dca9c548dfb0595337 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Jul 2021 17:21:53 +0000 Subject: [PATCH 30/74] Add mcl_item_id mod --- mods/HELP/mcl_item_id/init.lua | 35 ++++++++++++++++++++++++++++++++++ mods/HELP/mcl_item_id/mod.conf | 3 +++ 2 files changed, 38 insertions(+) create mode 100644 mods/HELP/mcl_item_id/init.lua create mode 100644 mods/HELP/mcl_item_id/mod.conf diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua new file mode 100644 index 0000000000..1d165d8c64 --- /dev/null +++ b/mods/HELP/mcl_item_id/init.lua @@ -0,0 +1,35 @@ +local game = "mineclone2" + +local same_id = { + heads = { "skeleton", "zombie", "creeper", "wither_skeleton" }, + mobitems = { "rabbit", "chicken" }, + walls = { + "andesite", "brick", "cobble", "diorite", "endbricks", + "granite", "mossycobble", "netherbrick", "prismarine", + "rednetherbrick", "redsandstone", "sandstone", + "stonebrick", "stonebrickmossy", + }, + wool = { + "black", "blue", "brown", "cyan", "green", + "grey", "light_blue", "lime", "magenta", "orange", + "pink", "purple", "red", "silver", "white", "yellow", + }, +} + +tt.register_snippet(function(itemstring) + local def = minetest.registered_items[itemstring] + local desc = def.description + local item_split = itemstring:find(":") + local new_id = game .. itemstring:sub(item_split) + for mod, ids in pairs(same_id) do + for _, id in pairs(ids) do + if itemstring == "mcl_" .. mod .. ":" .. id then + new_id = game .. ":" .. id .. "_" .. mod:gsub("s", "") + end + end + end + minetest.register_alias(new_id, itemstring) + if minetest.settings:get_bool("mcl_item_id_debug", true) then + return new_id, "#555555" + end +end) diff --git a/mods/HELP/mcl_item_id/mod.conf b/mods/HELP/mcl_item_id/mod.conf new file mode 100644 index 0000000000..c45e17fd31 --- /dev/null +++ b/mods/HELP/mcl_item_id/mod.conf @@ -0,0 +1,3 @@ +name = mcl_item_id +author = NO11 +depends = tt \ No newline at end of file From f2a4d6bd561a6499ea24875c23046340b8b572e0 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Jul 2021 17:23:12 +0000 Subject: [PATCH 31/74] Add item id setting --- settingtypes.txt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/settingtypes.txt b/settingtypes.txt index ea1c1a50a3..f605019ad1 100644 --- a/settingtypes.txt +++ b/settingtypes.txt @@ -153,3 +153,7 @@ fix_doubleplants (Mcimport double plant fixes) bool true # Allow players to create Minecraft-like maps. enable_real_maps (Enable Real Maps) bool true + +[Debugging] +# If enabled, this will show the itemstring of an item in the description. +mcl_item_id_debug (Item ID Debug) bool false \ No newline at end of file From 801d9a25715ee5ac1f7a99fc24b0b78fd4b60814 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 18 Jul 2021 18:01:55 +0000 Subject: [PATCH 32/74] Remove some spaces --- mods/HELP/mcl_item_id/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index 1d165d8c64..e715ac9e9b 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -17,7 +17,7 @@ local same_id = { } tt.register_snippet(function(itemstring) - local def = minetest.registered_items[itemstring] + local def = minetest.registered_items[itemstring] local desc = def.description local item_split = itemstring:find(":") local new_id = game .. itemstring:sub(item_split) From 96e8e6a86f00835d2e7d5dc36974ec5cfcf2a919 Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 19 Jul 2021 12:21:30 +0000 Subject: [PATCH 33/74] Use mineclone: instead of mineclone2: for item IDs --- mods/HELP/mcl_item_id/init.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index e715ac9e9b..e7772d1416 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -1,4 +1,4 @@ -local game = "mineclone2" +local game = "mineclone" local same_id = { heads = { "skeleton", "zombie", "creeper", "wither_skeleton" }, @@ -30,6 +30,6 @@ tt.register_snippet(function(itemstring) end minetest.register_alias(new_id, itemstring) if minetest.settings:get_bool("mcl_item_id_debug", true) then - return new_id, "#555555" - end + return new_id, "#555555" + end end) From 999b82c94a167cdb62d2894fe45718bd48a91ce9 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 20 Jul 2021 15:21:07 +0200 Subject: [PATCH 34/74] small documentation graphical improvement --- CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b5098a4f1..4c9bf3e384 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -52,17 +52,17 @@ Each mod must provide `mod.conf`. Each mod which add API functions should store functions inside a global table named like the mod. Public functions should not use self references but rather just access the table directly. Functions should be defined in this way: -``` +```lua function mcl_xyz.stuff(param) end ``` Insteed of this way: -``` +```lua mcl_xyz.stuff = function(param) end ``` Indentation must be unified, more likely with tabs. Time sensitive mods should make a local copy of most used API functions to improve performances. -``` +```lua local vector = vector local get_node = minetest.get_node ``` From b5f7ae54583197b55bb5e8f5f81a6605fa4f74e8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 20 Jul 2021 15:47:26 +0200 Subject: [PATCH 35/74] working implementation + support of other mods --- mods/ENTITIES/mcl_boats/init.lua | 2 +- mods/ENTITIES/mcl_boats/mod.conf | 2 +- mods/ENTITIES/mcl_minecarts/init.lua | 2 +- mods/ENTITIES/mcl_minecarts/mod.conf | 2 +- mods/HUD/mcl_title/init.lua | 5 ++--- mods/ITEMS/mcl_beds/functions.lua | 2 +- 6 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index 76ace7a45b..e81e9ffc5d 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -84,7 +84,7 @@ local function attach_object(self, obj) end end, name) obj:set_look_horizontal(yaw) - mcl_tmp_message.message(obj, S("Sneak to dismount")) + mcl_title.set(obj, "actionbar", {text=S("Sneak to dismount"), color="white", stay=3}) else obj:get_luaentity()._old_visual_size = visual_size end diff --git a/mods/ENTITIES/mcl_boats/mod.conf b/mods/ENTITIES/mcl_boats/mod.conf index a5d6cc8cb4..61463b6ec2 100644 --- a/mods/ENTITIES/mcl_boats/mod.conf +++ b/mods/ENTITIES/mcl_boats/mod.conf @@ -1,7 +1,7 @@ name = mcl_boats author = PilzAdam description = Adds drivable boats. -depends = mcl_player, flowlib +depends = mcl_player, flowlib, mcl_title optional_depends = mcl_core, doc_identifier diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index e33e120a14..a76ab538af 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -646,7 +646,7 @@ register_minecart( if player then mcl_player.player_set_animation(player, "sit" , 30) player:set_eye_offset({x=0, y=-5.5, z=0},{x=0, y=-4, z=0}) - mcl_tmp_message.message(clicker, S("Sneak to dismount")) + mcl_title.set(clicker, "actionbar", {text=S("Sneak to dismount"), color="white", stay=3}) end end, name) end diff --git a/mods/ENTITIES/mcl_minecarts/mod.conf b/mods/ENTITIES/mcl_minecarts/mod.conf index 9fff9175df..3b8ae55514 100644 --- a/mods/ENTITIES/mcl_minecarts/mod.conf +++ b/mods/ENTITIES/mcl_minecarts/mod.conf @@ -1,6 +1,6 @@ name = mcl_minecarts author = Krock description = Minecarts are vehicles to move players quickly on rails. -depends = mcl_explosions, mcl_core, mcl_sounds, mcl_player, mcl_achievements, mcl_chests, mcl_furnaces, mesecons_commandblock, mcl_hoppers, mcl_tnt, mesecons +depends = mcl_title, mcl_explosions, mcl_core, mcl_sounds, mcl_player, mcl_achievements, mcl_chests, mcl_furnaces, mesecons_commandblock, mcl_hoppers, mcl_tnt, mesecons optional_depends = doc_identifier, mcl_wip diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index 48c3a909f7..03fe176147 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -45,7 +45,7 @@ local player_params = {} minetest.register_on_joinplayer(function(player) local playername = player:get_player_name() - player_params[playername] = { + player_params[player] = { stay = gametick_to_secondes(mcl_title.defaults.stay), --fadeIn = gametick_to_secondes(mcl_title.defaults.fadein), --fadeOut = gametick_to_secondes(mcl_title.defaults.fadeout), @@ -127,14 +127,13 @@ function mcl_title.set(player, type, data) return false end - --TODO: enable this code then Fleckenstein's pr get merged (in about 5-6 years) + --TODO: enable this code then Fleckenstein's pr get merged (in about 5-6 years lol) --if data.bold == nil then data.bold = false end --if data.italic == nil then data.italic = false end player:hud_change(huds_idx[type][player], "text", data.text) player:hud_change(huds_idx[type][player], "number", hex_color) - hud_hide_timeouts[type][player:get_player_name()] = data.stay or mcl_title.params_get(player).stay return true end diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index dc9afe2bae..f323ca4c72 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -330,7 +330,7 @@ function mcl_beds.on_rightclick(pos, player, is_top) message = select(2, lay_down(player, ppos, other)) end if message then - mcl_tmp_message.message(player, message) + mcl_title.set(player, "actionbar", {text=message, color="white", stay=3}) end else lay_down(player, nil, nil, false) From c31c852a6ea63eb2ffed49089881866fb59df0ed Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 20 Jul 2021 16:14:34 +0200 Subject: [PATCH 36/74] add documentation --- mods/ENTITIES/mcl_boats/init.lua | 2 +- mods/ENTITIES/mcl_minecarts/init.lua | 2 +- mods/HUD/mcl_title/API.md | 42 ++++++++++++++++++++++++++++ mods/HUD/mcl_title/init.lua | 2 +- mods/ITEMS/mcl_beds/functions.lua | 2 +- 5 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 mods/HUD/mcl_title/API.md diff --git a/mods/ENTITIES/mcl_boats/init.lua b/mods/ENTITIES/mcl_boats/init.lua index e81e9ffc5d..311b07882f 100644 --- a/mods/ENTITIES/mcl_boats/init.lua +++ b/mods/ENTITIES/mcl_boats/init.lua @@ -84,7 +84,7 @@ local function attach_object(self, obj) end end, name) obj:set_look_horizontal(yaw) - mcl_title.set(obj, "actionbar", {text=S("Sneak to dismount"), color="white", stay=3}) + mcl_title.set(obj, "actionbar", {text=S("Sneak to dismount"), color="white", stay=60}) else obj:get_luaentity()._old_visual_size = visual_size end diff --git a/mods/ENTITIES/mcl_minecarts/init.lua b/mods/ENTITIES/mcl_minecarts/init.lua index a76ab538af..4d3873cc23 100644 --- a/mods/ENTITIES/mcl_minecarts/init.lua +++ b/mods/ENTITIES/mcl_minecarts/init.lua @@ -646,7 +646,7 @@ register_minecart( if player then mcl_player.player_set_animation(player, "sit" , 30) player:set_eye_offset({x=0, y=-5.5, z=0},{x=0, y=-4, z=0}) - mcl_title.set(clicker, "actionbar", {text=S("Sneak to dismount"), color="white", stay=3}) + mcl_title.set(clicker, "actionbar", {text=S("Sneak to dismount"), color="white", stay=60}) end end, name) end diff --git a/mods/HUD/mcl_title/API.md b/mods/HUD/mcl_title/API.md new file mode 100644 index 0000000000..50614be4f1 --- /dev/null +++ b/mods/HUD/mcl_title/API.md @@ -0,0 +1,42 @@ +# mcl_title + +Allow mods to show messages in the hud of players. + +## mcl_title.set(player, type, data) + +Show a hud message of `type` to player `player` with `data` as params. + +The element will stay for the per-player param `stay` or `data.stay` (in gametick which is 1/20 second). + +Here is a usage exemple: + +```lua +--show a title in the HUD with minecraft color "gold" +mcl_title.set(player, "title", {text="dummy text", color="gold"}) + +--show a subtitle in the HUD with hex color "#612D2D" +mcl_title.set(player, "subtitle", {text="dummy subtitle", color="#612D2D"}) + +--show an actionbar in the HUD (above the hotbar) with minecraft color "red" +mcl_title.set(player, "subtitle", {text="dummy actionbar", color="red"}) + +--show a title in the HUD with minecraft color "gold" staying for 3 seconds (override stay setting) +mcl_title.set(player, "title", {text="dummy text", color="gold", stay=3}) +``` + +## mcl_title.remove(player, type) + +Hide HUD element of type `type` for player `player`. + +## mcl_title.clear(player) + +Remove every title/subtitle/actionbar from a player. +Basicaly run `mcl_title.remove(player, type)` for every type. + +## mcl_title.params_set(player, params) + +Allow mods to set `stay` and upcomming `fadeIn`/`fadeOut` params. + +```lua +mcl_title.params_set(player, {stay = 600}) --elements with no 'data.stay' field will stay during 30s (600/20) +``` \ No newline at end of file diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index 03fe176147..d1dbece4b4 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -134,7 +134,7 @@ function mcl_title.set(player, type, data) player:hud_change(huds_idx[type][player], "text", data.text) player:hud_change(huds_idx[type][player], "number", hex_color) - hud_hide_timeouts[type][player:get_player_name()] = data.stay or mcl_title.params_get(player).stay + hud_hide_timeouts[type][player:get_player_name()] = gametick_to_secondes(data.stay) or mcl_title.params_get(player).stay return true end diff --git a/mods/ITEMS/mcl_beds/functions.lua b/mods/ITEMS/mcl_beds/functions.lua index f323ca4c72..e196f69ade 100644 --- a/mods/ITEMS/mcl_beds/functions.lua +++ b/mods/ITEMS/mcl_beds/functions.lua @@ -330,7 +330,7 @@ function mcl_beds.on_rightclick(pos, player, is_top) message = select(2, lay_down(player, ppos, other)) end if message then - mcl_title.set(player, "actionbar", {text=message, color="white", stay=3}) + mcl_title.set(player, "actionbar", {text=message, color="white", stay=60}) end else lay_down(player, nil, nil, false) From 31d3ea8a871fef4acbab8493d85768ea7884ac76 Mon Sep 17 00:00:00 2001 From: NO11 Date: Tue, 20 Jul 2021 20:09:43 +0000 Subject: [PATCH 37/74] Fix #1801 (add better texture for golden boots) --- .../textures/mcl_armor_inv_boots_gold.png | Bin 167 -> 409 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_boots_gold.png b/mods/ITEMS/mcl_armor/textures/mcl_armor_inv_boots_gold.png index dc452d41372344c624d15270867e81ea7551b52a..ef1f9fa87ca43be01bc084da406069ce278d3c1f 100644 GIT binary patch delta 382 zcmV-^0fGLf0ht4kB!32COGiWi{{a60|De66lK=n!32;bRa{vG?BLDy{BLR4&KXw2B z00(qQO+^Rg2NVS)N@!D*zX#WvQEA z04#(nBfex{Rjq`aWmi8Z5*|?Csfm&M27np1J9o)$LRS>Zl1E_v~4!`V2#&%;Q32n c`Ir8}H*o=PdJ9oayZ`_I07*qoM6N<$g80X(CIA2c delta 139 zcmV;60CfME1E&FyB!6y6L_t(|0b>|^;Q#;s_%N*uz|=^*L1E2{L6~|5?CR0_55iDB zhB#gWt}HkG|LS1U|0NYl7zO~vz;Ylp*bIQ#0#bm>0I(cT4PFC4nsFKc#25y^G?Rl- t4M^~)Ar`|7ppFYb4017LDUoUb0H9FFs6zF<5C8xG07*qoLI9vb# From a0d52010bf6dcfe3b7fa1175dc5c76923b515eed Mon Sep 17 00:00:00 2001 From: NO11 Date: Wed, 21 Jul 2021 22:16:37 +0000 Subject: [PATCH 38/74] Fix that aliases attemp to register mineclone:book_enchanted again and again --- mods/HELP/mcl_item_id/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index e7772d1416..01eb403624 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -28,7 +28,7 @@ tt.register_snippet(function(itemstring) end end end - minetest.register_alias(new_id, itemstring) + minetest.register_alias_force(new_id, itemstring) if minetest.settings:get_bool("mcl_item_id_debug", true) then return new_id, "#555555" end From fef23d0b6f224ed178d109ec5d74137168119421 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 22 Jul 2021 00:39:05 +0200 Subject: [PATCH 39/74] fix missing depend to `mcl_credits` of `mcl_portals` --- mods/ITEMS/mcl_portals/mod.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_portals/mod.conf b/mods/ITEMS/mcl_portals/mod.conf index d99344a76a..610b590c60 100644 --- a/mods/ITEMS/mcl_portals/mod.conf +++ b/mods/ITEMS/mcl_portals/mod.conf @@ -1,4 +1,4 @@ name = mcl_portals description = Adds buildable portals to the Nether and End dimensions. -depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn +depends = mcl_nether, mcl_end, mcl_particles, mcl_spawn, mcl_credits optional_depends = awards, doc From 667ef5cad51684f79debd5a133dc78f3ea29974c Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 22 Jul 2021 00:46:43 +0200 Subject: [PATCH 40/74] cache doc modpath --- mods/ITEMS/mcl_portals/portal_end.lua | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index d591537e1b..9f0db352a8 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -4,6 +4,8 @@ local table = table local vector = vector local math = math +local has_doc = minetest.get_modpath("doc") + -- Parameters --local SPAWN_MIN = mcl_vars.mg_end_min+70 --local SPAWN_MAX = mcl_vars.mg_end_min+98 @@ -339,7 +341,7 @@ minetest.register_node("mcl_portals:end_portal_frame_eye", { _mcl_hardness = -1, }) -if minetest.get_modpath("doc") then +if has_doc then doc.add_entry_alias("nodes", "mcl_portals:end_portal_frame", "nodes", "mcl_portals:end_portal_frame_eye") end @@ -366,7 +368,7 @@ minetest.override_item("mcl_end:ender_eye", { end minetest.set_node(pointed_thing.under, { name = "mcl_portals:end_portal_frame_eye", param2 = node.param2 }) - if minetest.get_modpath("doc") then + if has_doc then doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:end_portal_frame") end minetest.sound_play( @@ -381,7 +383,7 @@ minetest.override_item("mcl_end:ender_eye", { -- Epic 'portal open' sound effect that can be heard everywhere minetest.sound_play("mcl_portals_open_end_portal", {gain=0.8}, true) end_portal_area(ppos) - if minetest.get_modpath("doc") then + if has_doc then doc.mark_entry_as_revealed(user:get_player_name(), "nodes", "mcl_portals:portal_end") end end From a44d9643ae8b826f1e5efb67259d6d77320dfade Mon Sep 17 00:00:00 2001 From: NO11 Date: Thu, 22 Jul 2021 19:23:48 +0000 Subject: [PATCH 41/74] Fix several problems in `mcl_item_id` --- mods/HELP/mcl_item_id/init.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index 01eb403624..3b3128f269 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -28,8 +28,12 @@ tt.register_snippet(function(itemstring) end end end - minetest.register_alias_force(new_id, itemstring) - if minetest.settings:get_bool("mcl_item_id_debug", true) then + if new_id ~= game .. ":book_enchanted" then + minetest.register_alias_force(new_id, itemstring) + end + if minetest.settings:get_bool("mcl_item_id_debug", false) then return new_id, "#555555" end end) + +minetest.register_alias_force(game .. ":book_enchanted", "mcl_enchanting:book_enchanted") From 75b425ffd77b85ba3081ddf2e47f8b6695ec8fa5 Mon Sep 17 00:00:00 2001 From: NO11 Date: Fri, 23 Jul 2021 12:23:30 +0000 Subject: [PATCH 42/74] Fix #1842 make other mods not using "mineclone" name space for item ids --- mods/HELP/mcl_item_id/init.lua | 33 +++++++++++++++++++++++++++------ 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index 3b3128f269..50247a8580 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -1,4 +1,5 @@ local game = "mineclone" +local mcl_mods = {} local same_id = { heads = { "skeleton", "zombie", "creeper", "wither_skeleton" }, @@ -10,17 +11,34 @@ local same_id = { "stonebrick", "stonebrickmossy", }, wool = { - "black", "blue", "brown", "cyan", "green", + "black", "blue", "brown", "cyan", "green", "grey", "light_blue", "lime", "magenta", "orange", "pink", "purple", "red", "silver", "white", "yellow", }, } +local worldmt = io.open(minetest.get_worldpath() .. "/world.mt", "r") +local gameid = worldmt:read("*a"):match("gameid%s*=%s*(%S+)\n") +worldmt:close() + +for _, mod in pairs(minetest.get_modnames()) do + if minetest.get_modpath(mod):match("/games/" .. gameid .. "/") then + table.insert(mcl_mods, mod) + end +end + +local function item_id(id) + if minetest.settings:get_bool("mcl_item_id_debug", false) then + return id, "#555555" + end +end + tt.register_snippet(function(itemstring) local def = minetest.registered_items[itemstring] local desc = def.description local item_split = itemstring:find(":") local new_id = game .. itemstring:sub(item_split) + local mcl_mod = itemstring:sub(1, item_split) for mod, ids in pairs(same_id) do for _, id in pairs(ids) do if itemstring == "mcl_" .. mod .. ":" .. id then @@ -28,12 +46,15 @@ tt.register_snippet(function(itemstring) end end end - if new_id ~= game .. ":book_enchanted" then - minetest.register_alias_force(new_id, itemstring) - end - if minetest.settings:get_bool("mcl_item_id_debug", false) then - return new_id, "#555555" + for _, modname in pairs(mcl_mods) do + if modname .. ":" == mcl_mod then + if new_id ~= game .. ":book_enchanted" and new_id ~= itemstring then + minetest.register_alias_force(new_id, itemstring) + end + return item_id(new_id) + end end + return item_id(itemstring) end) minetest.register_alias_force(game .. ":book_enchanted", "mcl_enchanting:book_enchanted") From 09a68443cd641ed73631cc076916616e518402ea Mon Sep 17 00:00:00 2001 From: NO11 Date: Fri, 23 Jul 2021 16:12:43 +0000 Subject: [PATCH 43/74] Better fix for #1842 (make other mods not using "mineclone" name space for item ids) --- mods/HELP/mcl_item_id/init.lua | 57 ++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 27 deletions(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index 50247a8580..4e9c7c9f14 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -1,5 +1,20 @@ +mcl_item_id = {} + local game = "mineclone" -local mcl_mods = {} + +function mcl_item_id.set_mod_namespace(modname, namespace) + local namespace = namespace or modname + mcl_item_id[modname .. "_namespace"] = namespace +end + +function mcl_item_id.get_mod_namespace(modname) + local namespace = mcl_item_id[modname .. "_namespace"] + if namespace then + return namespace + else + return "" + end +end local same_id = { heads = { "skeleton", "zombie", "creeper", "wither_skeleton" }, @@ -17,28 +32,15 @@ local same_id = { }, } -local worldmt = io.open(minetest.get_worldpath() .. "/world.mt", "r") -local gameid = worldmt:read("*a"):match("gameid%s*=%s*(%S+)\n") -worldmt:close() - -for _, mod in pairs(minetest.get_modnames()) do - if minetest.get_modpath(mod):match("/games/" .. gameid .. "/") then - table.insert(mcl_mods, mod) - end -end - -local function item_id(id) - if minetest.settings:get_bool("mcl_item_id_debug", false) then - return id, "#555555" - end -end - tt.register_snippet(function(itemstring) local def = minetest.registered_items[itemstring] local desc = def.description local item_split = itemstring:find(":") - local new_id = game .. itemstring:sub(item_split) - local mcl_mod = itemstring:sub(1, item_split) + local id_part1 = itemstring:sub(1, item_split) + local id_part2 = itemstring:sub(item_split) + local modname = id_part1:gsub("%:", "") + local new_id = game .. id_part2 + local mod_namespace = mcl_item_id.get_mod_namespace(modname) for mod, ids in pairs(same_id) do for _, id in pairs(ids) do if itemstring == "mcl_" .. mod .. ":" .. id then @@ -46,15 +48,16 @@ tt.register_snippet(function(itemstring) end end end - for _, modname in pairs(mcl_mods) do - if modname .. ":" == mcl_mod then - if new_id ~= game .. ":book_enchanted" and new_id ~= itemstring then - minetest.register_alias_force(new_id, itemstring) - end - return item_id(new_id) - end + + if mod_namespace then + new_id = mod_namespace .. id_part2 + end + if new_id ~= game .. ":book_enchanted" then + minetest.register_alias_force(new_id, itemstring) + end + if minetest.settings:get_bool("mcl_item_id_debug", false) then + return new_id, "#555555" end - return item_id(itemstring) end) minetest.register_alias_force(game .. ":book_enchanted", "mcl_enchanting:book_enchanted") From e44e9eaf623809bc2fa4c617dd6e9629aa5b3879 Mon Sep 17 00:00:00 2001 From: NO11 Date: Fri, 23 Jul 2021 21:35:10 +0000 Subject: [PATCH 44/74] Fix typo --- mods/HELP/mcl_item_id/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index 4e9c7c9f14..911d8225be 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -12,7 +12,7 @@ function mcl_item_id.get_mod_namespace(modname) if namespace then return namespace else - return "" + return end end From c05e57efb1f3d55c89354c28a84e76abe63aadd5 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sat, 24 Jul 2021 14:09:47 +0000 Subject: [PATCH 45/74] Fix some crashes with set_mod_namespace and bugs --- mods/HELP/mcl_item_id/init.lua | 46 +++++++++++++++++++++------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index 911d8225be..9a2f926e8b 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -1,22 +1,38 @@ -mcl_item_id = {} +mcl_item_id = { + mod_namespaces = {}, +} local game = "mineclone" function mcl_item_id.set_mod_namespace(modname, namespace) local namespace = namespace or modname - mcl_item_id[modname .. "_namespace"] = namespace + mcl_item_id.mod_namespaces[modname] = namespace + minetest.register_on_mods_loaded(function() + for item, def in pairs(minetest.registered_items) do + local item_split = item:find(":") + if item_split then + local id_modname = item:sub(1, item_split - 1) + local id_string = item:sub(item_split) + if id_modname == modname then + minetest.register_alias_force(namespace .. id_string, item) + end + end + end + end) end function mcl_item_id.get_mod_namespace(modname) - local namespace = mcl_item_id[modname .. "_namespace"] + local namespace = mcl_item_id.mod_namespaces[modname] if namespace then return namespace else - return + return game end end local same_id = { + enchanting = { "table" }, + experience = { "bottle" }, heads = { "skeleton", "zombie", "creeper", "wither_skeleton" }, mobitems = { "rabbit", "chicken" }, walls = { @@ -34,13 +50,11 @@ local same_id = { tt.register_snippet(function(itemstring) local def = minetest.registered_items[itemstring] - local desc = def.description local item_split = itemstring:find(":") - local id_part1 = itemstring:sub(1, item_split) - local id_part2 = itemstring:sub(item_split) - local modname = id_part1:gsub("%:", "") - local new_id = game .. id_part2 - local mod_namespace = mcl_item_id.get_mod_namespace(modname) + local id_string = itemstring:sub(item_split) + local id_modname = itemstring:sub(1, item_split - 1) + local new_id = game .. id_string + local mod_namespace = mcl_item_id.get_mod_namespace(id_modname) for mod, ids in pairs(same_id) do for _, id in pairs(ids) do if itemstring == "mcl_" .. mod .. ":" .. id then @@ -48,16 +62,12 @@ tt.register_snippet(function(itemstring) end end end - - if mod_namespace then - new_id = mod_namespace .. id_part2 - end - if new_id ~= game .. ":book_enchanted" then + if mod_namespace ~= game then + new_id = mod_namespace .. id_string + else minetest.register_alias_force(new_id, itemstring) end if minetest.settings:get_bool("mcl_item_id_debug", false) then return new_id, "#555555" end -end) - -minetest.register_alias_force(game .. ":book_enchanted", "mcl_enchanting:book_enchanted") +end) \ No newline at end of file From 65d33b935ab23e6a43b069c62124d51ead05c165 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sat, 24 Jul 2021 14:45:55 +0000 Subject: [PATCH 46/74] Add API-md for `mcl_item_id` --- mods/HELP/mcl_item_id/API.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 mods/HELP/mcl_item_id/API.md diff --git a/mods/HELP/mcl_item_id/API.md b/mods/HELP/mcl_item_id/API.md new file mode 100644 index 0000000000..a2f244e0cd --- /dev/null +++ b/mods/HELP/mcl_item_id/API.md @@ -0,0 +1,24 @@ +# mcl_item_id +Show the item ID of an item in the description. +With this API, you can register a different name space than "mineclone" for your mod. + +## mcl_item_id.set_mod_namespace(modname, namespace) +Set a name space for all items in a mod. + +* param1: the modname +* param2: (optional) string of the desired name space, if nil, it is the name of the mod + +## mcl_item_id.get_mod_namespace(modname) +Get the name space of a mod registered with mcl_item_id.set_mod_namespace(modname, namespace). + +* param1: the modname + +### Examples: + +The name of the mod is "mod" which registered an item called "mod:itemname". + +* mcl_item_id.set_mod_namespace("mod", "mymod") will show "mymod:itemname" in the description of "mod:itemname" +* mcl_item_id.set_mod_namespace(minetest.get_current_modname()) will show "mod:itemname" in the description of "mod:itemname" +* mcl_item_id.get_mod_namespace(minetest.get_current_modname()) will return "mod" + +(If no namespace is set by a mod, mcl_item_id.get_mod_namespace(minetest.get_current_modname()) will return "mineclone") From 5c5c405ccf92762af6f0757d4a3b015ff14d0d37 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sat, 24 Jul 2021 15:19:10 +0000 Subject: [PATCH 47/74] Add missing check --- mods/HELP/mcl_item_id/init.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index 9a2f926e8b..e6df1af036 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -13,7 +13,7 @@ function mcl_item_id.set_mod_namespace(modname, namespace) if item_split then local id_modname = item:sub(1, item_split - 1) local id_string = item:sub(item_split) - if id_modname == modname then + if id_modname == modname and modname ~= namespace then minetest.register_alias_force(namespace .. id_string, item) end end From 4846076c8fc2555dff12bf148c5b1d83ab39ec9d Mon Sep 17 00:00:00 2001 From: NO11 Date: Sat, 24 Jul 2021 19:07:44 +0000 Subject: [PATCH 48/74] `mcl_item_id` simplify code --- mods/HELP/mcl_item_id/init.lua | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/mods/HELP/mcl_item_id/init.lua b/mods/HELP/mcl_item_id/init.lua index e6df1af036..f3e6d2735a 100644 --- a/mods/HELP/mcl_item_id/init.lua +++ b/mods/HELP/mcl_item_id/init.lua @@ -7,18 +7,6 @@ local game = "mineclone" function mcl_item_id.set_mod_namespace(modname, namespace) local namespace = namespace or modname mcl_item_id.mod_namespaces[modname] = namespace - minetest.register_on_mods_loaded(function() - for item, def in pairs(minetest.registered_items) do - local item_split = item:find(":") - if item_split then - local id_modname = item:sub(1, item_split - 1) - local id_string = item:sub(item_split) - if id_modname == modname and modname ~= namespace then - minetest.register_alias_force(namespace .. id_string, item) - end - end - end - end) end function mcl_item_id.get_mod_namespace(modname) @@ -64,7 +52,8 @@ tt.register_snippet(function(itemstring) end if mod_namespace ~= game then new_id = mod_namespace .. id_string - else + end + if mod_namespace ~= id_modname then minetest.register_alias_force(new_id, itemstring) end if minetest.settings:get_bool("mcl_item_id_debug", false) then From 4aabd7d9e721a860864157ac5145985d8a2360b9 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 1 Aug 2021 12:10:00 +0000 Subject: [PATCH 49/74] Make size/position of potion HUD more MC like --- mods/ITEMS/mcl_potions/functions.lua | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_potions/functions.lua b/mods/ITEMS/mcl_potions/functions.lua index 09b95115ad..c3b034b664 100644 --- a/mods/ITEMS/mcl_potions/functions.lua +++ b/mods/ITEMS/mcl_potions/functions.lua @@ -35,13 +35,13 @@ local function potions_init_icons(player) local name = player:get_player_name() icon_ids[name] = {} for e=1, EFFECT_TYPES do - local x = -7 + -38 * e + local x = -52 * e - 2 local id = player:hud_add({ hud_elem_type = "image", text = "blank.png", position = { x = 1, y = 0 }, - offset = { x = x, y = 272 }, - scale = { x = 2, y = 2 }, + offset = { x = x, y = 3 }, + scale = { x = 3, y = 3 }, alignment = { x = 1, y = 1 }, z_index = 100, }) From 5c563d6ffd16ba6d64691fff5e0356b85eb4fe80 Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 2 Aug 2021 12:24:34 +0000 Subject: [PATCH 50/74] Make eating particles much more MC like! --- mods/PLAYER/mcl_hunger/hunger.lua | 32 ++++++++++++------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/mods/PLAYER/mcl_hunger/hunger.lua b/mods/PLAYER/mcl_hunger/hunger.lua index 5dec8b1b04..d9a6fd5fe6 100644 --- a/mods/PLAYER/mcl_hunger/hunger.lua +++ b/mods/PLAYER/mcl_hunger/hunger.lua @@ -152,26 +152,18 @@ function mcl_hunger.item_eat(hunger_change, replace_with_item, poisontime, poiso -- If false, force item to not spawn any food partiles when eaten if def._food_particles ~= false and texture and texture ~= "" then local v = user:get_velocity() or user:get_player_velocity() - local minvel = vector.add(v, {x=-1, y=1, z=-1}) - local maxvel = vector.add(v, {x=1, y=2, z=1}) - - minetest.add_particlespawner({ - amount = math.min(math.max(8, hunger_change*2), 25), - time = 0.1, - minpos = {x=pos.x, y=pos.y, z=pos.z}, - maxpos = {x=pos.x, y=pos.y, z=pos.z}, - minvel = minvel, - maxvel = maxvel, - minacc = {x=0, y=-5, z=0}, - maxacc = {x=0, y=-9, z=0}, - minexptime = 1, - maxexptime = 1, - minsize = 1, - maxsize = 2, - collisiondetection = true, - vertical = false, - texture = texture, - }) + for i = 0, math.min(math.max(8, hunger_change*2), 25) do + minetest.add_particle({ + pos = { x = pos.x, y = pos.y, z = pos.z }, + velocity = vector.add(v, { x = math.random(-1, 1), y = math.random(1, 2), z = math.random(-1, 1) }), + acceleration = { x = 0, y = math.random(-9, -5), z = 0 }, + expirationtime = 1, + size = math.random(1, 2), + collisiondetection = true, + vertical = false, + texture = "[combine:3x3:" .. -i .. "," .. -i .. "=" .. texture, + }) + end end minetest.sound_play("mcl_hunger_bite", { max_hear_distance = 12, From df0c1f1dd1e32dc74a1b9e9a767037c517cdf071 Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 6 Aug 2021 11:14:17 +0200 Subject: [PATCH 51/74] Make bows and fishing rods show their durability in description (Fixes issue #1773) --- mods/HELP/mcl_tt/snippets_mcl.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index 3c79f52e8a..121d8ed70e 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -107,3 +107,8 @@ tt.register_snippet(function(itemstring) end end) +tt.register_snippet(function(itemstring, _, itemstack) + if itemstring:sub(1, 23) == "mcl_fishing:fishing_rod" or itemstring:sub(1, 12) == "mcl_bows:bow" then + return S("Durability: @1 uses", mcl_util.calculate_durability(itemstack or ItemStack(itemstring))) + end +end) From 5bb57a81ad46c163b58da046920b8a4bee18b30b Mon Sep 17 00:00:00 2001 From: Emily Date: Fri, 6 Aug 2021 11:55:27 +0200 Subject: [PATCH 52/74] Add durability tooltip to translation template --- mods/HELP/mcl_tt/locale/template.txt | 1 + mods/HELP/mcl_tt/snippets_mcl.lua | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/mods/HELP/mcl_tt/locale/template.txt b/mods/HELP/mcl_tt/locale/template.txt index 1259216c76..6fb735b139 100644 --- a/mods/HELP/mcl_tt/locale/template.txt +++ b/mods/HELP/mcl_tt/locale/template.txt @@ -45,3 +45,4 @@ Mining durability: @1= Block breaking strength: @1= @1 uses= Unlimited uses= +Durability: @1= diff --git a/mods/HELP/mcl_tt/snippets_mcl.lua b/mods/HELP/mcl_tt/snippets_mcl.lua index 121d8ed70e..825776f5f2 100644 --- a/mods/HELP/mcl_tt/snippets_mcl.lua +++ b/mods/HELP/mcl_tt/snippets_mcl.lua @@ -109,6 +109,6 @@ end) tt.register_snippet(function(itemstring, _, itemstack) if itemstring:sub(1, 23) == "mcl_fishing:fishing_rod" or itemstring:sub(1, 12) == "mcl_bows:bow" then - return S("Durability: @1 uses", mcl_util.calculate_durability(itemstack or ItemStack(itemstring))) + return S("Durability: @1", S("@1 uses", mcl_util.calculate_durability(itemstack or ItemStack(itemstring)))) end end) From 664c2381374ee25f423d2b0d0eb66b838257eca6 Mon Sep 17 00:00:00 2001 From: NO11 Date: Fri, 6 Aug 2021 10:52:55 +0000 Subject: [PATCH 53/74] Add german translation for the bow/fishing rod desc --- mods/HELP/mcl_tt/locale/mcl_tt.de.tr | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/HELP/mcl_tt/locale/mcl_tt.de.tr b/mods/HELP/mcl_tt/locale/mcl_tt.de.tr index 8f878afc72..54c376c3bb 100644 --- a/mods/HELP/mcl_tt/locale/mcl_tt.de.tr +++ b/mods/HELP/mcl_tt/locale/mcl_tt.de.tr @@ -45,3 +45,4 @@ Mining durability: @1=Grabehaltbarkeit: @1 Block breaking strength: @1=Blockbruchstärke: @1 @1 uses=@1 Verwendungen Unlimited uses=Unbegrenzte Verwendungen +Durability: @1=Haltbarkeit: @1 From f8dcf056707c917f2b77aead6669ee0d05905c86 Mon Sep 17 00:00:00 2001 From: NO11 Date: Wed, 11 Aug 2021 15:41:45 +0000 Subject: [PATCH 54/74] Add MC like nodebox for anvils --- mods/ITEMS/mcl_anvils/init.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index fbf6fb7513..51b78da6fe 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -297,9 +297,10 @@ local anvildef = { node_box = { type = "fixed", fixed = { - {-8/16, 2/16, -5/16, 8/16, 8/16, 5/16}, -- top - {-5/16, -4/16, -2/16, 5/16, 5/16, 2/16}, -- middle - {-8/16, -8/16, -5/16, 8/16, -4/16, 5/16}, -- base + { -6/16, -8/16, -6/16, 6/16, -4/16, 6/16 }, + { -5/16, -4/16, -4/16, 5/16, -3/16, 4/16 }, + { -4/16, -3/16, -2/16, 4/16, 2/16, 2/16 }, + { -8/16, 2/16, -5/16, 8/16, 8/16, 5/16 }, } }, sounds = mcl_sounds.node_sound_metal_defaults(), From cb55c36863b429a8328c98bc478d525d081727ca Mon Sep 17 00:00:00 2001 From: NO11 Date: Wed, 11 Aug 2021 15:44:43 +0000 Subject: [PATCH 55/74] Correct the texture of anvils Because of the new node_nox, the textures have to be a little bit bigger. --- .../mcl_anvils_anvil_top_damaged_0.png | Bin 195 -> 6074 bytes .../mcl_anvils_anvil_top_damaged_1.png | Bin 209 -> 5855 bytes .../mcl_anvils_anvil_top_damaged_2.png | Bin 220 -> 5882 bytes 3 files changed, 0 insertions(+), 0 deletions(-) diff --git a/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_0.png b/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_0.png index 84c64e9159abbd2703d701a32211caa4cc9b8418..43938aa7265afa58d0394ae683e7815a6159dc40 100644 GIT binary patch literal 6074 zcmeHLc~lcu7Y_&m5i2fLP>>LoDlpkdLK2C}P6Q-CSgh-0GJ!~v2}vM{pca*ipt$1( zE=5I9saO@MWvha;q5{Q=6j5+PM6oU?2ZV1D5b>*@{XD1rPtFO+yYF{@_rANmIkS#C z*LO5_G8TiujOO@xg`nSN+K<5q^#9|Vt*F3Y=Q3WTG6YoNWO76(62my9Mh4?xwMdA; zs2h)mi!xp~nD$dnOMKb}14^I}QqCVrDN zf|OaVJlY@qRkvx$WV6yN@vp3I0V1)A)h}8(|ET-vGmmfBKf>hB*s?pf=E*_fY-uHZ z?ZrDz<~@IUxw*R+8+Py(Dl0>$ja!}Jli_H;^wfqDu6s&`YggN@Q7P?bmbm#6e4L&N zdOSC<&*m-J6sT7`GJH`%4Z}744%X0efr(S>CG3^t2|T3l!t=HxrwJOo)x_|Wv~$K| zeWLOUBMm){1X}%qQO~>{^x)bz?iM5?yPeABg@OZ~^B4LG%_JwdHJ#U2C9*9s_)Nff zWMkn$D+?RnMwf(ooAY|Tb_}f8If^?QzhJEWe8{rOr0Htq)F22L)hVoZHnXX0VI{BF zRTf4R*K91*n>>eqAvI+@(fvESsLZ(5%;))&O7CtcT=diPW+Ut6Sce8&xuNwcEcswn z?S94_W$i^XD8OW`gL-a5)(PC9>KlSR_UAejRpcD~?g{e`o^AE#+Gp^JcBis}7rvy` zNB-tB<>09sf%L*|Kpg8oIwa=s4TsCLTOMfu@VnpRQ_XujfAHB#n;P&kc}2mu$D4yD z)n8htyi#U9U;j>t3&vgXAi(HkMp#b1;;`+VaAVs!5AX8Y*C)B38|$B4aWk!GJo0N} zf5nub`@EbdL8Kg3+?eW{nx3++A0vCd+c4SmWlV$nwUO7qUvuI0C2r}|?EN!L&;K4= zz5Uq!HG1U*CvCyGATGIAk3a?LB=3OMi;1Aivl|V`F$M-S3i=_kCREK7RMcosL$v z-nG^(nn@Rp>wXx&I;K;zc=S4l=`JBz4h=V|7u+=6NYMPbdwN7i)857zsqINWy|HjMG_^CRBH`-M%2<_foq}qTyZ@`6HHC%AA>zc+W2Lw}~UZF7eD-8LVp9Mo3J4;4ooV`N&td zi}KHP@%Oh|ms5!|@~i4sA0OjU5QP1DMibqzJ1@92tg!C&tj9-3MEG^tWo_kN%X1Qi z>2(Kw$@T2I*W%$^>_++VX+-+U?CgX$m51W`9yz{AtQDSY|Kbl--m5q4oaW?&(uJ-y zZMjSG{407dOQs|qeID~9*Rgo^oH0uuEm_+w)r9SM3TdprtgCe$)iS;Lse{AmwG^ar zS#E!1^U~DacLKQ5Mfc9Mh2`DnZ@0eMW486;tnjgW`V99Tsqygh5FW!|^pZuMo?MQn z=i3>DPNvM|o7sNnXIoY*4n5@UWYvMIv+<0pU3DZSn^#~wanAe$VMbg1OZRg;>sni< zotw=>QJn&42@aUBqZYa9 zfa?3<-nX23+kDNy^_=SZ@eeCZ7hJr~c1tWyd*=K~u`*rH9-)-kj=M^}d1NeNc2)el z@=DJIoA50YS{1Fas|kL+RdF|3T(5ZVG2ClGq2y{>%?ctr_(f^+e&MdmS!bJ?7hJL_ zF0$pPih0ND=k@IEO-}mh%$EDC%cRyw4}DI`reI%-FYCZzU{y)Dn=rxF|=Q_%|~L4;l!k%0j$2$2v#0m6p~YKaWJ zR4^E~S!x*w#lT7&AC3}9+4#9!0e;p@ ztecvJ5=dYrh*L|%QUy!R#_M=l=x?o>cZ?Ql~M4i%E9>1PCM&uyj9Ng)qpZxIzE}V$uOB9RdL+17-kZvXDe$KxB~SLK{ZKkt&p+6oR!> zC^#gzmIX%I>UgEW8-(}e&?6S|N<8kNcvz&a{z9$4;N4jWG)klsnSVo)hW2_y8~s`$&k=6%arI2<-(X3ED~m#5Q5pDw zY!7Dt-#H$g!iQ-zx+}mJ@?n5Vg=qkTNv8s2K1g*TGniBXiT=L3|H$!}EE@Uk@!W{o z3*>Dw-LxY%FpxDo-EP_u%;ISKEHq9g6N_N^`(^O9E&c~?nEqf3{+;@8*nqYtBGaHl zDq0z&l77_u2Y>?%0U`*NDv*!4J{&R-mSOiS>hpjMy}!}N0pif}z+e+-=fuDGH`rYN zq6L)tvyo4V@8@uR4%a6|;FG|gtLt;PJ}Cm91pZuI|5&)N@7^fDQuMJ_g}yHkJzVUF zzH2b&2JpPmZ&0j#_dui3*lae3!*OtMaCUY+bo}-hRH~;8nH!3keZK*HpN-Mu`}=xf zQVgy9(1nT2Z=M2!88u$}(ZlS{G)IL-N=~4+(LLi)W2{^pst;?G7IVDZdB)d)_2pyB zaK;7?ACe~GcxJ!pPbf1zV@>UTe4=UG=&YtSDdtipc5>Y_LXF?W@KmR=2X)!jPpg{R z=e;~`*m@~Z3O{*mb0yR12QG;ZcXWG|E-1xy7_7yPDn3S?dctC2_;%D3hT}cgE8kyC?g_dS~gqfu6?Tc50IwtLvYD7KjW>!X|Nn#cN&oMJL^Y}mH&u6vL7 z_MBX$qEgXV^dfmHnAz5C``f`q54bJkr=1M+ zG*3}fR=*rtKc}-wm>LW%^M~h9d^$kEt3f`Nw^jvn&lPQmO?zXM`oe{EX z!V9ys1n@>y%LA_a8zjVGY!CBlj_PSpOD$Ww_D;v6N|Q?o6ShyiJhGtOEM}RacE6j` z-L~eoCz?cKwjyu;tlVxTcH7tt!p=_N$YwMDwuFz=fRrOnvhgWUZ%&~ak=@Oh@Rr6i9 z*2}vL$h32cz*{}Y_E(J3cy@_y#VpxkFCJ{_c0X}_wfE3clhw8Ok`vxZ9`n)@E6oXh z%&1%DWisvr&^x0<)ahFd<2(m0Gq5{nYn5sGz2@xYVFTm_s}B^PX)Iow5=>t(WQkR4 z2oJKc-v3Lq`r>=oFmU}4scv(=G;s;VeFV} z2IN=QZ(&VA>(5xhfdiL2NAj9C?k5z~UKMN@UGY#^4eT&@Z4;GWrkxrxdTn_5`ZUjJ zvtQ7gBEz&AE-o0nOVt>g+kW`*)-#)i#N_iL9qaaOpKML{%p5-GjkiTq zf>cbaIju!x2JO7g%>k(w27j<>erd$Zh_hj55@+q74NSNgEyMA(oR9; zIpkdJs!@#x6LY2IE+YH6ajhi-yYAoc`rUPzU&mWSN7vns44{I7xORULe7a0w8 zeLhsyG-!U-jaCa~Bk{?$GZ%MO)RdR6-r*>9-u2pl=lS#LV`3&M;@1?eNm!@-;fm4d zdz=zc`NF&7?p0bZbSJ#{Ba@T;Jbw3rvCj(Rs|TMfUgWl5Z^W_M-wz4r|I4|Il720G z<+(TM=U#6xN_T%+LAtj7@%)Io_5;-0(|VlqMKcN+`;V?qxaRu(Z;ZQz8E=+3UOBVf z;l}kkLnoDCk>7!AX?f?Q&h}l0541dD)Ylnzj=Z#Z_7HX@y|ls?&Mv+D>zjJ~`b8Ci zm!4VrXY7lA{mZM!e9yf(uh;HWFMjgY<>ZFN_#;M#3hZ|~`(s?R^aFA@Q~0j(nnRFyfbxsc(Lh_DN$Re56GT+YzxEz|_owng~0 zxOV^UZw0O5);3w+KW#qi%oUDDV&%%G<6kNlXW&Q6z~fHe)&Vzmej~H0lUznGbe$R* zk!7P*YUeK{2Xt4fuHI%`@Y`U#$rc0)AECw~w5j zv8QQ9*QV~2q$7v2+Supaw2|Hh+|zhaA2JQuiv4(`C zn4Rrh`u4G_jQ`Pnw9_)5y!7l6U5xTJ`xUyiOO6{!p~o0DAkwC;0Hx*FVI=Ri^z z8I>lj{3FBpF+O*~@r&7H+bmMN*eu21$)d?EIff>(q@(m5rJbHU$0g>fgNcUr_6FPi zYUZfpOOI8QF0L!->cVF|Rg@%*dql(GEc3+JRS_8!$cAOHWJn<6BV^*Ieoqf_3zGXF(c*vw3M6a+FC1Pl4`vC76Ftp5G;E9@ z7C|9`CRQR!vA0f*yj-;}9c*LI^%G1wx>aX=FE&pGF)95r~QY@N_Yj;+Fe8f>!9fo`m)SE2$67aP#9{a^qJ=;p>Gxq&2* zMd@#ktp)|Xx0WjVRK)b8XdpQSAiGgwV?VM`qJD87{C(0w8IIl9lu$$|Qz>A?FAkBS zPW_$AB`RfqpDHDyo6^TE5eO+*P7|cFuPfVE2CH;VxxO5tE?%}k z28#u3{UZZlQdtOtP7;DtfJCD)-AODVpFv_UVGv;f3@TGV?MKCxDp5!ZBRVRKoGiw8 zXhJ3pv!;=lG%AyXF)&Ch1Y(hBd;!B<$YN2MR7O9FV1*c~1W3|9Djk&oqY^TyAdAjq zk{ArCfJB4nd=e7?AreDKW%5A)L<9_$o=SHPY_AY5hX|70KFowjAXF$*#A4+omI`EQ z<%gwkaV!#sLOR(1caZ7MqBHc7xr6=eBM^lWOLHA7;6?^Py}1BpPsTVQEZxMhkO-m3 zr6T=;?qJy1b}(rnU3Fm0`gv?OY##*zp)y6dOeWzFbW0;8Yj`4sp)Qz+K$ zl&B(}`!}2V51dDD!UkZrGDUnp|6$1d-cfH$l8E(E5eWJ=z=q&n`IS%{BG4ZJrep6C z91TfD2-a`=itXLJ_*02YW4Qx-K0<;8SeK&FVUPsD0vZYA^8pYLLVyrPK4w?Sgs2)) zAYLLY2e5O-ic5da1ed=28~ZU{9gXOc%MAobmJl+bC6`OYh~i_N-sR1I!S%E6%hA6x?+@#>_L0fsu_}&6gVoZ{ zy8i^QmmyFLBT}X8bD{T#^vcrjBEn+sox?6T?7pPDzcBlaR|| zNZ+q=eUYv>UtFrO zLjX1yC=ZyS#Nh^6>ppng`n+M-+2P6dc~pkgoPns z>N_naNtJV8YclgY!n!>;tyzQDEVX&*nDibTYKsE6%tdj}mlo~WeZ+xQG>q`7v(6M>bPitH}w+*gv1G@3NLfcDqg|%BS PuQ;wB&v&o)+~j`)mnpRX delta 163 zcmV;U09^myEztpxBL)B%P)t-slm8VMe;sF9xBvhE0d!JMQvg8b*k%9#0B1==K~#7F z9m~ND0zn8yVRmd_SutKmw*g}ZBrp|#Q-K{g{Tu$8}E3 za0gU)FPMq~VeUxoV_~1)8Mu6f0uhP5d4|=ssf}NuvD_28@-6qm<9r^S{_@Ka5oW~6 RhyMTo002ovPDHLkV1mc^K{fyY diff --git a/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_2.png b/mods/ITEMS/mcl_anvils/textures/mcl_anvils_anvil_top_damaged_2.png index 5f5cfbffa6f0ebd6c1fa06ad201cb312ca6875e0..096f65eac2203e52431aebcd73c473f68a690441 100644 GIT binary patch literal 5882 zcmeHLX;f3!77l|*DIzE$QHD#RRK<*BmN<|E5@d)>2GrIJH;|Hv+#3>I8LY5fn$1TCG+Dt)SwBfPkn-#fm(c)eEZw`d}r@{xMT`L z1Bcj+vO}RzLj-(oIP&di`dC{bzuRv&A`{jd=0%F&aIpc<>NIkN5(MC6EeL={g&c)4 z-q;r%bKu@M`<_;3$a;+9g+vjy#RlpTC^@U2>`6UQC*CTH8MZ!eT95hFWS?;9Pxrw zc`@g*Yu)eY1?ZvU^MAB;J&$r&;gLXd+U{yVTLE7+?5O`Pe3DNB&-32s@!F(wBdiU? z+Z#@<%2#$?*vbM@pDKUtOvx`hF#Fb2kFXAE;hmdDj>+5s{k2^!(b*%MeF6F}aSmm_ zU`5?c*@rXyyIh1{>Mx@W+xYgeteEdt6-G>I@gL+BtA0fC9qCAwRT#5puZX^TK6@i; zzBZ}?*l0O#$d2QZZKpMUw?^1$XMeUKm>7T^QRDjO+1|^-4s3HKEE0L)Jp{{$Hjs3Y zi|w|_Px%fDT2FkHG1JPXc>!~7hM@Hd*X5`#;a)Ct8BOS18MiO@hqV?{t?L)g&FNlK zipAdJ&zFZ;yIH*u5S_1!sxS6I?KozZhUc;zS&`p%j7fnV*txRi*$C|*PW`3 zSDy3KSn0-PI{9Eik6UNv6(nBGgsP5R?#ZLynfIh>zGuoGjFV_Zq!3sMV57qp!#v=ej3XA}fwkcjc4i{aQ?C)OQ%vTJWI_KuOf z+eV+3!K4;;pSqP_MiA|3Djk2LFk{<{C03CtVX83RE0NzMoYZ>t_Q9arb}6>sqf=uK&%6`cb+o zhi=odD!aybmTxIB{44fIDW>yE=0+zHd%@PCstEG1yS6|jf9k!16VN5BM*Fr|s~&6` zbKL>L`d`UOo%%0Z#f*d&%Zu&q3(|A{biqy`<&ilnnjOxa+di46$9z}D*!<-1XHn(H zi|Xz99e4Lc*(8?#DzCq6O*l)kP zdg0P;i$2^CY)=trt9Qi(VL-F{;q=TCb##*PQ$U{C4dmZdA zR^46Pl}#Cy`|`@DjVXo4>SrF@=e8zu{^pgZ4<3D9v#Yjahg17%Y}~VNOOrew`91yS zSz_;!OIHI@i)P*o99@Sln>FiI`u4IVh2>zv&Rxx6af=q6xxsR)bO_%SSZ~mbJycq2 z7<;yOawvIHKJ30mrEaekW7=cX*J5g}tv}$l;mF8mKFm2cuyf)fyqllj$-6&8lhwWR zc+RYqvAsdNQyaz(&3aJuEU0H`*Xg>4ch~ivYa&EMzOq99c&cM~WYi@T%3`sC!x0KN zoY!3n=}iUS=n1IRq08~%jj!_jvs{N}cRzW2r|GdfK=BEt&i6(|?LikA zgDYF2dG$U$_X8cpD+HA_!`sf-&;I2a+b`urR_Da$P+GRdSPl6Uc33s(cA=BTv08Z* zuIm2TD>~1)5o%1#!1H^~>FXNkRlJRZHlxYpqU1)$V$mbXk*t{W!pz;7*yZ2PD9_Q0 z8jhcd*;fgMv=dzU|G(LK=g(rIbpU_T0p@tSHkZVH}63minRCuvWBLVS7l@_^H zP$<7CMy*(y0K$L-j8mxDn2uv7F@QqG#>}LK5JR*aFkZo*rvoGAg+@x}B}kbv%#_J? zenu8TpaNkrU{op95X;EMn0Z;qvuT=u0n89MfsGM`2my{p2Lcp41y98BjEW>OX0jdN zr<2K9;oN|J3S`8_#KW+bMIaaq2E4%+uhGR3NK7V^KqM2$WE_IPLCI=ZY{aP{tcjwJ zg9}1Zok9yMG-|-aDVAvTFdKtG)`5OX*h zmP{j6$XMn_2}4e$5}8ySkw%r{C?q)<$Dqm>IGV56mqsT_X%ad(fJ&f-V6j>Xny3(R zyaM5&`GRr@oyx#bBqS=10+L8LrkF^=`I6*vI#WgkrHp|TVLAm;31a2Is7zEcgo;F@ zlgVvis4yEySdXix_sX>MXA5%J`{6`7P3fN+YD zbW^CraUemfjx(E>4u*wn2a#56st$zNJdf;##nFLcSfh*7Xq0S>DO$ipX)Y?jufJSa z!5XRA&Va5-|}c_cdi7iGd`tFVhz%0i|?b8ktIy zOQi3zLmD}35bMBcaYzmz=ZqAW`J91q{rNZkUA!S4G$j|2Ou`|3kVJ|k(OG0Bi%Q4z zoi^Y{Fm>41yY(~mppX#OKt23SJ&GkTC1QkLt5qsM-Mc!y&YS;&8(`m`qkm^U5Y}hS z(P)#ADvpQ44C)WMe-E&aAy^>=)sW^xp$~-g$ui&~LSpWlLoPVvz9hW4F#EH_R7n5e zPk;9PgB}p-Pfk8c-%oOVlIx=s_$ctF?D{0vM=9`8;7{50f0N7Z?JGB^M*i+IATQK~ zvCtjlW!ys;9LbyBlZHG}sZ=(bEf5GMPMqlF<%LG0y}i9XJUoQ28gR(61son4ftuQK z9r?#E%0eCH9CwNfSh@8U`i+~BD=C8?4c9(>Y$xwIR+E*5?@X->~ z*51?{#r>CgKkc@-HY)RriL<;f+U}62cXIA2I=2;EpW6YYZHmmKRk)R`ZOsuB*+e|( qY`XQ$7EUtyslzQI06`Itw>G2U3|B3qJG>4&{oe{YJX}30I~h72#wopEO5?EVYHwaDb65M)!CR*< z9gb4mW#r{_fM@!LBKHkbsw+DcJj9b-cSmb=9DH(1X(HpbxFC&td}aZGk&>Psjf@N~ XpT)8tEoFEQw41@x)z4*}Q$iB}no2*M From fe62189019f0ec704396d797d223706eb8b111eb Mon Sep 17 00:00:00 2001 From: AFCMS Date: Fri, 13 Aug 2021 11:35:18 +0200 Subject: [PATCH 56/74] Update French translation (part 1) --- mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr | 5 +++-- .../mcl_minecarts/locale/mcl_minecarts.fr.tr | 1 + mods/ENTITIES/mobs_mc/locale/template.txt | 1 + mods/HELP/doc/doc_items/locale/doc_items.fr.tr | 2 +- mods/HUD/mcl_credits/locale/mcl_credits.de.tr | 1 + mods/HUD/mcl_credits/locale/mcl_credits.es.tr | 14 ++++++++++++++ mods/HUD/mcl_credits/locale/mcl_credits.fr.tr | 14 ++++++++++++++ mods/HUD/mcl_credits/locale/mcl_credits.pl.tr | 14 ++++++++++++++ mods/HUD/mcl_credits/locale/mcl_credits.ru.tr | 14 ++++++++++++++ mods/ITEMS/mcl_chests/init.lua | 2 +- mods/ITEMS/mcl_chests/locale/template.txt | 2 +- .../ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr | 3 +++ .../ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr | 3 +++ .../ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr | 3 +++ mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr | 5 ++++- 15 files changed, 78 insertions(+), 6 deletions(-) create mode 100644 mods/HUD/mcl_credits/locale/mcl_credits.es.tr create mode 100644 mods/HUD/mcl_credits/locale/mcl_credits.fr.tr create mode 100644 mods/HUD/mcl_credits/locale/mcl_credits.pl.tr create mode 100644 mods/HUD/mcl_credits/locale/mcl_credits.ru.tr create mode 100644 mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr create mode 100644 mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr create mode 100644 mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr diff --git a/mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr b/mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr index 04d6d9da92..785d50146c 100644 --- a/mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr +++ b/mods/ENTITIES/mcl_boats/locale/mcl_boats.fr.tr @@ -6,6 +6,7 @@ Boats are used to travel on the surface of water.=Les bateaux sont utilisés pou Dark Oak Boat=Bateau en Chêne Noir Jungle Boat=Bateau en Acajou Oak Boat=Bateau en Chêne -Rightclick on a water source to place the boat. Rightclick the boat to enter it. Use [Left] and [Right] to steer, [Forwards] to speed up and [Backwards] to slow down or move backwards. Rightclick the boat again to leave it, punch the boat to make it drop as an item.=Faites un clic droit sur une source d'eau pour placer le bateau. Faites un clic droit sur le bateau pour y entrer. Utilisez [Gauche] et [Droite] pour diriger, [Avant] pour accélérer et [Arrière] pour ralentir ou reculer. Cliquez de nouveau avec le bouton droit sur le bateau pour le quitter, frappez le bateau pour le faire tomber en tant qu'objet. +Rightclick on a water source to place the boat. Rightclick the boat to enter it. Use [Left] and [Right] to steer, [Forwards] to speed up and [Backwards] to slow down or move backwards. Use [Sneak] to leave the boat, punch the boat to make it drop as an item.=Faites un clic droit sur une source d'eau pour placer le bateau. Faites un clic droit sur le bateau pour y entrer. Utilisez [Gauche] et [Droite] pour diriger, [Avant] pour accélérer et [Arrière] pour ralentir ou reculer. Utilisez [Sneak] pour le quitter, frappez le bateau pour le faire tomber en tant qu'objet. Spruce Boat=Bateau en Sapin -Water vehicle=Véhicule aquatique \ No newline at end of file +Water vehicle=Véhicule aquatique +Sneak to dismount= \ No newline at end of file diff --git a/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.fr.tr b/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.fr.tr index 39cdfd0137..67ed5eb1b0 100644 --- a/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.fr.tr +++ b/mods/ENTITIES/mcl_minecarts/locale/mcl_minecarts.fr.tr @@ -33,3 +33,4 @@ Activates minecarts when powered=Active les wagonnets lorsqu'il est alimenté Emits redstone power when a minecart is detected=Émet de l'énergie redstone lorsqu'un wagonnet est détecté Vehicle for fast travel on rails=Véhicule pour voyager rapidement sur rails Can be ignited by tools or powered activator rail=Peut être allumé par des outils ou un rail d'activation motorisé +Sneak to dismount= \ No newline at end of file diff --git a/mods/ENTITIES/mobs_mc/locale/template.txt b/mods/ENTITIES/mobs_mc/locale/template.txt index 04ba9e4658..7b55c1b89e 100644 --- a/mods/ENTITIES/mobs_mc/locale/template.txt +++ b/mods/ENTITIES/mobs_mc/locale/template.txt @@ -28,6 +28,7 @@ Pig= Polar Bear= Rabbit= Killer Bunny= +The Killer Bunny= Sheep= Shulker= Silverfish= diff --git a/mods/HELP/doc/doc_items/locale/doc_items.fr.tr b/mods/HELP/doc/doc_items/locale/doc_items.fr.tr index 5d655404d3..824ceeeba2 100644 --- a/mods/HELP/doc/doc_items/locale/doc_items.fr.tr +++ b/mods/HELP/doc/doc_items/locale/doc_items.fr.tr @@ -2,7 +2,7 @@ Using it as fuel turns it into: @1.=L'utiliser comme combustible le transforme en : @1. @1 seconds=@1 secondes # Item count times item name -%@1×@2=%@1×@ +@1×@2=@1×@ # Itemname (25%) @1 (@2%)=@1 (@2%) # Itemname (<0.5%) diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.de.tr b/mods/HUD/mcl_credits/locale/mcl_credits.de.tr index 6a38d18e62..fa26f5bc4a 100644 --- a/mods/HUD/mcl_credits/locale/mcl_credits.de.tr +++ b/mods/HUD/mcl_credits/locale/mcl_credits.de.tr @@ -7,6 +7,7 @@ Creator of MineClone2=Schöpfer von MineClone2 Developers=Entwickler Jump to speed up (additionally sprint)=Springen, um zu beschleunigen (zusätzlich sprinten) Maintainers=Betreuer +MineClone5=MineClone5 Original Mod Authors=Original-Mod-Autoren Sneak to skip=Schleichen zum Überspringen Textures=Texturen diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.es.tr b/mods/HUD/mcl_credits/locale/mcl_credits.es.tr new file mode 100644 index 0000000000..a8886286e7 --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.es.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models= +A faithful Open Source clone of Minecraft= +Contributors= +Creator of MineClone= +Creator of MineClone2= +Developers= +Jump to speed up (additionally sprint)= +Maintainers= +MineClone5= +Original Mod Authors= +Sneak to skip= +Textures= +Translations= \ No newline at end of file diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.fr.tr b/mods/HUD/mcl_credits/locale/mcl_credits.fr.tr new file mode 100644 index 0000000000..b34249eff1 --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.fr.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models=Modèles 3D +A faithful Open Source clone of Minecraft=Un clone open source de Minecraft +Contributors=Contributeurs +Creator of MineClone=Créateur de MineClone +Creator of MineClone2=Créateur de MineClone2 +Developers=Développeurs +Jump to speed up (additionally sprint)=Saut pour accélérer (peut être combiné avec sprint) +Maintainers=Mainteneurs +MineClone5=MineClone5 +Original Mod Authors=Auteurs des mods originaux +Sneak to skip=Shift pour passer +Textures=Textures +Translations=Traductions \ No newline at end of file diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.pl.tr b/mods/HUD/mcl_credits/locale/mcl_credits.pl.tr new file mode 100644 index 0000000000..a8886286e7 --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.pl.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models= +A faithful Open Source clone of Minecraft= +Contributors= +Creator of MineClone= +Creator of MineClone2= +Developers= +Jump to speed up (additionally sprint)= +Maintainers= +MineClone5= +Original Mod Authors= +Sneak to skip= +Textures= +Translations= \ No newline at end of file diff --git a/mods/HUD/mcl_credits/locale/mcl_credits.ru.tr b/mods/HUD/mcl_credits/locale/mcl_credits.ru.tr new file mode 100644 index 0000000000..a8886286e7 --- /dev/null +++ b/mods/HUD/mcl_credits/locale/mcl_credits.ru.tr @@ -0,0 +1,14 @@ +# textdomain: mcl_credits +3D Models= +A faithful Open Source clone of Minecraft= +Contributors= +Creator of MineClone= +Creator of MineClone2= +Developers= +Jump to speed up (additionally sprint)= +Maintainers= +MineClone5= +Original Mod Authors= +Sneak to skip= +Textures= +Translations= \ No newline at end of file diff --git a/mods/ITEMS/mcl_chests/init.lua b/mods/ITEMS/mcl_chests/init.lua index cd66c3fc40..69f6a601da 100644 --- a/mods/ITEMS/mcl_chests/init.lua +++ b/mods/ITEMS/mcl_chests/init.lua @@ -1133,7 +1133,7 @@ for color, desc in pairs(boxtypes) do if mod_doc then if is_canonical then longdesc = S("A shulker box is a portable container which provides 27 inventory slots for any item except shulker boxes. Shulker boxes keep their inventory when broken, so shulker boxes as well as their contents can be taken as a single item. Shulker boxes come in many different colors.") - usagehelp = S("To access the inventory of a shulker box, place and right-click it. To take a shulker box and its contents with you, just break and collect it, the items will not fall out.") + usagehelp = S("To access the inventory of a shulker box, place and right-click it. To take a shulker box and its contents with you, just break and collect it, the items will not fall out. Place the shulker box again to be able to retrieve its contents.") entry_name = S("Shulker Box") else create_entry = false diff --git a/mods/ITEMS/mcl_chests/locale/template.txt b/mods/ITEMS/mcl_chests/locale/template.txt index 1d947184b1..d680c24c9d 100644 --- a/mods/ITEMS/mcl_chests/locale/template.txt +++ b/mods/ITEMS/mcl_chests/locale/template.txt @@ -24,7 +24,7 @@ Red Shulker Box= Grey Shulker Box= Black Shulker Box= A shulker box is a portable container which provides 27 inventory slots for any item except shulker boxes. Shulker boxes keep their inventory when broken, so shulker boxes as well as their contents can be taken as a single item. Shulker boxes come in many different colors.= -To access the inventory of a shulker box, place and right-click it. To take a shulker box and its contents with you, just break and collect it, the items will not fall out.= +To access the inventory of a shulker box, place and right-click it. To take a shulker box and its contents with you, just break and collect it, the items will not fall out. Place the shulker box again to be able to retrieve its contents.= Shulker Box= Large Chest= Inventory= diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr new file mode 100644 index 0000000000..e66eb06a59 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.es.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_fireworks +Firework Rocket= +Flight Duration:= \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr new file mode 100644 index 0000000000..b02faa4285 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.fr.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_fireworks +Firework Rocket=Fusée +Flight Duration:=Durée de vol : \ No newline at end of file diff --git a/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr new file mode 100644 index 0000000000..e66eb06a59 --- /dev/null +++ b/mods/ITEMS/mcl_fireworks/locale/mcl_fireworks.ru.tr @@ -0,0 +1,3 @@ +# textdomain: mcl_fireworks +Firework Rocket= +Flight Duration:= \ No newline at end of file diff --git a/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr b/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr index 9ef7cd5c50..1808e839d3 100644 --- a/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr +++ b/mods/ITEMS/mcl_maps/locale/mcl_maps.fr.tr @@ -1,5 +1,8 @@ # textdomain: mcl_maps Empty Map=Carte Vierge Empty maps are not useful as maps, but they can be stacked and turned to maps which can be used.=Les cartes vierges ne sont pas utiles en tant que cartes, mais elles peuvent être empilées et transformées en cartes utilisables. -Rightclick to start using the map (which can't be stacked anymore).=Clic droit pour commencer à utiliser la carte (qui ne peut plus être empilée). +Rightclick to create a filled map (which can't be stacked anymore).=Clic droit pour créer une carte remplie (qui ne peut plus être empilée). Map=Carte +Shows a map image.=Affiche une carte. +When created, the map saves the nearby area as an image that can be viewed any time by holding the map.=Lors de sa création, la carte sauvegarde le terrain proche sous forme d'image qui peut être consultée n'importe quand en tenant la carte dans la main. +Hold the map in your hand. This will display a map on your screen.=Tenez la carte dans votre main. Cela affichera la carte à l'écran. From 58a292a4f3edcf6816936b89a6b32275fb785299 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 16 Aug 2021 13:48:08 +0200 Subject: [PATCH 57/74] fix inconsistency --- mods/HUD/mcl_title/init.lua | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index d1dbece4b4..ffdc456391 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -36,7 +36,11 @@ local string = string local pairs = pairs local function gametick_to_secondes(gametick) - return gametick / 20 + if gametick then + return gametick / 20 + else + return nil + end end @@ -46,9 +50,9 @@ local player_params = {} minetest.register_on_joinplayer(function(player) local playername = player:get_player_name() player_params[player] = { - stay = gametick_to_secondes(mcl_title.defaults.stay), - --fadeIn = gametick_to_secondes(mcl_title.defaults.fadein), - --fadeOut = gametick_to_secondes(mcl_title.defaults.fadeout), + stay = mcl_title.defaults.stay, + --fadeIn = mcl_title.defaults.fadein, + --fadeOut = mcl_title.defaults.fadeout, } local _, hex_color = get_color("white") huds_idx.title[player] = player:hud_add({ @@ -106,9 +110,9 @@ end) function mcl_title.params_set(player, data) player_params[player] = { - stay = gametick_to_secondes(data.stay) or gametick_to_secondes(mcl_title.defaults.stay), - --fadeIn = gametick_to_secondes(data.fadeIn) or gametick_to_secondes(mcl_title.defaults.fadein), - --fadeOut = gametick_to_secondes(data.fadeOut) or gametick_to_secondes(mcl_title.defaults.fadeout), + stay = data.stay or mcl_title.defaults.stay, + --fadeIn = data.fadeIn or mcl_title.defaults.fadein, + --fadeOut = data.fadeOut or mcl_title.defaults.fadeout, } end @@ -134,7 +138,7 @@ function mcl_title.set(player, type, data) player:hud_change(huds_idx[type][player], "text", data.text) player:hud_change(huds_idx[type][player], "number", hex_color) - hud_hide_timeouts[type][player:get_player_name()] = gametick_to_secondes(data.stay) or mcl_title.params_get(player).stay + hud_hide_timeouts[type][player:get_player_name()] = gametick_to_secondes(data.stay) or gametick_to_secondes(mcl_title.params_get(player).stay) return true end From 40898d3e9dfeb492ecaca2621308c8c125ef5471 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Mon, 16 Aug 2021 14:19:50 +0200 Subject: [PATCH 58/74] WIP bold and italic support --- mods/HUD/mcl_title/init.lua | 38 +++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index ffdc456391..933158d20b 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -43,6 +43,23 @@ local function gametick_to_secondes(gametick) end end +--https://github.com/minetest/minetest/blob/b3b075ea02034306256b486dd45410aa765f035a/doc/lua_api.txt#L8477 + +local function style_to_bits(bold, italic) + if bold then + if italic then + return 3 + else + return 1 + end + else + if italic then + return 2 + else + return 0 + end + end +end --PARAMS SYSTEM local player_params = {} @@ -60,8 +77,7 @@ minetest.register_on_joinplayer(function(player) position = mcl_title.layout.title.position, alignment = mcl_title.layout.title.alignment, text = "", - --bold = data.bold, - --italic = data.italic, + style = 0, size = {x = mcl_title.layout.title.size}, number = hex_color, z_index = 100, @@ -71,8 +87,7 @@ minetest.register_on_joinplayer(function(player) position = mcl_title.layout.subtitle.position, alignment = mcl_title.layout.subtitle.alignment, text = "", - --bold = data.bold, - --italic = data.italic, + style = 0, size = {x = mcl_title.layout.subtitle.size}, number = hex_color, z_index = 100, @@ -82,8 +97,7 @@ minetest.register_on_joinplayer(function(player) position = mcl_title.layout.actionbar.position, offset = {x = 0, y = -210}, alignment = mcl_title.layout.actionbar.alignment, - --bold = data.bold, - --italic = data.italic, + style = 0, text = "", size = {x = mcl_title.layout.actionbar.size}, number = hex_color, @@ -131,13 +145,12 @@ function mcl_title.set(player, type, data) return false end - --TODO: enable this code then Fleckenstein's pr get merged (in about 5-6 years lol) - - --if data.bold == nil then data.bold = false end - --if data.italic == nil then data.italic = false end - player:hud_change(huds_idx[type][player], "text", data.text) player:hud_change(huds_idx[type][player], "number", hex_color) + + --apply bold and italic + player:hud_change(huds_idx[type][player], "style", style_to_bits(data.bold, data.italic)) + hud_hide_timeouts[type][player:get_player_name()] = gametick_to_secondes(data.stay) or gametick_to_secondes(mcl_title.params_get(player).stay) return true end @@ -145,6 +158,7 @@ end function mcl_title.remove(player, type) if player then player:hud_change(huds_idx[type][player], "text", "") + player:hud_change(huds_idx[type][player], "style", 0) --no styling end end @@ -184,7 +198,7 @@ end) minetest.register_chatcommand("title", { func = function(name, param) local player = minetest.get_player_by_name(name) - mcl_title.set(player, "title", {text=param, color="gold"}) + mcl_title.set(player, "title", {text=param, color="gold", bold=true, italic=true}) end, }) From df4b8e64cc153ba70457a199661e1e6e92e30bf9 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Thu, 19 Aug 2021 19:21:33 +0200 Subject: [PATCH 59/74] finish `mcl_title` API + doc --- mods/HUD/mcl_title/API.md | 8 ++++++ mods/HUD/mcl_title/init.lua | 28 +++++++++++--------- mods/HUD/mcl_tmp_message/API.md | 7 ----- mods/HUD/mcl_tmp_message/init.lua | 44 ------------------------------- mods/HUD/mcl_tmp_message/mod.conf | 3 --- 5 files changed, 23 insertions(+), 67 deletions(-) delete mode 100644 mods/HUD/mcl_tmp_message/API.md delete mode 100644 mods/HUD/mcl_tmp_message/init.lua delete mode 100644 mods/HUD/mcl_tmp_message/mod.conf diff --git a/mods/HUD/mcl_title/API.md b/mods/HUD/mcl_title/API.md index 50614be4f1..97d75ece83 100644 --- a/mods/HUD/mcl_title/API.md +++ b/mods/HUD/mcl_title/API.md @@ -39,4 +39,12 @@ Allow mods to set `stay` and upcomming `fadeIn`/`fadeOut` params. ```lua mcl_title.params_set(player, {stay = 600}) --elements with no 'data.stay' field will stay during 30s (600/20) +``` + +## mcl_title.params_get(player) + +Get `stay` and upcomming `fadeIn` and `fadeOut` params of a player as a table. + +```lua +mcl_title.params_get(player) ``` \ No newline at end of file diff --git a/mods/HUD/mcl_title/init.lua b/mods/HUD/mcl_title/init.lua index 933158d20b..2ea1571c82 100644 --- a/mods/HUD/mcl_title/init.lua +++ b/mods/HUD/mcl_title/init.lua @@ -32,7 +32,7 @@ mcl_title.layout.actionbar = {position = {x = 0.5, y = 1}, alignment = {x = 0, y local get_color = mcl_util.get_color -local string = string +--local string = string local pairs = pairs local function gametick_to_secondes(gametick) @@ -44,7 +44,7 @@ local function gametick_to_secondes(gametick) end --https://github.com/minetest/minetest/blob/b3b075ea02034306256b486dd45410aa765f035a/doc/lua_api.txt#L8477 - +--[[ local function style_to_bits(bold, italic) if bold then if italic then @@ -60,24 +60,25 @@ local function style_to_bits(bold, italic) end end end +]] --PARAMS SYSTEM local player_params = {} minetest.register_on_joinplayer(function(player) - local playername = player:get_player_name() + --local playername = player:get_player_name() player_params[player] = { stay = mcl_title.defaults.stay, --fadeIn = mcl_title.defaults.fadein, --fadeOut = mcl_title.defaults.fadeout, } - local _, hex_color = get_color("white") + local _, hex_color = get_color("white") huds_idx.title[player] = player:hud_add({ hud_elem_type = "text", position = mcl_title.layout.title.position, alignment = mcl_title.layout.title.alignment, text = "", - style = 0, + --style = 0, size = {x = mcl_title.layout.title.size}, number = hex_color, z_index = 100, @@ -87,7 +88,7 @@ minetest.register_on_joinplayer(function(player) position = mcl_title.layout.subtitle.position, alignment = mcl_title.layout.subtitle.alignment, text = "", - style = 0, + --style = 0, size = {x = mcl_title.layout.subtitle.size}, number = hex_color, z_index = 100, @@ -97,7 +98,7 @@ minetest.register_on_joinplayer(function(player) position = mcl_title.layout.actionbar.position, offset = {x = 0, y = -210}, alignment = mcl_title.layout.actionbar.alignment, - style = 0, + --style = 0, text = "", size = {x = mcl_title.layout.actionbar.size}, number = hex_color, @@ -116,7 +117,7 @@ minetest.register_on_leaveplayer(function(player) huds_idx.subtitle[player] = nil huds_idx.actionbar[player] = nil - --remove timers form list + --remove timers from list hud_hide_timeouts.title[playername] = nil hud_hide_timeouts.subtitle[playername] = nil hud_hide_timeouts.actionbar[playername] = nil @@ -149,7 +150,7 @@ function mcl_title.set(player, type, data) player:hud_change(huds_idx[type][player], "number", hex_color) --apply bold and italic - player:hud_change(huds_idx[type][player], "style", style_to_bits(data.bold, data.italic)) + --player:hud_change(huds_idx[type][player], "style", style_to_bits(data.bold, data.italic)) hud_hide_timeouts[type][player:get_player_name()] = gametick_to_secondes(data.stay) or gametick_to_secondes(mcl_title.params_get(player).stay) return true @@ -158,7 +159,7 @@ end function mcl_title.remove(player, type) if player then player:hud_change(huds_idx[type][player], "text", "") - player:hud_change(huds_idx[type][player], "style", 0) --no styling + --player:hud_change(huds_idx[type][player], "style", 0) --no styling end end @@ -193,8 +194,8 @@ minetest.register_globalstep(function(dtime) end) ---TEMP STUFF!! ---TODO: remove then testing/tweaking done +--DEBUG STUFF!! +--[[ minetest.register_chatcommand("title", { func = function(name, param) local player = minetest.get_player_by_name(name) @@ -231,4 +232,5 @@ minetest.register_chatcommand("all", { mcl_title.set(player, "subtitle", {text=param, color="gold"}) mcl_title.set(player, "actionbar", {text=param, color="gold"}) end, -}) \ No newline at end of file +}) +]] \ No newline at end of file diff --git a/mods/HUD/mcl_tmp_message/API.md b/mods/HUD/mcl_tmp_message/API.md deleted file mode 100644 index 0a3fc06a33..0000000000 --- a/mods/HUD/mcl_tmp_message/API.md +++ /dev/null @@ -1,7 +0,0 @@ -# mcl_temp_message - -Allow mods to show short messages in the hud of players. - -## mcl_tmp_message.message(player, message) - -Show above the hotbar a hud message to player . \ No newline at end of file diff --git a/mods/HUD/mcl_tmp_message/init.lua b/mods/HUD/mcl_tmp_message/init.lua deleted file mode 100644 index 1456cd5922..0000000000 --- a/mods/HUD/mcl_tmp_message/init.lua +++ /dev/null @@ -1,44 +0,0 @@ -mcl_tmp_message = {} - -local huds = {} -local hud_hide_timeouts = {} - -function mcl_tmp_message.message(player, message) - local name = player:get_player_name() - player:hud_change(huds[name], "text", message) - hud_hide_timeouts[name] = 3 -end - -minetest.register_on_joinplayer(function(player) - huds[player:get_player_name()] = player:hud_add({ - hud_elem_type = "text", - position = {x=0.5, y=1}, - offset = {x = 0, y = -210}, - alignment = {x=0, y=0}, - number = 0xFFFFFF , - text = "", - z_index = 100, - }) -end) - -minetest.register_on_leaveplayer(function(player) - local name = player:get_player_name() - huds[name] = nil - hud_hide_timeouts[name] = nil -end) - -minetest.register_globalstep(function(dtime) - local new_timeouts = {} - for name, timeout in pairs(hud_hide_timeouts) do - timeout = timeout - dtime - if timeout <= 0 then - local player = minetest.get_player_by_name(name) - if player then - player:hud_change(huds[name], "text", "") - end - else - new_timeouts[name] = timeout - end - end - hud_hide_timeouts = new_timeouts -end) diff --git a/mods/HUD/mcl_tmp_message/mod.conf b/mods/HUD/mcl_tmp_message/mod.conf deleted file mode 100644 index ad453643e8..0000000000 --- a/mods/HUD/mcl_tmp_message/mod.conf +++ /dev/null @@ -1,3 +0,0 @@ -name = mcl_tmp_message -author = Fleckenstein -description = A simple API to show a temporary message to a player From af8e88f44cad6465e91530b0f87e8588e885cff3 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 24 Aug 2021 08:25:42 +0200 Subject: [PATCH 60/74] fix error in `mcl_title` documentation --- mods/HUD/mcl_title/API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/HUD/mcl_title/API.md b/mods/HUD/mcl_title/API.md index 97d75ece83..37f1c279f5 100644 --- a/mods/HUD/mcl_title/API.md +++ b/mods/HUD/mcl_title/API.md @@ -21,7 +21,7 @@ mcl_title.set(player, "subtitle", {text="dummy subtitle", color="#612D2D"}) mcl_title.set(player, "subtitle", {text="dummy actionbar", color="red"}) --show a title in the HUD with minecraft color "gold" staying for 3 seconds (override stay setting) -mcl_title.set(player, "title", {text="dummy text", color="gold", stay=3}) +mcl_title.set(player, "title", {text="dummy text", color="gold", stay=60}) ``` ## mcl_title.remove(player, type) From f0af15fcd8006a66ce91ba3efbf77c24a8e8ffca Mon Sep 17 00:00:00 2001 From: NO11 Date: Thu, 26 Aug 2021 10:14:57 +0000 Subject: [PATCH 61/74] Make anvil selection/collision box more MC like --- mods/ITEMS/mcl_anvils/init.lua | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index 51b78da6fe..e1685c60e9 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -284,6 +284,12 @@ local function damage_anvil_by_falling(pos, distance) end end +local anvilbox = { + type = "fixed", + fixed = { + { -8 / 16, -8 / 16, -6 / 16, 8 / 16, 8 / 16, 6 / 16 }, + }, +} local anvildef = { groups = {pickaxey=1, falling_node=1, falling_node_damage=1, crush_after_fall=1, deco_block=1, anvil=1}, tiles = {"mcl_anvils_anvil_top_damaged_0.png^[transformR90", "mcl_anvils_anvil_base.png", "mcl_anvils_anvil_side.png"}, @@ -297,12 +303,14 @@ local anvildef = { node_box = { type = "fixed", fixed = { - { -6/16, -8/16, -6/16, 6/16, -4/16, 6/16 }, - { -5/16, -4/16, -4/16, 5/16, -3/16, 4/16 }, - { -4/16, -3/16, -2/16, 4/16, 2/16, 2/16 }, - { -8/16, 2/16, -5/16, 8/16, 8/16, 5/16 }, + { -6 / 16, -8 / 16, -6 / 16, 6 / 16, -4 / 16, 6 / 16 }, + { -5 / 16, -4 / 16, -4 / 16, 5 / 16, -3 / 16, 4 / 16 }, + { -4 / 16, -3 / 16, -2 / 16, 4 / 16, 2 / 16, 2 / 16 }, + { -8 / 16, 2 / 16, -5 / 16, 8 / 16, 8 / 16, 5 / 16 }, } }, + selection_box = anvilbox, + collision_box = anvilbox, sounds = mcl_sounds.node_sound_metal_defaults(), _mcl_blast_resistance = 1200, _mcl_hardness = 5, From ca086109bf17787e3a7b075ceb07ccb82810a3bb Mon Sep 17 00:00:00 2001 From: NO11 Date: Tue, 31 Aug 2021 21:04:57 +0000 Subject: [PATCH 62/74] support tables for `_repair_material` --- mods/ITEMS/mcl_anvils/init.lua | 44 +++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/mods/ITEMS/mcl_anvils/init.lua b/mods/ITEMS/mcl_anvils/init.lua index e1685c60e9..d3b32b8449 100644 --- a/mods/ITEMS/mcl_anvils/init.lua +++ b/mods/ITEMS/mcl_anvils/init.lua @@ -53,6 +53,15 @@ local function get_consumed_materials(tool, material) return materials_used end +local function contains(table, value) + for _, i in pairs(table) do + if i == value then + return true + end + end + return false +end + -- Given 2 input stacks, tells you which is the tool and which is the material. -- Returns ("tool", input1, input2) if input1 is tool and input2 is material. -- Returns ("material", input2, input1) if input1 is material and input2 is tool. @@ -60,9 +69,15 @@ end local function distinguish_tool_and_material(input1, input2) local def1 = input1:get_definition() local def2 = input2:get_definition() - if def1.type == "tool" and def1._repair_material then + local r1 = def1._repair_material + local r2 = def2._repair_material + if def1.type == "tool" and r1 and type(r1) == "table" and contains(r1, input2) then return "tool", input1, input2 - elseif def2.type == "tool" and def2._repair_material then + elseif def2.type == "tool" and r2 and type(r2) == "table" and contains(r2, input1) then + return "material", input2, input1 + elseif def1.type == "tool" and r1 then + return "tool", input1, input2 + elseif def2.type == "tool" and r2 then return "material", input2, input1 else return nil @@ -121,11 +136,28 @@ local function update_anvil_slots(meta) local distinguished, tool, material = distinguish_tool_and_material(input1, input2) if distinguished then local tooldef = tool:get_definition() + local repair = tooldef._repair_material local has_correct_material = false - if string.sub(tooldef._repair_material, 1, 6) == "group:" then - has_correct_material = minetest.get_item_group(material:get_name(), string.sub(tooldef._repair_material, 7)) ~= 0 - elseif material:get_name() == tooldef._repair_material then - has_correct_material = true + local material_name = material:get_name() + if type(repair) == "string" then + if string.sub(repair, 1, 6) == "group:" then + has_correct_material = minetest.get_item_group(material_name, string.sub(repair, 7)) ~= 0 + elseif material_name == repair then + has_correct_material = true + end + else + if contains(repair, material_name) then + has_correct_material = true + else + for _, r in pairs(repair) do + if string.sub(r, 1, 6) == "group:" then + if minetest.get_item_group(material_name, string.sub(r, 7)) ~= 0 then + has_correct_material = true + end + + end + end + end end if has_correct_material and tool:get_wear() > 0 then local materials_used = get_consumed_materials(tool, material) From 0da7b3fbda988d11ee79a03ca3c2719d6906e20f Mon Sep 17 00:00:00 2001 From: NO11 Date: Thu, 2 Sep 2021 20:38:01 +0000 Subject: [PATCH 63/74] Make cactus mechanisms more MC like (Fix #1741) --- mods/ITEMS/mcl_core/functions.lua | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index eceb81c514..af4821c90b 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -184,6 +184,7 @@ minetest.register_abm({ end, }) +-- Cactus mechanisms minetest.register_abm({ label = "Cactus growth", nodenames = {"mcl_core:cactus"}, @@ -195,19 +196,31 @@ minetest.register_abm({ end, }) --- Make cactus destroy items minetest.register_abm({ label = "Cactus destroy items", nodenames = {"mcl_core:cactus"}, interval = 1, chance = 1, action = function(pos, node, active_object_count, active_object_count_wider) - for _,object in pairs(minetest.get_objects_inside_radius(pos, 0.9)) do + for _, object in pairs(minetest.get_objects_inside_radius(pos, 0.9)) do local entity = object:get_luaentity() if entity and entity.name == "__builtin:item" then object:remove() end end + local posses = { { 1, 0 }, { -1, 0 }, { 0, 1 }, { 0, -1 } } + for _, p in pairs(posses) do + if minetest.registered_nodes[minetest.get_node(vector.new(pos.x + p[1], pos.y, pos.z + p[2])).name].walkable then + local posy = pos.y + while minetest.get_node(vector.new(pos.x, posy, pos.z)).name == "mcl_core:cactus" do + local pos = vector.new(pos.x, posy, pos.z) + minetest.remove_node(pos) + minetest.add_item(vector.offset(pos, math.random(-0.5, 0.5), 0, math.random(-0.5, 0.5)), "mcl_core:cactus") + posy = posy + 1 + end + break + end + end end, }) From bf62eb33fa97cc345fcab2515b2360cd18b80fbf Mon Sep 17 00:00:00 2001 From: NO11 Date: Fri, 3 Sep 2021 14:06:21 +0000 Subject: [PATCH 64/74] Change label of cactus abm --- mods/ITEMS/mcl_core/functions.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_core/functions.lua b/mods/ITEMS/mcl_core/functions.lua index af4821c90b..2ef73af729 100644 --- a/mods/ITEMS/mcl_core/functions.lua +++ b/mods/ITEMS/mcl_core/functions.lua @@ -197,7 +197,7 @@ minetest.register_abm({ }) minetest.register_abm({ - label = "Cactus destroy items", + label = "Cactus mechanisms", nodenames = {"mcl_core:cactus"}, interval = 1, chance = 1, From 5fedd914fb110aa8adeed1c3fe633a2c9e25c9e7 Mon Sep 17 00:00:00 2001 From: NO11 Date: Sat, 4 Sep 2021 19:14:08 +0000 Subject: [PATCH 65/74] Fix strange behaviour when filling end portal with bedrock inside (#1749) --- mods/ITEMS/mcl_portals/portal_end.lua | 4 ---- 1 file changed, 4 deletions(-) diff --git a/mods/ITEMS/mcl_portals/portal_end.lua b/mods/ITEMS/mcl_portals/portal_end.lua index 9f0db352a8..e4982c39b7 100644 --- a/mods/ITEMS/mcl_portals/portal_end.lua +++ b/mods/ITEMS/mcl_portals/portal_end.lua @@ -391,7 +391,3 @@ minetest.override_item("mcl_end:ender_eye", { return itemstack end, }) -minetest.override_item("mcl_core:bedrock", { - after_destruct = destroy_portal, -}) - From f41cea71fd61473090cd04ac8f206f56b9cd3410 Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 6 Sep 2021 13:30:08 +0000 Subject: [PATCH 66/74] Make it possible to use shears in the dispenser for mobs (Fix #1233) --- mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 53 +++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 7c2c073939..62ed2dc718 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -168,6 +168,59 @@ local dispenserdef = { end inv:set_stack("main", stack_id, stack) + + -- Use shears on sheeps + elseif igroups.shears then + for _, obj in pairs(minetest.get_objects_inside_radius(droppos, 1)) do + local entity = obj:get_luaentity() + if entity and not entity.child and not entity.gotten then + local entname = entity.name + local pos = obj:get_pos() + local used, texture = false + if entname == "mobs_mc:sheep" then + minetest.add_item(pos, entity.drops[2].name .. " " .. math.random(1, 3)) + if not entity.color then + entity.color = "unicolor_white" + end + entity.base_texture = { "blank.png", "mobs_mc_sheep.png" } + texture = entity.base_texture + entity.drops = { + { name = mobs_mc.items.mutton_raw, chance = 1, min = 1, max = 2 }, + } + used = true + elseif entname == "mobs_mc:snowman" then + texture = { + "mobs_mc_snowman.png", + "blank.png", "blank.png", + "blank.png", "blank.png", + "blank.png", "blank.png", + } + used = true + elseif entname == "mobs_mc:mooshroom" then + local droppos = vector.offset(pos, 0, 1.4, 0) + if entity.base_texture[1] == "mobs_mc_mooshroom_brown.png" then + minetest.add_item(droppos, mobs_mc.items.mushroom_brown .. " 5") + else + minetest.add_item(droppos, mobs_mc.items.mushroom_red .. " 5") + end + local oldyaw = obj:get_yaw() + obj:remove() + local cow = minetest.add_entity(pos, "mobs_mc:cow") + cow:set_yaw(oldyaw) + obj = cow + entity = cow:get_luaentity() + used = true + end + if used then + obj:set_properties({ textures = texture }) + entity.gotten = true + minetest.sound_play("mcl_tools_shears_cut", { pos = pos }, true) + stack:add_wear(65535 / stackdef._mcl_diggroups.shearsy.uses) + inv:set_stack("main", stack_id, stack) + end + end + end + -- Spawn Egg elseif igroups.spawn_egg then -- Spawn mob From dc8436fdf95afe224437d5fa6e3c883fa322f2a6 Mon Sep 17 00:00:00 2001 From: NO11 Date: Mon, 6 Sep 2021 14:34:25 +0000 Subject: [PATCH 67/74] Destroy objects near cactus faster (make it possible to throw items at a cactus) --- mods/ENTITIES/mcl_item_entity/init.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index ab1ac57525..7869b9d797 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -575,7 +575,7 @@ minetest.register_entity(":__builtin:item", { return true end, - on_step = function(self, dtime) + on_step = function(self, dtime, moveresult) if self._removed then self.object:set_properties({ physical = false @@ -642,6 +642,18 @@ minetest.register_entity(":__builtin:item", { end end + -- Destroy item when it collides with a cactus + if moveresult and moveresult.collides then + for _, collision in pairs(moveresult.collisions) do + local pos = collision.node_pos + if collision.type == "node" and minetest.get_node(pos).name == "mcl_core:cactus" then + self._removed = true + self.object:remove() + return + end + end + end + -- Push item out when stuck inside solid opaque node if def and def.walkable and def.groups and def.groups.opaque == 1 then local shootdir From 1a5339e907c1b5d572e2fe38a8b4451bf9bfff43 Mon Sep 17 00:00:00 2001 From: NO11 Date: Wed, 8 Sep 2021 14:22:53 +0000 Subject: [PATCH 68/74] Only use the shears once in dispenser if there are more mobs in front of the dispenser --- mods/ITEMS/REDSTONE/mcl_dispensers/init.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua index 62ed2dc718..82d53c8060 100644 --- a/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua +++ b/mods/ITEMS/REDSTONE/mcl_dispensers/init.lua @@ -217,6 +217,7 @@ local dispenserdef = { minetest.sound_play("mcl_tools_shears_cut", { pos = pos }, true) stack:add_wear(65535 / stackdef._mcl_diggroups.shearsy.uses) inv:set_stack("main", stack_id, stack) + break end end end From 1c192f4fbbee2089ff72912cf369e8591fd4e481 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Thu, 8 Jul 2021 15:34:50 +0200 Subject: [PATCH 69/74] Do not send useless HUDCHANGE packets Several mods set or unset the visibility of a HUD bar way too often (e.g. in a globalstep handler), causing the server to send a lot of superfluous HUDCHANGE packets to each client. Returning from hb.hide_hudbar() early if HUD bar visibility would not change prevents sending these packets. --- mods/HUD/hudbars/init.lua | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mods/HUD/hudbars/init.lua b/mods/HUD/hudbars/init.lua index 08f1914ca0..505ff403b8 100644 --- a/mods/HUD/hudbars/init.lua +++ b/mods/HUD/hudbars/init.lua @@ -425,6 +425,7 @@ function hb.hide_hudbar(player, identifier) local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) if hudtable == nil then return false end + if hudtable.hudstate[name].hidden == true then return true end if hb.settings.bar_type == "progress_bar" then if hudtable.hudids[name].icon then player:hud_change(hudtable.hudids[name].icon, "scale", {x=0,y=0}) @@ -443,6 +444,7 @@ function hb.unhide_hudbar(player, identifier) local name = player:get_player_name() local hudtable = hb.get_hudtable(identifier) if hudtable == nil then return false end + if hudtable.hudstate[name].hidden == false then return true end local value = hudtable.hudstate[name].value local max = hudtable.hudstate[name].max if hb.settings.bar_type == "progress_bar" then From 95c4d6472bc57c056c5116be88d8f99550ec04b6 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Sun, 4 Jul 2021 03:25:05 +0200 Subject: [PATCH 70/74] Send FOV packets only when necessary Before this change, about 10 to 30 FOV packets were sent from the server to each connected client each second. This patch only sends FOV packets when the FOV actually needs to be changed, i.e. when the player starts or stops sprinting. --- mods/PLAYER/mcl_sprint/init.lua | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mods/PLAYER/mcl_sprint/init.lua b/mods/PLAYER/mcl_sprint/init.lua index 73a518c425..4c0d609c96 100644 --- a/mods/PLAYER/mcl_sprint/init.lua +++ b/mods/PLAYER/mcl_sprint/init.lua @@ -69,18 +69,19 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player local controls = player:get_player_control() if players[playerName] then players[playerName].sprinting = sprinting + local fov_old = players[playerName].fov + local fov_new = fov_old + local fade_time = .15 if sprinting == true or controls.RMB and string.find(player:get_wielded_item():get_name(), "mcl_bows:bow") and player:get_wielded_item():get_name() ~= "mcl_bows:bow" then if sprinting == true then - players[playerName].fov = math.min(players[playerName].fov + 0.05, 1.2) - players[playerName].fade_time = .15 + fov_new = math.min(players[playerName].fov + 0.05, 1.2) else - players[playerName].fov = .7 + fov_new = .7 players[playerName].fade_time = .3 end - player:set_fov(players[playerName].fov, true, players[playerName].fade_time) if sprinting == true then playerphysics.add_physics_factor(player, "speed", "mcl_sprint:sprint", mcl_sprint.SPEED) end @@ -88,12 +89,15 @@ local function setSprinting(playerName, sprinting) --Sets the state of a player and player:get_wielded_item():get_name() ~= "mcl_bows:bow_0" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_1" and player:get_wielded_item():get_name() ~= "mcl_bows:bow_2" then - players[playerName].fov = math.max(players[playerName].fov - 0.05, 1.0) - player:set_fov(players[playerName].fov, true, 0.15) + fov_new = math.max(players[playerName].fov - 0.05, 1.0) if sprinting == false then playerphysics.remove_physics_factor(player, "speed", "mcl_sprint:sprint") end end + if fov_new ~= fov_old then + players[playerName].fov = fov_new + player:set_fov(fov_new, true, fade_time) + end return true end return false From 693a5317efd84eeb1141414e0b48930a09bdceec Mon Sep 17 00:00:00 2001 From: sfan5 Date: Wed, 28 Jul 2021 20:44:48 +0200 Subject: [PATCH 71/74] Fix non-serializable item entity unload crash MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some items, like shulkers or books, can have so much metadata that the corresponding item entity can not be serialized by the Minetest engine. Without this patch, dropping such an item and then moving away crashes Minetest, as it can not serialize the entity with serializeString16() when unloading a map block. The patch resets the overlong metadata of non-serializable item entities. This avoids a crash and makes it possible to retrieve a “sanitized” item without metadata when the mapblock containing the item entity is reloaded. Originally sfan5 guessed the maximum possible item entity serialization size that would not lead to a crash as 65530 bytes, but anon5 calculated it to be actually 65487 bytes. This has been experimentally verified by erlehmann. --- mods/ENTITIES/mcl_item_entity/init.lua | 28 +++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 7869b9d797..7a2758ed03 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -480,7 +480,7 @@ minetest.register_entity(":__builtin:item", { end, get_staticdata = function(self) - return minetest.serialize({ + local data = minetest.serialize({ itemstring = self.itemstring, always_collect = self.always_collect, age = self.age, @@ -488,6 +488,32 @@ minetest.register_entity(":__builtin:item", { _flowing = self._flowing, _removed = self._removed, }) + -- sfan5 guessed that the biggest serializable item + -- entity would have a size of 65530 bytes. This has + -- been experimentally verified to be still too large. + -- + -- anon5 has calculated that the biggest serializable + -- item entity has a size of exactly 65487 bytes: + -- + -- 1. serializeString16 can handle max. 65535 bytes. + -- 2. The following engine metadata is always saved: + -- • 1 byte (version) + -- • 2 byte (length prefix) + -- • 14 byte “__builtin:item” + -- • 4 byte (length prefix) + -- • 2 byte (health) + -- • 3 × 4 byte = 12 byte (position) + -- • 4 byte (yaw) + -- • 1 byte (version 2) + -- • 2 × 4 byte = 8 byte (pitch and roll) + -- 3. This leaves 65487 bytes for the serialization. + if #data > 65487 then -- would crash the engine + local stack = ItemStack(self.itemstring) + stack:get_meta():from_table(nil) + self.itemstring = stack:to_string() + return self:get_staticdata() + end + return data end, on_activate = function(self, staticdata, dtime_s) From 256de2bc365466735900dde62c749035ee700843 Mon Sep 17 00:00:00 2001 From: Nils Dagsson Moskopp Date: Thu, 29 Jul 2021 15:46:50 +0200 Subject: [PATCH 72/74] Log warning for non-serializable item entity fix --- mods/ENTITIES/mcl_item_entity/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mods/ENTITIES/mcl_item_entity/init.lua b/mods/ENTITIES/mcl_item_entity/init.lua index 7a2758ed03..cfd141f046 100644 --- a/mods/ENTITIES/mcl_item_entity/init.lua +++ b/mods/ENTITIES/mcl_item_entity/init.lua @@ -511,6 +511,13 @@ minetest.register_entity(":__builtin:item", { local stack = ItemStack(self.itemstring) stack:get_meta():from_table(nil) self.itemstring = stack:to_string() + minetest.log( + "warning", + "Overlong item entity metadata removed: “" .. + self.itemstring .. + "” had serialized length of " .. + #data + ) return self:get_staticdata() end return data From 27e4bd6d09b8a1ea36e9b0120b5aa7b90d16cc5a Mon Sep 17 00:00:00 2001 From: Elias Fleckenstein Date: Sat, 18 Sep 2021 22:28:20 +0200 Subject: [PATCH 73/74] Fix burning entity packet spam - Use upright_sprite for 3rd person flame display, which is both closer to minecraft and allows for client side texture animation - Take care of flame HUD in the MineClone2Client --- mods/ENTITIES/mcl_burning/api.lua | 18 +++-------- mods/ENTITIES/mcl_burning/init.lua | 51 +++++++++++++----------------- 2 files changed, 27 insertions(+), 42 deletions(-) diff --git a/mods/ENTITIES/mcl_burning/api.lua b/mods/ENTITIES/mcl_burning/api.lua index 4cb19cca10..9699852053 100644 --- a/mods/ENTITIES/mcl_burning/api.lua +++ b/mods/ENTITIES/mcl_burning/api.lua @@ -67,14 +67,9 @@ function mcl_burning.set_on_fire(obj, burn_time) end if not storage.burn_time or burn_time >= storage.burn_time then - if obj:is_player() and not storage.fire_hud_id then - storage.fire_hud_id = obj:hud_add({ - hud_elem_type = "image", - position = {x = 0.5, y = 0.5}, - scale = {x = -100, y = -100}, - text = "mcl_burning_entity_flame_animated.png^[opacity:180^[verticalframe:" .. mcl_burning.animation_frames .. ":" .. 1, - z_index = 1000, - }) + if obj:is_player() then + mcl_burning.channels[obj]:send_all(tostring(mcl_burning.animation_frames)) + mcl_burning.channels[obj]:send_all("start") end storage.burn_time = burn_time storage.fire_damage_timer = 0 @@ -95,7 +90,6 @@ function mcl_burning.set_on_fire(obj, burn_time) fire_entity:set_properties({visual_size = size}) fire_entity:set_attach(obj, "", offset, {x = 0, y = 0, z = 0}) local fire_luaentity = fire_entity:get_luaentity() - fire_luaentity:update_frame(obj, storage) for _, other in pairs(minetest.get_objects_inside_radius(fire_entity:get_pos(), 0)) do local other_luaentity = other:get_luaentity() @@ -111,9 +105,7 @@ function mcl_burning.extinguish(obj) if mcl_burning.is_burning(obj) then local storage = mcl_burning.get_storage(obj) if obj:is_player() then - if storage.fire_hud_id then - obj:hud_remove(storage.fire_hud_id) - end + mcl_burning.channels[obj]:send_all("stop") mcl_burning.storage[obj] = {} else storage.burn_time = nil @@ -143,4 +135,4 @@ function mcl_burning.tick(obj, dtime, storage) end end end -end \ No newline at end of file +end diff --git a/mods/ENTITIES/mcl_burning/init.lua b/mods/ENTITIES/mcl_burning/init.lua index 34b7ca2d4b..313e75dca7 100644 --- a/mods/ENTITIES/mcl_burning/init.lua +++ b/mods/ENTITIES/mcl_burning/init.lua @@ -7,6 +7,7 @@ local get_item_group = minetest.get_item_group mcl_burning = { storage = {}, + channels = {}, animation_frames = tonumber(minetest.settings:get("fire_animation_frames")) or 8 } @@ -54,12 +55,11 @@ minetest.register_on_joinplayer(function(player) end mcl_burning.storage[player] = storage + mcl_burning.channels[player] = minetest.mod_channel_join("mcl_burning:" .. player:get_player_name()) end) minetest.register_on_leaveplayer(function(player) - local storage = mcl_burning.storage[player] - storage.fire_hud_id = nil - player:get_meta():set_string("mcl_burning:data", minetest.serialize(storage)) + player:get_meta():set_string("mcl_burning:data", minetest.serialize(mcl_burning.storage[player])) mcl_burning.storage[player] = nil end) @@ -68,27 +68,28 @@ minetest.register_entity("mcl_burning:fire", { initial_properties = { physical = false, collisionbox = {0, 0, 0, 0, 0, 0}, - visual = "cube", + visual = "upright_sprite", + textures = { + name = "mcl_burning_entity_flame_animated.png", + animation = { + type = "vertical_frames", + aspect_w = 16, + aspect_h = 16, + length = 1.0, + }, + }, + spritediv = {x = 1, y = mcl_burning.animation_frames}, pointable = false, glow = -1, backface_culling = false, }, animation_frame = 0, animation_timer = 0, - on_step = function(self, dtime) - local parent, storage = self:sanity_check() - - if parent then - self.animation_timer = self.animation_timer + dtime - if self.animation_timer >= 0.1 then - self.animation_timer = 0 - self.animation_frame = self.animation_frame + 1 - if self.animation_frame > mcl_burning.animation_frames - 1 then - self.animation_frame = 0 - end - self:update_frame(parent, storage) - end - else + on_activate = function(self) + self.object:set_sprite({x = 0, y = 0}, mcl_burning.animation_frames, 1.0 / mcl_burning.animation_frames) + end, + on_step = function(self) + if not self:sanity_check() then self.object:remove() end end, @@ -96,23 +97,15 @@ minetest.register_entity("mcl_burning:fire", { local parent = self.object:get_attach() if not parent then - return + return false end local storage = mcl_burning.get_storage(parent) if not storage or not storage.burn_time then - return + return false end - return parent, storage - end, - update_frame = function(self, parent, storage) - local frame_overlay = "^[opacity:180^[verticalframe:" .. mcl_burning.animation_frames .. ":" .. self.animation_frame - local fire_texture = "mcl_burning_entity_flame_animated.png" .. frame_overlay - self.object:set_properties({textures = {"blank.png", "blank.png", fire_texture, fire_texture, fire_texture, fire_texture}}) - if parent:is_player() then - parent:hud_change(storage.fire_hud_id, "text", "mcl_burning_hud_flame_animated.png" .. frame_overlay) - end + return true end, }) From c6003398b5f4149b3eaffe585fde40e8374c721b Mon Sep 17 00:00:00 2001 From: NO11 Date: Sun, 19 Sep 2021 13:14:36 +0000 Subject: [PATCH 74/74] Remove chain armor recipes, because villagers spawn now --- mods/MISC/mcl_temp_helper_recipes/init.lua | 34 ---------------------- 1 file changed, 34 deletions(-) diff --git a/mods/MISC/mcl_temp_helper_recipes/init.lua b/mods/MISC/mcl_temp_helper_recipes/init.lua index 420cd6c2ec..b7607946d4 100644 --- a/mods/MISC/mcl_temp_helper_recipes/init.lua +++ b/mods/MISC/mcl_temp_helper_recipes/init.lua @@ -35,40 +35,6 @@ minetest.register_craft({ }, }) -minetest.register_craft({ - output = "mcl_armor:helmet_chain", - recipe = { - { "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - } -}) - -minetest.register_craft({ - output = "mcl_armor:leggings_chain", - recipe = { - { "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - } -}) - -minetest.register_craft({ - output = "mcl_armor:boots_chain", - recipe = { - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - } -}) - -minetest.register_craft({ - output = "mcl_armor:chestplate_chain", - recipe = { - { "xpanes:bar_flat", "", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "mcl_core:iron_ingot", "xpanes:bar_flat" }, - { "xpanes:bar_flat", "xpanes:bar_flat", "xpanes:bar_flat" }, - } -}) - -- Make red sand, red sandstone and more craftable in v6 -- NOTE: When you change these, also update mcl_craftguide for the "v6" icon in -- the craft guide!