From 7cf91c79cb1813089874460b821176eaea83d7a8 Mon Sep 17 00:00:00 2001 From: AFCMS Date: Tue, 18 Oct 2022 14:49:21 +0200 Subject: [PATCH] Smithing Table --- .luarc.json | 22 +++++ mods/ITEMS/mcl_smithing_table/init.lua | 86 +++++++++++------- mods/ITEMS/mcl_smithing_table/mod.conf | 2 +- textures/mcl_smithing_table_bottom.png | Bin 240 -> 284 bytes textures/mcl_smithing_table_front.png | Bin 263 -> 298 bytes .../mcl_smithing_table_inventory_hammer.png | Bin 0 -> 178 bytes textures/mcl_smithing_table_side.png | Bin 241 -> 283 bytes textures/mcl_smithing_table_top.png | Bin 283 -> 320 bytes 8 files changed, 77 insertions(+), 33 deletions(-) create mode 100644 .luarc.json create mode 100644 textures/mcl_smithing_table_inventory_hammer.png diff --git a/.luarc.json b/.luarc.json new file mode 100644 index 000000000..7e9e92042 --- /dev/null +++ b/.luarc.json @@ -0,0 +1,22 @@ +{ + "runtime.version": "LuaJIT", + "diagnostics": { "disable": ["lowercase-global"] }, + "diagnostics.globals": [ + "minetest", + "dump", + "dump2", + "Raycast", + "Settings", + "PseudoRandom", + "PerlinNoise", + "VoxelManip", + "SecureRandom", + "VoxelArea", + "PerlinNoiseMap", + "PcgRandom", + "ItemStack", + "AreaStore", + "vector" + ], + "workspace.ignoreDir": [".luacheckrc"] +} diff --git a/mods/ITEMS/mcl_smithing_table/init.lua b/mods/ITEMS/mcl_smithing_table/init.lua index dbb6c620f..5d0becad7 100644 --- a/mods/ITEMS/mcl_smithing_table/init.lua +++ b/mods/ITEMS/mcl_smithing_table/init.lua @@ -1,11 +1,13 @@ ---[[ -By EliasFleckenstein03 and Code-Sploit -]] +-- By EliasFleckenstein03 and Code-Sploit local S = minetest.get_translator("mcl_smithing_table") +local F = minetest.formspec_escape +local C = minetest.colorize + mcl_smithing_table = {} --- Function to upgrade diamond tool/armor to netherite tool/armor +---Function to upgrade diamond tool/armor to netherite tool/armor +---@param itemstack ItemStack function mcl_smithing_table.upgrade_item(itemstack) local def = itemstack:get_definition() @@ -29,28 +31,48 @@ function mcl_smithing_table.upgrade_item(itemstack) return itemstack end --- Badly copied over from mcl_anvils --- ToDo: Make better formspec +local formspec = table.concat({ + "formspec_version[4]", + "size[11.75,10.425]", -local formspec = "size[9,9]" .. - "background[-0.19,-0.25;9.41,9.49;mcl_smithing_table_inventory.png]".. - "label[0,4.0;" .. minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Inventory"))) .. "]" .. - "list[current_player;main;0,4.5;9,3;9]" .. - mcl_formspec.get_itemslot_bg(0,4.5,9,3) .. - "list[current_player;main;0,7.74;9,1;]" .. - mcl_formspec.get_itemslot_bg(0,7.74,9,1) .. - "list[context;diamond_item;1,2.5;1,1;]" .. - mcl_formspec.get_itemslot_bg(1,2.5,1,1) .. - "list[context;netherite;4,2.5;1,1;]" .. - mcl_formspec.get_itemslot_bg(4,2.5,1,1) .. - "list[context;upgraded_item;8,2.5;1,1;]" .. - mcl_formspec.get_itemslot_bg(8,2.5,1,1) .. - "label[3,0.1;" .. minetest.formspec_escape(minetest.colorize(mcl_colors.DARK_GRAY, S("Upgrade Gear"))) .. "]" .. - "listring[context;output]".. - "listring[current_player;main]".. - "listring[context;input]".. - "listring[current_player;main]" + "label[4.125,0.375;" .. F(C(mcl_formspec.label_color, S("Upgrade Gear"))) .. "]", + "image[0.875,0.375;1.75,1.75;mcl_smithing_table_inventory_hammer.png]", + + mcl_formspec.get_itemslot_bg_v4(1.625, 2.6, 1, 1), + "list[context;diamond_item;1.625,2.6;1,1;]", + + "image[3.5,2.6;1,1;mcl_anvils_inventory_cross.png]", + + mcl_formspec.get_itemslot_bg_v4(5.375, 2.6, 1, 1), + "list[context;netherite;5.375,2.6;1,1;]", + + "image[6.75,2.6;2,1;mcl_anvils_inventory_arrow.png]", + + mcl_formspec.get_itemslot_bg_v4(9.125, 2.6, 1, 1), + "list[context;upgraded_item;9.125,2.6;1,1;]", + + -- Player Inventory + + mcl_formspec.get_itemslot_bg_v4(0.375, 5.1, 9, 3), + "list[current_player;main;0.375,5.1;9,3;9]", + + mcl_formspec.get_itemslot_bg_v4(0.375, 9.05, 9, 1), + "list[current_player;main;0.375,9.05;9,1;]", + + -- Listrings + + "listring[context;diamond_item]", + "listring[current_player;main]", + "listring[context;netherite]", + "listring[current_player;main]", + "listring[context;upgraded_item]", + "listring[current_player;main]", + "listring[current_player;main]", + "listring[context;diamond_item]", +}) + +---@param pos Vector local function reset_upgraded_item(pos) local inv = minetest.get_meta(pos):get_inventory() local upgraded_item @@ -66,8 +88,7 @@ minetest.register_node("mcl_smithing_table:table", { description = S("Smithing table"), -- ToDo: Add _doc_items_longdesc and _doc_items_usagehelp - stack_max = 64, - groups = {pickaxey = 2, deco_block = 1}, + groups = { pickaxey = 2, deco_block = 1 }, tiles = { "mcl_smithing_table_top.png", @@ -92,7 +113,8 @@ minetest.register_node("mcl_smithing_table:table", { end, allow_metadata_inventory_put = function(pos, listname, index, stack, player) - if listname == "diamond_item" and mcl_smithing_table.upgrade_item(stack) or listname == "netherite" and stack:get_name() == "mcl_nether:netherite_ingot" then + if listname == "diamond_item" and mcl_smithing_table.upgrade_item(stack) or + listname == "netherite" and stack:get_name() == "mcl_nether:netherite_ingot" then return stack:get_count() end @@ -119,7 +141,7 @@ minetest.register_node("mcl_smithing_table:table", { take_item("netherite") -- ToDo: make epic sound - minetest.sound_play("mcl_smithing_table_upgrade", {pos = pos, max_hear_distance = 16}) + minetest.sound_play("mcl_smithing_table_upgrade", { pos = pos, max_hear_distance = 16 }) end if listname == "upgraded_item" then if stack:get_name() == "mcl_farming:hoe_netherite" then @@ -138,8 +160,8 @@ minetest.register_node("mcl_smithing_table:table", { minetest.register_craft({ output = "mcl_smithing_table:table", recipe = { - {"mcl_core:iron_ingot", "mcl_core:iron_ingot", ""}, - {"group:wood", "group:wood", ""}, - {"group:wood", "group:wood", ""} - } + { "mcl_core:iron_ingot", "mcl_core:iron_ingot", "" }, + { "group:wood", "group:wood", "" }, + { "group:wood", "group:wood", "" } + }, }) diff --git a/mods/ITEMS/mcl_smithing_table/mod.conf b/mods/ITEMS/mcl_smithing_table/mod.conf index aee93fa65..1c12cb483 100644 --- a/mods/ITEMS/mcl_smithing_table/mod.conf +++ b/mods/ITEMS/mcl_smithing_table/mod.conf @@ -1,2 +1,2 @@ name = mcl_smithing_table -depends = mcl_colors, mcl_formspec +depends = mcl_colors, mcl_formspec, mcl_anvils diff --git a/textures/mcl_smithing_table_bottom.png b/textures/mcl_smithing_table_bottom.png index d44c0773ea51d8f2b95c5cfa02d5f54ba6ca1e34..cca0ebf1428aea62b5de7844d76df482482ead40 100644 GIT binary patch delta 269 zcmV+o0rLLv0h|Jm7=H)?0001xk!Usm0084jL_t(2Q+<-L3IZ_@MDqzD<^6%3gtr`4kT*Jw$r;?h zsMT)a9%h_Cp{GfY8z3`UllSx{&-Y0?vq)VYSQH`9SfSJTCRvd`JFRsOj_9}^`e2+? zp5**UR*(=6mesG3OO*;G0Pxm+ON3X{@?IqZSvli=LzLCT#ORc+9q=F0B(kR*)R$iq a8;^gOpes$)gLioV0000(V2XOTbd`kb`f6ZO51%Eu$C85T6hh_gO*zJ zrVw!p1yT%Wr~T@0fjrN%EE{W$vwZsKVpp7@0{BPB3|xF?OBR5~kPOgn3_j{wz#BleBp;hwvVgZ% g7|Y}7ZVA8-;1k#23E5OqA^-pY07*qoM6N<$f^D9B0RR91 delta 246 zcmV%CMPE+C@3f? zDJd!{DlRTAFE1}NG&DFF7eGKjLn0tfJ}^&DPgX4}Sw=T;Rz!SXOp4^0)!m~`z+V5@y<**%XLA(y7vNa6#e5J4^*PhCjzV+_0i};>m9hP`B0a% wQ_43Of1;;Wm!eC!=rx|=5>8=0)sM0K16gc3WlB;-mjD0&07*qoM6N<$f@QZ_0ssI2 diff --git a/textures/mcl_smithing_table_inventory_hammer.png b/textures/mcl_smithing_table_inventory_hammer.png new file mode 100644 index 0000000000000000000000000000000000000000..48a21e97dbb3f3ed76930150de82b93bd2ff227a GIT binary patch literal 178 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`m7Xq+Ar_~T6BHO!RFC{Op1|!e z%eR;3-{e#dA7hT!S(y#IonN>7^xu?L;(Vz&ro)_N3FmA@m7Ofp64sjF(t0y~$Yhcm9(po*u?=43~JgOnzmzu}a;X brOC>0sGz1VDWvBa&=Cxtu6{1-oD!M<5duKG literal 0 HcmV?d00001 diff --git a/textures/mcl_smithing_table_side.png b/textures/mcl_smithing_table_side.png index fbc1a9a23610d4afd2a51f565058a50f74f24e40..d93a7906ce77f831ff3509f956e2114a141308fb 100644 GIT binary patch delta 267 zcmV+m0rdXy0hMA%%S6zJoSKq*=^lNjC>3PKvN-oKlKbquu?wsp4(rYB}xLSB7Y9XUq25rG( z3nf~NSg{yyrbGJ`6-LAZWD~gVW>HnfchKzHX&qH%z5oL#fPW`22$4V<+g3|kfTYWI zE_oQj`~k{hDF8+QR3iZ}oB${;yRJS-kiC5ec6!~9s_)17R{^pt^Btb$K2Xbxhq`H+ zwg6fmRudfqgQt$<0r?|zhv-?+79dyBm|WA|R{-k90Xe81w-f04k?dIkKE;jKtGmh> R+yDRo07*qoL>-||3@o88ogw8JZ5N;woH^!2I4dkX|0KgVGhO01z9+CI^vO)fIjm|0-KGP zl?(R8wLt<&g1ZE522EsC<|hL9{V(w`n827Wxcl$v=PTXRcr7IA>08Gix*005AYXf^-<0S8G$K~yMHb&|^tf-n$8`4SQlS@^2b5DbPy zUAS`N!j&6${{J6%+Dpa?@unribk01WnR9L#HTxBwMbtd1EK6+s83(WXnWx{aFGr94 zyq#?EijyOvv5TU}K$Xl*QeyXg z9~$amXsj1|Tc|Y=#q{GXt!3^aH5EG|04!eSU%W<7ySA!p}$q&*bl3QlP4}hx(TB9G> Ro&W#<07*qoL