From 20c84b98f864515763c94323b08199bdf1eb057c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Tue, 21 Feb 2017 01:41:13 +0100 Subject: [PATCH] Complete refresh of furnace mod - Take code from Minetest Game 0.4.15 - The progress arrow now works - Less bugs --- .../textures/crafting_inventory_furnace.png | Bin 22154 -> 0 bytes .../crafting_inventory_furnace_on.png | Bin 22141 -> 0 bytes mods/ITEMS/mcl_furnaces/README.md | 12 + mods/ITEMS/mcl_furnaces/init.lua | 436 ++++++++++-------- .../textures/default_furnace_bg.png | Bin 1189 -> 0 bytes .../textures/gui_furnace_arrow_bg.png | Bin 0 -> 370 bytes .../textures/gui_furnace_arrow_fg.png | Bin 0 -> 341 bytes .../textures/mcl_furnaces_formspec.png | Bin 0 -> 2718 bytes 8 files changed, 247 insertions(+), 201 deletions(-) delete mode 100644 mods/ITEMS/mcl_core/textures/crafting_inventory_furnace.png delete mode 100644 mods/ITEMS/mcl_core/textures/crafting_inventory_furnace_on.png create mode 100644 mods/ITEMS/mcl_furnaces/README.md delete mode 100644 mods/ITEMS/mcl_furnaces/textures/default_furnace_bg.png create mode 100644 mods/ITEMS/mcl_furnaces/textures/gui_furnace_arrow_bg.png create mode 100644 mods/ITEMS/mcl_furnaces/textures/gui_furnace_arrow_fg.png create mode 100644 mods/ITEMS/mcl_furnaces/textures/mcl_furnaces_formspec.png diff --git a/mods/ITEMS/mcl_core/textures/crafting_inventory_furnace.png b/mods/ITEMS/mcl_core/textures/crafting_inventory_furnace.png deleted file mode 100644 index e80c3c9b69deda77aa95d9b347f82fe4f876286b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22154 zcmeI44^SIb8o(E+###mMdJg`<=Egeb&DFz>=rt5!ueKGdV|rGdlv)U$w6sMf0yZsy zES9s3(>btL+n!S(<7q{kmOU*T0<0sfD}@o=~6=eZg$^&n}ia?j;XDl zH}^8jX4&Mu_r33Xf4=v7U-s2M$y08)?$+xFg1BMX!%J2WM5G-4ZoKvyx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{uT!?tV&a5KYw29IW8js19N7AHMC&tMM#yEE7~3-Ker z_Yymr*wOsCI-25=vcH@Z{^k6h#qRW#E$ki&*IdGKIgmpSEV#wrVp(3k)ZbfO*!~?O zZ~3UMVI4bY8S-VHnRXQJ%j;Ja%tsO2{rSRo9Lc7`n~(O58!2JO9hgaBCKc8uKHg&& z!y|CO01g6$pB?YD;JudAY|M=@H~zVDV{93085}x- zLq~AvNH{T&I7AVmOR+oi|2}DYJ6eWduh|{bb?Mv2@QeN1M2I8?USDi+JuOaKBQEeE z)|!(16c6;gq6_dJ_)t=*yI}q+{+)Gns_Y%g&O}vja)1U5)F04Cy9E}FFv7OL=i^kY z{Ie!__UNeYm@emS^pcGC6mN)z=c4+u#&YUELm%xB3h(1bsD7j3CNYOUBerr}2~Tc~ az9Z+R7kBP`qzf`8mMxVpsd+GC%YOhjczJOE diff --git a/mods/ITEMS/mcl_core/textures/crafting_inventory_furnace_on.png b/mods/ITEMS/mcl_core/textures/crafting_inventory_furnace_on.png deleted file mode 100644 index 80d3e26f4e95ed2f6736d7bbbbc9089bd3c3c2fb..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 22141 zcmeI44^SIb8o(E+###mEdJg`<=Egeb&DFz>=rt5!ueKGdV|xCZlv)U$ZE1^21lqI& zve=$7PDjwIZO@{y)XO9pXC|XU32p_1VLQ4AU@v@@F^H&$CpDtKMsGeT? zd{NT#tBQVePtx3^lxLH*AoWRZ$)W{MY|M7>3qD-=%8oZOlk0~JnI~Sp>C2VbbAEd` z=d=~s^^e_sV9g%ihW#U&PYU1v^j8b!rrvQI*(OmhoQ>KLPw`gDhgcLt5IszQJh)A; z8piBzA2}wz&XC+t@2NF+CyOu6)Bk{f9_s8}xjOhltk89w zB{Kd9RU+#Lv1RB^p_AhB(JkdO3Br^>mdF~);k=NnlEK@d9@P~Dv9Y;#8bOR~ZkY~x zTp9f0jJP|Xa6%%~lekM(1^evFUqGutJcB%y>(I3Xq0NuGL#uIkH)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5ZxJDqn0S4m$@P>xZH+j=hg@q)@^d`U^RiCB zf8;|+rQYJXF9lcD(aDN;DJK(GyU_&}Fj0R*AMX@cG|UKFL!XaPiSo~l@a)kM-4R{> zJ7~R(_m!=Shv%XOa!2zUKSv*L6H4ykhp9fZ;s#N|Ul3b8ri3TA#^08I!wcJYKhz0= Oi6x8Wi|X#r+58{PTXoI= diff --git a/mods/ITEMS/mcl_furnaces/README.md b/mods/ITEMS/mcl_furnaces/README.md new file mode 100644 index 000000000..7bdcae469 --- /dev/null +++ b/mods/ITEMS/mcl_furnaces/README.md @@ -0,0 +1,12 @@ +Furnaces for MineClone 2. +Heavily based on Minetest Game (default/furnace.lua). + +License of source code +---------------------- +LGPLv2.1 +Based on code from Minetest Game. +Modified by Wuzzy. + +License of media +---------------- +MIT License diff --git a/mods/ITEMS/mcl_furnaces/init.lua b/mods/ITEMS/mcl_furnaces/init.lua index a7a5eff91..75d068aa9 100644 --- a/mods/ITEMS/mcl_furnaces/init.lua +++ b/mods/ITEMS/mcl_furnaces/init.lua @@ -1,6 +1,33 @@ -local furnace_inactive_formspec = - "size[9,8.75]".. - "background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_furnace.png]".. + +-- +-- Formspecs +-- + +local function active_formspec(fuel_percent, item_percent) + return "size[9,8.75]".. + "background[-0.19,-0.25;9.41,9.49;mcl_furnaces_formspec.png]".. + mcl_vars.inventory_header.. + "list[current_player;main;0,4.5;9,3;9]".. + "list[current_player;main;0,7.74;9,1;]".. + "list[current_name;src;2.75,0.5;1,1;]".. + "list[current_name;fuel;2.75,2.5;1,1;]".. + "list[current_name;dst;5.75,1.5;1,1;]".. + "image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:".. + (100-fuel_percent)..":default_furnace_fire_fg.png]".. + "image[4.1,1.5;1.5,1;gui_furnace_arrow_bg.png^[lowpart:".. + (item_percent)..":gui_furnace_arrow_fg.png^[transformR270]".. + "image_button[8,0;1,1;craftguide_book.png;__mcl_craftguide;]".. + "tooltip[__mcl_craftguide;Show crafting recipes]".. + "listring[current_name;dst]".. + "listring[current_player;main]".. + "listring[current_name;src]".. + "listring[current_player;main]".. + "listring[current_name;fuel]".. + "listring[current_player;main]" +end + +local inactive_formspec = "size[9,8.75]".. + "background[-0.19,-0.25;9.41,9.49;mcl_furnaces_formspec.png]".. mcl_vars.inventory_header.. "list[current_player;main;0,4.5;9,3;9]".. "list[current_player;main;0,7.74;9,1;]".. @@ -8,6 +35,7 @@ local furnace_inactive_formspec = "list[current_name;fuel;2.75,2.5;1,1;]".. "list[current_name;dst;5.75,1.5;1,1;]".. "image[2.75,1.5;1,1;default_furnace_fire_bg.png]".. + "image[4.1,1.5;1.5,1;gui_furnace_arrow_bg.png^[transformR270]".. "image_button[8,0;1,1;craftguide_book.png;__mcl_craftguide;]".. "tooltip[__mcl_craftguide;Show crafting recipes]".. "listring[current_name;dst]".. @@ -23,23 +51,184 @@ local craftguide = function(pos, formname, fields, sender) end end +-- +-- Node callback functions that are the same for active and inactive furnace +-- + +local function allow_metadata_inventory_put(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + if listname == "fuel" then + if minetest.get_craft_result({method="fuel", width=1, items={stack}}).time ~= 0 then + return stack:get_count() + else + return 0 + end + elseif listname == "src" then + return stack:get_count() + elseif listname == "dst" then + return 0 + end +end + +local function allow_metadata_inventory_move(pos, from_list, from_index, to_list, to_index, count, player) + local meta = minetest.get_meta(pos) + local inv = meta:get_inventory() + local stack = inv:get_stack(from_list, from_index) + return allow_metadata_inventory_put(pos, to_list, to_index, stack, player) +end + +local function allow_metadata_inventory_take(pos, listname, index, stack, player) + if minetest.is_protected(pos, player:get_player_name()) then + return 0 + end + return stack:get_count() +end + +local function swap_node(pos, name) + local node = minetest.get_node(pos) + if node.name == name then + return + end + node.name = name + minetest.swap_node(pos, node) +end + +local function furnace_node_timer(pos, elapsed) + -- + -- Inizialize metadata + -- + local meta = minetest.get_meta(pos) + local fuel_time = meta:get_float("fuel_time") or 0 + local src_time = meta:get_float("src_time") or 0 + local fuel_totaltime = meta:get_float("fuel_totaltime") or 0 + + local inv = meta:get_inventory() + local srclist, fuellist + + local cookable, cooked + local fuel + + local update = true + while update do + update = false + + srclist = inv:get_list("src") + fuellist = inv:get_list("fuel") + + -- + -- Cooking + -- + + -- Check if we have cookable content + local aftercooked + cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) + cookable = cooked.time ~= 0 + + -- Check if we have enough fuel to burn + if fuel_time < fuel_totaltime then + -- The furnace is currently active and has enough fuel + fuel_time = fuel_time + elapsed + -- If there is a cookable item then check if it is ready yet + if cookable then + src_time = src_time + elapsed + if src_time >= cooked.time then + -- Place result in dst list if possible + if inv:room_for_item("dst", cooked.item) then + inv:add_item("dst", cooked.item) + inv:set_stack("src", 1, aftercooked.items[1]) + src_time = src_time - cooked.time + update = true + end + end + end + else + -- Furnace ran out of fuel + if cookable then + -- We need to get new fuel + local afterfuel + fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) + + if fuel.time == 0 then + -- No valid fuel in fuel list + fuel_totaltime = 0 + src_time = 0 + else + -- Take fuel from fuel list + inv:set_stack("fuel", 1, afterfuel.items[1]) + update = true + fuel_totaltime = fuel.time + (fuel_time - fuel_totaltime) + src_time = src_time + elapsed + end + else + -- We don't need to get new fuel since there is no cookable item + fuel_totaltime = 0 + src_time = 0 + end + fuel_time = 0 + end + + elapsed = 0 + end + + if fuel and fuel_totaltime > fuel.time then + fuel_totaltime = fuel.time + end + if srclist[1]:is_empty() then + src_time = 0 + end + + -- + -- Update formspec and node + -- + local formspec = inactive_formspec + local item_state + local item_percent = 0 + if cookable then + item_percent = math.floor(src_time / cooked.time * 100) + end + + local result = false + + if fuel_totaltime ~= 0 then + local fuel_percent = math.floor(fuel_time / fuel_totaltime * 100) + formspec = active_formspec(fuel_percent, item_percent) + swap_node(pos, "mcl_furnaces:furnace_active") + -- make sure timer restarts automatically + result = true + else + swap_node(pos, "mcl_furnaces:furnace") + -- stop timer on the inactive furnace + minetest.get_node_timer(pos):stop() + end + + -- + -- Set meta values + -- + meta:set_float("fuel_totaltime", fuel_totaltime) + meta:set_float("fuel_time", fuel_time) + meta:set_float("src_time", src_time) + meta:set_string("formspec", formspec) + + return result +end + minetest.register_node("mcl_furnaces:furnace", { description = "Furnace", - tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", - "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front.png"}, + tiles = { + "default_furnace_top.png", "default_furnace_bottom.png", + "default_furnace_side.png", "default_furnace_side.png", + "default_furnace_side.png", "default_furnace_front.png" + }, paramtype2 = "facedir", - is_ground_content = false, - stack_max = 64, groups = {cracky=2, container=4, deco_block=1}, + is_ground_content = false, sounds = mcl_sounds.node_sound_stone_defaults(), - on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", furnace_inactive_formspec) - local inv = meta:get_inventory() - inv:set_size("fuel", 1) - inv:set_size("src", 1) - inv:set_size("dst", 1) - end, + + on_timer = furnace_node_timer, after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) local meta2 = meta @@ -54,58 +243,45 @@ minetest.register_node("mcl_furnaces:furnace", { end meta:from_table(meta2:to_table()) end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) + + on_construct = function(pos) local meta = minetest.get_meta(pos) + meta:set_string("formspec", inactive_formspec) local inv = meta:get_inventory() - if listname == "fuel" then - if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then - return stack:get_count() - else - return 0 - end - elseif listname == "src" then - return stack:get_count() - elseif listname == "dst" then - return 0 - end + inv:set_size('src', 1) + inv:set_size('fuel', 1) + inv:set_size('dst', 1) end, - allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local stack = inv:get_stack(from_list, from_index) - if to_list == "fuel" then - if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then - return count - else - return 0 - end - elseif to_list == "src" then - return count - elseif to_list == "dst" then - return 0 - end + + on_metadata_inventory_move = function(pos) + minetest.get_node_timer(pos):start(1.0) end, + on_metadata_inventory_put = function(pos) + -- start timer function, it will sort out whether furnace can burn or not. + minetest.get_node_timer(pos):start(1.0) + end, + + allow_metadata_inventory_put = allow_metadata_inventory_put, + allow_metadata_inventory_move = allow_metadata_inventory_move, + allow_metadata_inventory_take = allow_metadata_inventory_take, on_receive_fields = craftguide, }) minetest.register_node("mcl_furnaces:furnace_active", { description = "Furnace", - tiles = {"default_furnace_top.png", "default_furnace_bottom.png", "default_furnace_side.png", - "default_furnace_side.png", "default_furnace_side.png", "default_furnace_front_active.png"}, + tiles = { + "default_furnace_top.png", "default_furnace_bottom.png", + "default_furnace_side.png", "default_furnace_side.png", + "default_furnace_side.png", "default_furnace_front_active.png", + }, paramtype2 = "facedir", - is_ground_content = false, light_source = 13, drop = "mcl_furnaces:furnace", - groups = {cracky=2, container=4, not_in_creative_inventory=1}, + groups = {cracky=2, container=4, deco_block=1, not_in_creative_inventory=1}, + is_ground_content = false, sounds = mcl_sounds.node_sound_stone_defaults(), - on_construct = function(pos) - local meta = minetest.get_meta(pos) - meta:set_string("formspec", furnace_inactive_formspec) - local inv = meta:get_inventory() - inv:set_size("fuel", 1) - inv:set_size("src", 1) - inv:set_size("dst", 1) - end, + on_timer = furnace_node_timer, + after_dig_node = function(pos, oldnode, oldmetadata, digger) local meta = minetest.get_meta(pos) local meta2 = meta @@ -120,153 +296,11 @@ minetest.register_node("mcl_furnaces:furnace_active", { end meta:from_table(meta2:to_table()) end, - allow_metadata_inventory_put = function(pos, listname, index, stack, player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - if listname == "fuel" then - if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then - return stack:get_count() - else - return 0 - end - elseif listname == "src" then - return stack:get_count() - elseif listname == "dst" then - return 0 - end - end, - allow_metadata_inventory_move = function(pos, from_list, from_index, to_list, to_index, count, player) - local meta = minetest.get_meta(pos) - local inv = meta:get_inventory() - local stack = inv:get_stack(from_list, from_index) - if to_list == "fuel" then - if minetest.get_craft_result({method="fuel",width=1,items={stack}}).time ~= 0 then - return count - else - return 0 - end - elseif to_list == "src" then - return count - elseif to_list == "dst" then - return 0 - end - end, + + + allow_metadata_inventory_put = allow_metadata_inventory_put, + allow_metadata_inventory_move = allow_metadata_inventory_move, + allow_metadata_inventory_take = allow_metadata_inventory_take, on_receive_fields = craftguide, }) -minetest.register_abm({ - nodenames = {"mcl_furnaces:furnace","mcl_furnaces:furnace_active"}, - interval = 1.0, - chance = 1, - action = function(pos, node, active_object_count, active_object_count_wider) - local meta = minetest.get_meta(pos) - for i, name in ipairs({ - "fuel_totaltime", - "fuel_time", - "src_totaltime", - "src_time" - }) do - if meta:get_string(name) == "" then - meta:set_float(name, 0.0) - end - end - - local inv = meta:get_inventory() - - local srclist = inv:get_list("src") - local cooked = nil - local aftercooked - - if srclist then - cooked, aftercooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) - end - - local was_active = false - - if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then - was_active = true - meta:set_float("fuel_time", meta:get_float("fuel_time") + 1) - meta:set_float("src_time", meta:get_float("src_time") + 1) - if cooked and cooked.item and meta:get_float("src_time") >= cooked.time then - -- check if there's room for output in "dst" list - if inv:room_for_item("dst",cooked.item) then - -- Put result in "dst" list - inv:add_item("dst", cooked.item) - -- take stuff from "src" list - inv:set_stack("src", 1, aftercooked.items[1]) - else - print("Could not insert '"..cooked.item:to_string().."'") - end - meta:set_string("src_time", 0) - end - end - - if meta:get_float("fuel_time") < meta:get_float("fuel_totaltime") then - local percent = math.floor(meta:get_float("fuel_time") / - meta:get_float("fuel_totaltime") * 100) - minetest.swap_node(pos, { name = "mcl_furnaces:furnace_active", param = node.param, param2 = node.param2 }) - meta:set_string("formspec", - "size[9,8.75]".. - "background[-0.19,-0.25;9.41,9.49;crafting_formspec_bg.png^crafting_inventory_furnace.png]".. - mcl_vars.inventory_header.. - "list[current_player;main;0,4.5;9,3;9]".. - "list[current_player;main;0,7.74;9,1;]".. - "list[current_name;src;2.75,0.5;1,1;]".. - "list[current_name;fuel;2.75,2.5;1,1;]".. - "list[current_name;dst;5.75,1.5;1,1;]".. - "image[2.75,1.5;1,1;default_furnace_fire_bg.png^[lowpart:".. - (100-percent)..":default_furnace_fire_fg.png]".. - "image_button[8,0;1,1;craftguide_book.png;__mcl_craftguide;]".. - "tooltip[__mcl_craftguide;Show crafting recipes]".. - "listring[current_name;dst]".. - "listring[current_player;main]".. - "listring[current_name;src]".. - "listring[current_player;main]".. - "listring[current_name;fuel]".. - "listring[current_player;main]") - return - end - - local fuel = nil - local afterfuel - local cooked = nil - local fuellist = inv:get_list("fuel") - local srclist = inv:get_list("src") - - if srclist then - cooked = minetest.get_craft_result({method = "cooking", width = 1, items = srclist}) - end - if fuellist then - fuel, afterfuel = minetest.get_craft_result({method = "fuel", width = 1, items = fuellist}) - end - - if fuel.time <= 0 then - minetest.swap_node(pos, { name = "mcl_furnaces:furnace", param = node.param, param2 = node.param2 }) - meta:set_string("formspec", furnace_inactive_formspec) - return - end - - if cooked.item:is_empty() then - if was_active then - minetest.swap_node(pos, { name = "mcl_furnaces:furnace", param = node.param, param2 = node.param2 }) - meta:set_string("formspec", furnace_inactive_formspec) - end - return - end - - meta:set_string("fuel_totaltime", fuel.time) - meta:set_string("fuel_time", 0) - - inv:set_stack("fuel", 1, afterfuel.items[1]) - end, -}) - -minetest.register_craft({ - output = 'mcl_furnaces:furnace', - recipe = { - {'mcl_core:cobble', 'mcl_core:cobble', 'mcl_core:cobble'}, - {'mcl_core:cobble', '', 'mcl_core:cobble'}, - {'mcl_core:cobble', 'mcl_core:cobble', 'mcl_core:cobble'}, - } -}) - diff --git a/mods/ITEMS/mcl_furnaces/textures/default_furnace_bg.png b/mods/ITEMS/mcl_furnaces/textures/default_furnace_bg.png deleted file mode 100644 index a538893296975d46a4502f38bcc4888a3f88f32c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1189 zcmeAS@N?(olHy`uVBq!ia0y~yU`zmF9}Z@q$f1kVjDeJ8fKP~PcX#)(W5@pg{|^)} zH#ZLr4ULbFFDfbmiud*Pty;Be$BrF91!vEmy>jKs_3PIkJ$m%v!v~=HVAcXTpdRLu zAirQB{j2QAJq89A2~QWtkcwMx@80%%Z6LsUp|E%dJJ;X;{kFN2-FQWcHZPp8HC}4r z#6^0M$2MB|VwI5<% zYF{v3pQO9?{as0eDQ7Hy+`AK^o}jR^_zP={p8I{i8Sek?FtG7NFfg;}G%zxY9cW-R zNI1YGVUWPc10)VKs6Q*Sh(6%m@Siu8y+ZQCUk9K{hzuiM#-Hzv`ODL}D=z(Amd0-J z{_m-~@*v~Z^H+R`@jcMJ??ahI!+JHw9R>vqdOR`>+|29`zI$qF7cl(em{Y{W{(xKA zB9(>jK<)i4@o`UQswV|h%spV3RBOs9>%DF6%aNLxwwNk9}@E1QFk-si;Ld!0rc%}c@oh@Kx;KBmS#ivm`$7NjgW?UBbsk84 zI3Oa}y{tp3AP~srX9oouBlEw_?=MCqN?-rJ&)r#hk(&!x?C^ozD;aHG*4=)|_{SR* zWgt=fk@F#+>EFHY8Eg1|%)Y;Pqtydbq}blT080Xl+z_KcDPmg9fn-1TP~&%BZk#@# z3}yK@wAaV2O1pDDA86qkHlWQPpvl4%=7b6eV}lgXQHPl!DdsA}zsd&>F9%-jv9|qY z^q~X73hQr^k4eU<(@<<4rgG`yB)AeH;kkWVHVtQXYzft7lUFQ5%i{D><%sl1I z9^Qi2)#b`Riy59pUnm!z?R#{)PQj`lVxMgp-XAXrJ*aVD_xIce>Ex4hl;70*%yNGE UX@AKVU{S%~>FVdQ&MBb@01N=@1^@s6 diff --git a/mods/ITEMS/mcl_furnaces/textures/gui_furnace_arrow_bg.png b/mods/ITEMS/mcl_furnaces/textures/gui_furnace_arrow_bg.png new file mode 100644 index 0000000000000000000000000000000000000000..587685717cf6def4cf38f96801542d7d26d382e1 GIT binary patch literal 370 zcmeAS@N?(olHy`uVBq!ia0vp^3P5bY!2%?2E#2@0NU@|l`Z_W&Z0zU$lgJ9>D%scCL%%3`(MvwT5+Hmg{S=7#Xw|06!G=dr$b?&E{Ce0G2C z9`3f^{o`Zxe8E4b4BEn37gq#!*sjRh%2~v(BiBT7;dOH!?pi&B9UgOP!uxvqhcu90DgfuWUwnU#Ts nHi%*1HTxORJ4hOG^HVa@DsgMDJ{A`O)WG2B>gTe~DWM4f1k`8_ literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_furnaces/textures/mcl_furnaces_formspec.png b/mods/ITEMS/mcl_furnaces/textures/mcl_furnaces_formspec.png new file mode 100644 index 0000000000000000000000000000000000000000..f8191ffd2272529bfe9e74bb1ade663c5f859e1d GIT binary patch literal 2718 zcmeAS@N?(olHy`uVBq!ia0y~yVDLBZQ@pfqDikY6x^!?PP{AWo9Ey9-kqcTEbA z!(QU)>&pI+NtBU+gZWa4KLZ12fv1aONX4zUcOCPD*%{gbzjG{m#9*QBAZqE5KY>+! z!xZfcwdR}O_1(TUL1@m6W69q0X0ETC-}0!%KGDcuthw{))vUEgw@0n5tKNR`(C-b! zQRiy~tZuj8m3?*h4*SB*cWeJV{PO%x`=a=g?}dNQzI?~8yUTyRyaj7j(XQFQ4NBDf zdM!*JUFir`CXSK!`pb_yckZX#LX^L_=2u)_|9?8fjK!Mkl&YahW|k z|B5|^n7wRwU&YHWhhIEB{(bxU*!cW=VRNJkvyQC17~^-`eqVj)$D+^Ih<7T@1auYP& zkd!#-pm^F7lUJ!S&+Sgkd~_wl)6Ytl{!#Pg*2{k%qi<{PyYx47{?bBdZfL(Qczs^J z-}W9zuCaRhrNs8*kNa=m9(*s8*LU|;UH$tH*)J|ZGwNl(+t0rryJPpS@^{?t=vXO; zFG_Y^e*F3B;mYN2SFbqi4A+&=-62DpWCw)y0R8e|IyH z@V5r~w0h5;q3>aEM12$lmR(AZGmis#>!ss5G3t{SA3pAd#kib){!or#q?B26B=bhk ziHcjmbb8};TQ~_7DOy>z`0(@Wo(zL|Wxy=(?a$Cl^+;iYoQVl#1|nM>Xn}>IOZC^6 znZXO+`@Ozjp1?)FK#IZ0z|dURz)07~FvP&n3W$u&v_TAmvhR)hC>nC} gQ!>*k(KQ%Y8CXCxnBCA525MmNboFyt=akR{0GkN)xc~qF literal 0 HcmV?d00001