From 70d9f58f6b9e82deeba9aa4e3f0ad1505bf562da Mon Sep 17 00:00:00 2001 From: "Github is a non-free platform owned by Microsoft. Reasonable alternatives exist, such as Gitea, Sourcehut. We need a federated, mastodon-like forge based on ForgeFed. See: https://forgefed.org" Date: Wed, 11 Oct 2023 20:04:20 +0200 Subject: [PATCH] Airtanks and breathing tube in armor slots (#8) Integrates MineClone/MineClonia so that those items can be used in the armor slot. --- init.lua | 58 +++++++++++++++++--- mod.conf | 2 +- textures/airtanks_chestplate_tank.png | Bin 0 -> 413 bytes textures/airtanks_chestplate_tank_three.png | Bin 0 -> 463 bytes textures/airtanks_chestplate_tank_two.png | Bin 0 -> 433 bytes textures/airtanks_helmet_tube.png | Bin 0 -> 201 bytes textures/airtanks_helmet_tube_preview.png | Bin 0 -> 206 bytes 7 files changed, 52 insertions(+), 8 deletions(-) create mode 100644 textures/airtanks_chestplate_tank.png create mode 100644 textures/airtanks_chestplate_tank_three.png create mode 100644 textures/airtanks_chestplate_tank_two.png create mode 100644 textures/airtanks_helmet_tube.png create mode 100644 textures/airtanks_helmet_tube_preview.png diff --git a/init.lua b/init.lua index bbfe36a..775dcd7 100644 --- a/init.lua +++ b/init.lua @@ -4,6 +4,8 @@ local print_settingtypes = false local CONFIG_FILE_PREFIX = "airtanks_" local config = {} +local has_mcl_armor = minetest.get_modpath("mcl_armor") + local function setting(stype, name, default, description) local value if stype == "bool" then @@ -87,6 +89,9 @@ end local tube_desc = S("A breathing tube to allow automatic hands-free use of air tanks.") local tube_help = S("If this item is present in your quick-use inventory then whenever your breath bar goes below 5 it will automatically make use of any air tanks that are present in your quick-use inventory to replenish your breath supply. Note that it will not use air tanks that are present elsewhere in your inventory, only ones in your quick-use bar.") +if has_mcl_armor then + tube_help = S("If this item is present in your head armor slot then whenever your breath bar goes below 5 it will automatically make use of any air tanks that are present in your chestplate armor slot to replenish your breath supply. Note that it will not use air tanks that are present elsewhere in your inventory, only ones in your chestplate armor slot.") +end local cardinal_dirs = {{x=1,y=0,z=0},{x=-1,y=0,z=0},{x=0,y=1,z=0},{x=0,y=-1,z=0},{x=0,y=0,z=1},{x=0,y=0,z=-1},} @@ -144,11 +149,19 @@ local function register_air_tank(name, desc, color, uses, material) inventory_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png", wield_image = "airtanks_airtank.png^[colorize:"..color.."^[mask:airtanks_airtank.png", stack_max = 1, + _mcl_armor_element = "torso", + _mcl_armor_texture = "airtanks_chestplate_tank.png", on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user) + if has_mcl_armor then + return mcl_armor.equip_on_use(itemstack, user, pointed_thing) + else + return use_airtank(itemstack, user) + end end, + on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, + on_use = function(itemstack, user, pointed_thing) return use_airtank(itemstack, user) end, @@ -190,11 +203,19 @@ local function register_air_tank_2(name, desc, color, uses, material) inventory_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png", wield_image = "airtanks_airtank_two.png^[colorize:"..color.."^[mask:airtanks_airtank_two.png", stack_max = 1, + _mcl_armor_element = "torso", + _mcl_armor_texture = "airtanks_chestplate_tank_two.png", on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user) + if has_mcl_armor then + return mcl_armor.equip_on_use(itemstack, user, pointed_thing) + else + return use_airtank(itemstack, user) + end end, + on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, + on_use = function(itemstack, user, pointed_thing) return use_airtank(itemstack, user) end, @@ -243,11 +264,19 @@ local function register_air_tank_3(name, desc, color, uses, material) inventory_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png", wield_image = "airtanks_airtank_three.png^[colorize:"..color.."^[mask:airtanks_airtank_three.png", stack_max = 1, + _mcl_armor_element = "torso", + _mcl_armor_texture = "airtanks_chestplate_tank_three.png", on_place = function(itemstack, user, pointed_thing) - return use_airtank(itemstack, user) + if has_mcl_armor then + mcl_armor.equip_on_use(itemstack, user, pointed_thing) + else + return use_airtank(itemstack, user) + end end, + on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, + on_use = function(itemstack, user, pointed_thing) return use_airtank(itemstack, user) end, @@ -356,7 +385,7 @@ local test_can_put = function(pos, listname, index, itemstack) return 1 end end - return 0 + return 0 end if listname == "fuel" then local fuel, afterfuel = minetest.get_craft_result({method="fuel",width=1,items={itemstack:get_name()}}) @@ -593,6 +622,13 @@ minetest.register_craftitem("airtanks:breathing_tube", { _doc_items_usagehelp = tube_help, inventory_image = "airtanks_breathing_tube.png", wield_image = "airtanks_breathing_tube.png", + + _mcl_armor_element = "head", + _mcl_armor_texture = "airtanks_helmet_tube.png", + _mcl_armor_preview = "airtanks_helmet_tube_preview.png", + + on_place = has_mcl_armor and mcl_armor.equip_on_use, + on_secondary_use = has_mcl_armor and mcl_armor.equip_on_use, }) minetest.register_craft({ @@ -606,9 +642,13 @@ minetest.register_craft({ local function tool_active(player, item) local inv = player:get_inventory() + local inv_list = "main" local hotbar = player:hud_get_hotbar_itemcount() + if has_mcl_armor then + inv_list = "armor" + end for i=1, hotbar do - if inv:get_stack("main", i):get_name() == item then + if inv:get_stack(inv_list, i):get_name() == item then return true end end @@ -617,12 +657,16 @@ end local function use_any_airtank(player) local inv = player:get_inventory() + local inv_list = "main" local hotbar = player:hud_get_hotbar_itemcount() + if has_mcl_armor then + inv_list = "armor" + end for i=1, hotbar do - local itemstack = inv:get_stack("main", i) + local itemstack = inv:get_stack(inv_list, i) if minetest.get_item_group(itemstack:get_name(), "airtank") > 1 then itemstack = use_airtank(itemstack, player) - inv:set_stack("main", i, itemstack) + inv:set_stack(inv_list, i, itemstack) return true end end diff --git a/mod.conf b/mod.conf index e13b27e..7dfb028 100644 --- a/mod.conf +++ b/mod.conf @@ -1,4 +1,4 @@ name = airtanks description = Provides pressurized air tanks for extended underwater excursions depends = -optional_depends = doc, default, mcl_formspec, mcl_sounds, mcl_core, mcl_copper \ No newline at end of file +optional_depends = doc, default, mcl_formspec, mcl_sounds, mcl_core, mcl_copper, mcl_armor \ No newline at end of file diff --git a/textures/airtanks_chestplate_tank.png b/textures/airtanks_chestplate_tank.png new file mode 100644 index 0000000000000000000000000000000000000000..081ceb90b955bc30f1d43b94dbc1ec7a54dc351e GIT binary patch literal 413 zcmV;O0b>4%P)Aw7k8z$;`;Oxv`Rzhm)3$h>V4WhJ3fVwbRwpwYRQ@ih8@fxwEyd z>+b8Dp_#kAyt}=)go=8otf8^As;#i5xx2Ktxwpl~!@$G5$H>LGyR)gRp}D)byS%x* zz`Uxhsiml)rKzC5z`3xqtgNo4!Nb6}xUsCRq?447ggNZg00001bW%=J06^y0W&i*H z0b)x>L;#2d9Y_EG010qNS#tmY3ljhU3ljkVnw%H_000McNliruA&U;ANsrKRY|m0K33IMP8pG0~kduxhOKgL_%DWA_Mq^ zgbgV&z*tX*GA}6E*eXzDfEc5d7DWc=%4yqC7KqB$M!01G;?D&&FJB&&00000NkvXX Hu0mjf1>C`; literal 0 HcmV?d00001 diff --git a/textures/airtanks_chestplate_tank_three.png b/textures/airtanks_chestplate_tank_three.png new file mode 100644 index 0000000000000000000000000000000000000000..7f961d9039669b9c4085cbc6723a94db953211e5 GIT binary patch literal 463 zcmV;=0WkiFP)k5h>L&v{QUO#_^7I>xVyKKm5Ip9 z$Gp9_oT8e|(9E>Aw7k8z$;`;Oxv`Rzhm)3$h>V4WhJ3fVwbRwpwYRQ@ih8@fxwEyd z>+b8Dp_#kAyt}=)go=8otf8^As;#i5xx2Ktxwpl~!@$G5$H>LGyR)gRp}D)byS%x* zz`Uxhsiml)rKzC5z`3xqtgNo4!Nb6}xUsCRq?447w3hhy00001bW%=J06^y0W&i*H z0b)x>L;#2d9Y_EG010qNS#tmY3ljhU3ljkVnw%H_000McNliruA&`VCG|B;A5u10A3DeJ`P@rT)@jgi3<#b2_l$TmP%PFvSbPTP)b z1K2ou1dKR&6v;L~orOtSgM~?xYy;Hz*-b6@*;#SP0{{|*2n7i{v7-P0002ovPDHLk FV1h$p+}r>F literal 0 HcmV?d00001 diff --git a/textures/airtanks_chestplate_tank_two.png b/textures/airtanks_chestplate_tank_two.png new file mode 100644 index 0000000000000000000000000000000000000000..ea7598ffb9594cfb70525bf2b43ce3840fc91376 GIT binary patch literal 433 zcmeAS@N?(olHy`uVBq!ia0vp^4nVBH!3-p)I`?e@QU?NjLR?p@T(on~_79&vtlPL| z-om;4Q+gLIT>_NsozOaETHp2^8#=n{fBpIM?Z=N5t5)vVy?yGm-bqtCPn_9W7l|E7mOBxMkJa4a;`!-m-n?_M^uSA2__{_=%%CcW+*~X5r4= zJ9h8cx%a@HRclu+U9oWK$_4um?A)+<&6;(~4jw+ReaFT%>y}KO(%)kF<_gfcj3q&S z!3+-1Zlr-YN#5=*3>~bp9zYIffk$L90|U1(2s1Lwnj--eWH0gbb!C6b#VaBpH#7AJ zP@W;n)5S5w<9Kp{1nc4ik)EbN2b+XPsR<8K7ad@bD^qwN=^!q#;>7D_gPUvyT~S4i zKzhR}FK-b2ftyph2}n!4epvwGYuvn{)c~YB45KnZ{1>M(Z#NqJY+R9(%W`PP6UI1x WF8w*hOEZABGI+ZBxvXHYaZfQi=gSA+E~G%94_jD<1vV(a|wA zHTCrLw6(Q;`~83Ux!v zL>4nJa0`PlBg3pY5H=O_NQFDLZW literal 0 HcmV?d00001 diff --git a/textures/airtanks_helmet_tube_preview.png b/textures/airtanks_helmet_tube_preview.png new file mode 100644 index 0000000000000000000000000000000000000000..829d644c30d1b17c07b720c783a1f35380c1363a GIT binary patch literal 206 zcmeAS@N?(olHy`uVBq!ia0vp^0zj<5!VDx|E`RzTNNEN5gt#gzD@#gBnwpx%ue+h6 zqvPr6`S$z&6_5VA*3RR}W8kY};3;4To_>%gmtkYCt^!aOV@Z%-FoVOh8)+a;lDE4H zLkFv@2av;A;1OBOz`!jG!i)^F=12eq*-JcqUD=;<@d}9=dixdL1q#V}x;TbNTux44 tU<_l^P-qimSs2nHqQG;Eq3t0z!_P!UVeu`yRst0=c)I$ztaD0e0szCVG|vD4 literal 0 HcmV?d00001