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 zcmeHP4{#Gz8vjDkifHQ{=O9|hjX1~6!BxiUky_h56s+hNPSgoS+TaNksM^>ffre%) zJ?%KmQ8@(8p>4)ftP!rS$>8*uvRQ&IZ_9J)V931^^hRc`UCKVEiwHKN-GMy%_-RSUq>)>ZgmBuhu?a zvJ5oOuY7rR`pe5!|N8#)ndzA?X6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3l(L2$`zNFnf;nbJI1%Zg$^Izb8@b37E-#^kBmBcp02&C>O^HY z^&8?{-}f9BK05Zr)RcOh_ZfbbC$PUw5VtsiW-z_#MCCF;A^3NVjq}h_DOig%z zC^K}4B70%N1BlEBwpfyY1aZG!QJrhf;q zNuM^gtf0?OeQeR$QOEjSr9GOmnMlSwu$up#Bgb}N-67YI73a6yEn!j;CY4YUU&^ry z{A8bm=Pbv8+B|oJ=QwlVtKr`Vg*y|K%+MA~+arQzx`AvZU z<6O+_j^6B!N(2j_4z=X6x#7!E5H{Rn076;U{`W+#>6bZN&!yJmY>)gFQ9X@oCVEe@ zS(mG&PE)3y!IqG39Q&T*-}Mj9s#etSVJp61sg!GxaxDoJ4M@3`;yejAmT=>rEp99! z`af4hU$Ts38L6m8D(aDndJ?Hll>*J{7-&X1+xn_8J~XlG%G1WZn#f%Od>|BFUv6_f zs!m(n-~#}jd_8{9^O|nJf8>vn%0p!{Ul%j$=)|TEa37gczt#@`7W@zB)9pNs`bmCc z^!^Z@ru@=;3&4Qku%Y;U^s0gjSFB2v0kDOG#m!%$Pq*;v@8|mQ9;@nhfx@2=T|1;k b9Vqqg;@e-@y7Tca0DyUOm2(;%Ub5joH+Xq* 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 zcmeHP4{#Gz8vjDkifHQ`=O9|hjX1~6!BxiUky_h5L_~B9=f4R>+TaNksM^>9fu_w? zdS}OBj_M(B4sA1@VwFJmkk*1F+0=3up-50nqp5TgN(rQdElu-x|Gb;sq>x@^41%0D zvzhJYbvN&O-@o_vd%y2X-uR<(-mN#^c{2dqI{&dpo(4!!0;Jq_(~SUd+dU5mZ)1yQ zKRFv0xt}FC$vp-(?#@4sM^j{xba>ju? z#;5Pww_;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t_GrlWO=5@#=1$!`h;80TVUcl2g=R3caa zb*Lqm%?)3Ug0SHp0}#%+_P-}`O~1_Hem=bsXM5$hi0WxxJJEN7&AD7Hb%rwiG`56% z{pj}`|89J6R;{9rkJ#|1mrA)7Dc6!z(SVd|Dan^`V+l9@+2Y0$qW^P6^d-wkmXV5j zq@o_Fs3)1~R4LHBj)7*htK)1f#)l_%UwPWNPZPaMfDeSi>&tDfN7ZSI8+-u3Q?JJl zdS25F_>cTiQhB(1=3m6jIy%1T1KdxhHLeQ)fCc|O`g9vlqkfX#7`s1&XDGik-vTgT zIAkb!AFWYvk*ZbcG61${u%z`%^yy~4;(o3l@3pCJ7byG*(e*=W)QQsXF1h{HEju3X Q1^}2pSNTZO!%H^&2hCe`&Hw-a 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`$|OVD#Z&W?*1Aba9$70|SF)fKP~PcX#)(W5@pg z|Ifg{U~X<68X6iOA74~d)ZN|P*Vngd)v6skb{so)?CjaISFT*Se*OBRM~^;y`0)S# z|6tYvIR*v>=8_=4UED%DYsZ4K@zRaV!o>^o57{nPHc z=z~T3{QIw}{Sf<7`-1WMB;B>|?@Ag>Ib-?b-klKj1cjZ&Usz-G-0$aIM!Ig$3 zhUb$WH!y#&EGWNu(#7_`Vzi8%f9gT)6euX1q&GLq_@BA@SU6Ud19Nuex3)L zI~9Y}?^qpAdcaV_H^*=KOO~2SzCPDOt6B5fvc2#2zVvp!!7-2L4&U{|^IVS9vdefk zo;|qN_Slu)JHiD^R=(y~-EqFr`hNL=OuY@I1@&z!&PN(ER8RUXWTDHtP27;-&e>z1 z8{RIf<(u)kSYj#AoYQt9TaGc%>OpOzZj7yef|4BcW32AZZ2T4 z!v}V+WVCr%cl#ydA8$~Ufkg2~&WC)afA_v;tl|GL`~KpMRu4>(VtWGvED11jLyQ8Y zh-ozklKtF6jo*E_ar%HVl;z*hULUtA?aujpMrO7(Yz7GjK0uR&Da;8K5XJ_n0}YIa znIS3WD#O3Z2M;d?UhT2A{bux`1HuaHZf0hLH#4d7cP{|8fbn zC#t4?)w=x#B!=pCr~@7{LV`F8`yB)AeK9f&BIQ z4qQy{Yv(tLe7wt?ziRRO%a56-yxGHB@VdHO`DZc1v*-)u!n1vkZr3ST^+W8lEyMfc q1)&Eu4($G(+aR5Ma*pzwdY@U&Pe1K1`NF`!z~JfX=d#Wzp$PyC0P6+- 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!ia0y~yU{GLSU@+idVPIgmwRFQ11_lO}bVpxD28NCO+mi?V3(d3p_MEJ^JADmn#-Ezzrlu@b+daz{^k=h*#b|B_zx_Yr<9Z(J zd*?nrSj%Vk=kDQd``tf2R?ipwbIPDCoON+UV2ACBtgW0y{5s-I0xb$GiW~>`vwVKf za3R_1_7l(PrVI=WswJ)wB`Jv|saDBFsfi`23`Pcq=DG$(x<-Z}28LD!W>yA<+8~C( jedfj1C>nC}Q!>*kacfu?C*97#z`)??>gTe~DWM4f$*p)c literal 0 HcmV?d00001 diff --git a/mods/ITEMS/mcl_furnaces/textures/gui_furnace_arrow_fg.png b/mods/ITEMS/mcl_furnaces/textures/gui_furnace_arrow_fg.png new file mode 100644 index 0000000000000000000000000000000000000000..7a9ec4e5ea3f6c03191ba730f6854edbd0e16bbc GIT binary patch literal 341 zcmeAS@N?(olHy`uVBq!ia0y~yU{GLSU@+idU|?VfJ+8i)fq{V~-O<;Pfnj4m_n$;o zkb-27AYTTCDm4a%h86~fUknTk4KElNN(~qoUL`OvSj}Ky5HFasE6|34fq|(c$S;_I zp=|P53lJ~K+ueoXe|!I#{R|8Y>?NMQuIvw)L>bvQLOU*>WME+M_jGX#u{izq;zr&E z0|6FC?puomx|RyAk|=5_Z8)*#=4~6@vd$@?2>=AtXbu1X 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~yVD@8RU>0CuW?*1=#HC@%z`($g?&#~tz_78O`%fY( z0|SFXvPY0F14ES>14Ba#1H&%{28M z$s@kK_w6sw-L7hRR&Efw8XS9M1!v}+OsR_nmzf`!yfP`Yy18hM+niZvb@>x+#M~%( z-g`N2j+^Q3%T3U9LsH_TgW_pVOkSnRJhwYB^U;+IPd_VJ`bW)|TQC28jJ~bC@6zAU z`AZ9-xuN~K;PrX=e%pH>xyI`0mlE5LKkmPMd+@zXUf%f-ga(*=2t zUGB3qJ$8J~zIpk{Hg9JHC!bkq`0R>AaaNC|>9ILd$$q_t%a08;VfQ(0XFGb9%NA$# z?9HoC#VA%6A3pxw%|ycA`q>qU>OFggzK6jP^-*wnqOsEB%;R&UlGjVebz;;fFFt(S z3yX0%{rsUE!$>K!=1As^o)Z8G5N6 zDNK+vF`>*rWUB)$uuycV{`xXAc;S1$*Z0fww|tNb)AnmD^LzchSia@l*9~!N!`?r) zdYUViKD!Yx0-{xiMRyO-2^_0b6i1_sp<*NBpo#FA92^QD+5C-V>4|K!=UVYqdtm;-29Zxv`Tah237_Z5DjKG^n@807#KWV{an^LB{Ts5 Dn+Wx} literal 0 HcmV?d00001