From 84bcfd0913354395076dfb593ad6cfc9e7a672a7 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 04:52:19 +0200 Subject: [PATCH 01/12] Rudimentary banner crafting code --- mods/ITEMS/mcl_banners/init.lua | 113 +++++++++++++++++++++++++++++++- 1 file changed, 111 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 06bd3afed7..604bb57731 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -128,7 +128,7 @@ minetest.register_node("mcl_banners:standing_banner", { wield_image = "mcl_banners_item_base.png", tiles = { "blank.png" }, selection_box = {type = "fixed", fixed= {-0.2, -0.5, -0.2, 0.2, 0.5, 0.2} }, - groups = { banner = 1, deco_block = 1, attached_node = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1, }, + groups = { deco_block = 1, attached_node = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1, }, stack_max = 16, sounds = node_sounds, drop = "", -- Item drops are handled in entity code @@ -161,6 +161,8 @@ for colorid, colortab in pairs(colors) do _doc_items_longdesc = "Banners are tall decorative blocks with a solid color. They can be placed on the floor. Banners can not be emblazoned (yet).", inventory_image = inv, wield_image = inv, + -- Banner group groups together the banner items, but not the nodes. + -- Used for crafting. groups = { banner = 1, deco_block = 1, }, stack_max = 16, @@ -191,7 +193,11 @@ for colorid, colortab in pairs(colors) do place_pos.y = place_pos.y - 0.5 local banner = minetest.add_entity(place_pos, "mcl_banners:standing_banner") - banner:get_luaentity():_set_textures(colorid) + local imeta = itemstack:get_meta() + local layers_raw = imeta:get_string("layers") + local layers = minetest.deserialize(layers_raw) + banner:get_luaentity():_set_textures(colorid, layers) + -- Determine the rotation based on player's yaw local yaw = placer:get_look_horizontal() @@ -278,6 +284,109 @@ minetest.register_entity("mcl_banners:standing_banner", { end, }) +minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) + if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then + return + end + + local original + local index + for i = 1, player:get_inventory():get_size("craft") do + if minetest.get_item_group(old_craft_grid[i]:get_name(), "banner") == 1 then + original = old_craft_grid[i] + index = i + end + end + if not original then + return + end + + local imeta = itemstack:get_meta() + + imeta:set_string("description", "Emblazoned Banner") + return itemstack +end) + + +minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) + if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then + return + end + + local original + local index + for i = 1, player:get_inventory():get_size("craft") do + local itemname = old_craft_grid[i]:get_name() + if minetest.get_item_group(itemname, "banner") == 1 then + original = old_craft_grid[i] + index = i + end + end + if not original then + return + end + + local ometa = original:get_meta() + local layers_raw = ometa:get_string("layers") + local layers = minetest.deserialize(layers_raw) + if type(layers) ~= "table" then + layers = {} + end + + table.insert(layers, {pattern="circle", color = "unicolor_yellow"}) + + local imeta = itemstack:get_meta() + imeta:set_string("layers", minetest.serialize(layers)) + + imeta:set_string("description", "Emblazoned Banner") + return itemstack +end) + +minetest.register_craft({ + recipe = { + { "", "", "" }, + { "", "mcl_banners:banner_item_red", "" }, + { "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, + }, + output = "mcl_banners:banner_item_red", +}) + +minetest.register_craft({ + recipe = { + { "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, + { "", "mcl_banners:banner_item_red", "" }, + { "", "", "" }, + }, + output = "mcl_banners:banner_item_red", +}) + +minetest.register_craft({ + recipe = { + { "mcl_dye:yellow", "", "" }, + { "mcl_dye:yellow", "mcl_banners:banner_item_red", "" }, + { "mcl_dye:yellow", "", "" }, + }, + output = "mcl_banners:banner_item_red", +}) + +minetest.register_craft({ + recipe = { + { "", "mcl_dye:yellow", "" }, + { "", "mcl_dye:yellow", "mcl_banners:banner_item_red", }, + { "", "mcl_dye:yellow", "" }, + }, + output = "mcl_banners:banner_item_red", +}) + +minetest.register_craft({ + recipe = { + { "", "", "mcl_dye:yellow", }, + { "", "mcl_banners:banner_item_red", "mcl_dye:yellow", }, + { "", "", "mcl_dye:yellow" }, + }, + output = "mcl_banners:banner_item_red", +}) + minetest.register_craft({ type = "fuel", recipe = "group:banner", From b14c33039f9f0f64c986996a70551902cf2669c6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 14:54:34 +0200 Subject: [PATCH 02/12] Move banner pattern code to patterncraft.lua --- mods/ITEMS/mcl_banners/init.lua | 144 +---------------------- mods/ITEMS/mcl_banners/patterncraft.lua | 146 ++++++++++++++++++++++++ 2 files changed, 147 insertions(+), 143 deletions(-) create mode 100644 mods/ITEMS/mcl_banners/patterncraft.lua diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 604bb57731..6d9589c1be 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -32,47 +32,6 @@ local colors = { local base_color_ratio = 224 local layer_ratio = 255 -local patterns = { - "border", - "bricks", - "circle", - "creeper", - "cross", - "curly_border", - "diagonal_left", - "diagonal_right", - "diagonal_up_left", - "diagonal_up_right", - "flower", - "gradient", - "gradient_up", - "half_horizontal_bottom", - "half_horizontal", - "half_vertical", - "half_vertical_right", - "thing", - "rhombus", - "skull", - "small_stripes", - "square_bottom_left", - "square_bottom_right", - "square_top_left", - "square_top_right", - "straight_cross", - "stripe_bottom", - "stripe_center", - "stripe_downleft", - "stripe_downright", - "stripe_left", - "stripe_middle", - "stripe_right", - "stripe_top", - "triangle_bottom", - "triangles_bottom", - "triangles_top", - "triangle_top", -} - -- After destroying the standing banner node local on_destruct_standing_banner = function(pos) -- Find this node's banner entity and make it drop as an item @@ -284,108 +243,7 @@ minetest.register_entity("mcl_banners:standing_banner", { end, }) -minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) - if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then - return - end - - local original - local index - for i = 1, player:get_inventory():get_size("craft") do - if minetest.get_item_group(old_craft_grid[i]:get_name(), "banner") == 1 then - original = old_craft_grid[i] - index = i - end - end - if not original then - return - end - - local imeta = itemstack:get_meta() - - imeta:set_string("description", "Emblazoned Banner") - return itemstack -end) - - -minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) - if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then - return - end - - local original - local index - for i = 1, player:get_inventory():get_size("craft") do - local itemname = old_craft_grid[i]:get_name() - if minetest.get_item_group(itemname, "banner") == 1 then - original = old_craft_grid[i] - index = i - end - end - if not original then - return - end - - local ometa = original:get_meta() - local layers_raw = ometa:get_string("layers") - local layers = minetest.deserialize(layers_raw) - if type(layers) ~= "table" then - layers = {} - end - - table.insert(layers, {pattern="circle", color = "unicolor_yellow"}) - - local imeta = itemstack:get_meta() - imeta:set_string("layers", minetest.serialize(layers)) - - imeta:set_string("description", "Emblazoned Banner") - return itemstack -end) - -minetest.register_craft({ - recipe = { - { "", "", "" }, - { "", "mcl_banners:banner_item_red", "" }, - { "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, - }, - output = "mcl_banners:banner_item_red", -}) - -minetest.register_craft({ - recipe = { - { "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, - { "", "mcl_banners:banner_item_red", "" }, - { "", "", "" }, - }, - output = "mcl_banners:banner_item_red", -}) - -minetest.register_craft({ - recipe = { - { "mcl_dye:yellow", "", "" }, - { "mcl_dye:yellow", "mcl_banners:banner_item_red", "" }, - { "mcl_dye:yellow", "", "" }, - }, - output = "mcl_banners:banner_item_red", -}) - -minetest.register_craft({ - recipe = { - { "", "mcl_dye:yellow", "" }, - { "", "mcl_dye:yellow", "mcl_banners:banner_item_red", }, - { "", "mcl_dye:yellow", "" }, - }, - output = "mcl_banners:banner_item_red", -}) - -minetest.register_craft({ - recipe = { - { "", "", "mcl_dye:yellow", }, - { "", "mcl_banners:banner_item_red", "mcl_dye:yellow", }, - { "", "", "mcl_dye:yellow" }, - }, - output = "mcl_banners:banner_item_red", -}) +dofile(minetest.get_modpath("mcl_banners").."/patterncraft.lua") minetest.register_craft({ type = "fuel", diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua new file mode 100644 index 0000000000..699a1a6fae --- /dev/null +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -0,0 +1,146 @@ +local patterns = { + "border", + "bricks", + "circle", + "creeper", + "cross", + "curly_border", + "diagonal_left", + "diagonal_right", + "diagonal_up_left", + "diagonal_up_right", + "flower", + "gradient", + "gradient_up", + "half_horizontal_bottom", + "half_horizontal", + "half_vertical", + "half_vertical_right", + "thing", + "rhombus", + "skull", + "small_stripes", + "square_bottom_left", + "square_bottom_right", + "square_top_left", + "square_top_right", + "straight_cross", + "stripe_bottom", + "stripe_center", + "stripe_downleft", + "stripe_downright", + "stripe_left", + "stripe_middle", + "stripe_right", + "stripe_top", + "triangle_bottom", + "triangles_bottom", + "triangles_top", + "triangle_top", +} + +minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) + if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then + return + end + + local original + local index + for i = 1, player:get_inventory():get_size("craft") do + if minetest.get_item_group(old_craft_grid[i]:get_name(), "banner") == 1 then + original = old_craft_grid[i] + index = i + end + end + if not original then + return + end + + local imeta = itemstack:get_meta() + + imeta:set_string("description", "Emblazoned Banner") + return itemstack +end) + + +minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) + if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then + return + end + + local original + local index + for i = 1, player:get_inventory():get_size("craft") do + local itemname = old_craft_grid[i]:get_name() + if minetest.get_item_group(itemname, "banner") == 1 then + original = old_craft_grid[i] + index = i + end + end + if not original then + return + end + + local ometa = original:get_meta() + local layers_raw = ometa:get_string("layers") + local layers = minetest.deserialize(layers_raw) + if type(layers) ~= "table" then + layers = {} + end + + table.insert(layers, {pattern="circle", color = "unicolor_yellow"}) + + local imeta = itemstack:get_meta() + imeta:set_string("layers", minetest.serialize(layers)) + + imeta:set_string("description", "Emblazoned Banner") + return itemstack +end) + + +minetest.register_craft({ + recipe = { + { "", "", "" }, + { "", "mcl_banners:banner_item_red", "" }, + { "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, + }, + output = "mcl_banners:banner_item_red", +}) + +minetest.register_craft({ + recipe = { + { "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, + { "", "mcl_banners:banner_item_red", "" }, + { "", "", "" }, + }, + output = "mcl_banners:banner_item_red", +}) + +minetest.register_craft({ + recipe = { + { "mcl_dye:yellow", "", "" }, + { "mcl_dye:yellow", "mcl_banners:banner_item_red", "" }, + { "mcl_dye:yellow", "", "" }, + }, + output = "mcl_banners:banner_item_red", +}) + +minetest.register_craft({ + recipe = { + { "", "mcl_dye:yellow", "" }, + { "", "mcl_dye:yellow", "mcl_banners:banner_item_red", }, + { "", "mcl_dye:yellow", "" }, + }, + output = "mcl_banners:banner_item_red", +}) + +minetest.register_craft({ + recipe = { + { "", "", "mcl_dye:yellow", }, + { "", "mcl_banners:banner_item_red", "mcl_dye:yellow", }, + { "", "", "mcl_dye:yellow" }, + }, + output = "mcl_banners:banner_item_red", +}) + + From ba224104c84f9b8bf460b2aabb91b12d2115a3e0 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 14:56:49 +0200 Subject: [PATCH 03/12] Adjust banner stand icon coloring --- .../textures/mcl_banners_item_base.png | Bin 163 -> 134 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/mods/ITEMS/mcl_banners/textures/mcl_banners_item_base.png b/mods/ITEMS/mcl_banners/textures/mcl_banners_item_base.png index 47f4348996dda60a0fea8c083846f150ab296ad6..31a75b37b29a5b6d02998a712367c41c3577229d 100644 GIT binary patch delta 117 zcmZ3?*v2?PB9Dogfq@}uuJ|V)#S`EY;tHfAz3o%NJn|9(8@d!00{M(3L4Lsu4$p3+ z0XZ6;E{-7;jL8iRd;U8#{bcCKU=Zp_IK=2-VA*i=z@`~2!ZR`&1QHk+%Dgyv_xCO1 Q2kK$)boFyt=akR{0G!<;NdN!< delta 147 zcmZo;T+BE@qMn0^fq`Md#0)ba#a0sJ7Yw9Eakt!I->&L&Y*vyh1vZ zJzDI?j4N$X2L%)729zFYj?q_EP;zvhIA2rX;7*f*phbJx1ST#}ynk9_{>m{an^LB{Ts5fvhh@ From 423196d65cf312257df912cb09142fc2424e50fa Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 17:23:13 +0200 Subject: [PATCH 04/12] Add banner emblazoning recipes (WIP) --- mods/ITEMS/mcl_banners/init.lua | 48 ++-- mods/ITEMS/mcl_banners/patterncraft.lua | 302 +++++++++++++++++------- 2 files changed, 244 insertions(+), 106 deletions(-) diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 6d9589c1be..eacf5171a9 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -9,24 +9,26 @@ local function round(num, idp) return math.floor(num * mult + 0.5) / mult end -local colors = { - -- ID, description, wool, unified dyes color group, overlay color, - ["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF" }, - ["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030" }, - ["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B" }, - ["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000" }, - ["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000" }, - ["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800" }, - ["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000" }, - ["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC" }, - ["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC" }, - ["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C" }, - ["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900" }, - ["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC" }, - ["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100" }, - ["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C" }, - ["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00"}, - ["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF" }, +mcl_banners = {} + +mcl_banners.colors = { + -- ID, description, wool, unified dyes color group, overlay color, dye + ["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF", "mcl_dye:white" }, + ["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030", "mcl_dye:dark_grey" }, + ["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B", "mcl_dye:grey" }, + ["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000", "mcl_dye:black" }, + ["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000", "mcl_dye:red" }, + ["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800", "mcl_dye:yellow" }, + ["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000", "mcl_dye:dark_green" }, + ["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC", "mcl_dye:cyan" }, + ["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC", "mcl_dye:blue" }, + ["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C", "mcl_dye:magenta" }, + ["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900", "mcl_dye:orange" }, + ["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC", "mcl_dye:violet" }, + ["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100", "mcl_dye:brown" }, + ["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C", "mcl_dye:pink" }, + ["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00", "mcl_dye:green" }, + ["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF", "mcl_dye:lightblue" }, } -- Overlay ratios (0-255) local base_color_ratio = 224 @@ -45,8 +47,8 @@ end local make_banner_texture = function(base_color, layers) local colorize - if colors[base_color] then - colorize = colors[base_color][4] + if mcl_banners.colors[base_color] then + colorize = mcl_banners.colors[base_color][4] end if colorize then -- Base texture with base color @@ -58,7 +60,7 @@ local make_banner_texture = function(base_color, layers) for l=1, #layers do local layerinfo = layers[l] local pattern = "mcl_banners_" .. layerinfo.pattern .. ".png" - local color = colors[layerinfo.color][4] + local color = mcl_banners.colors[layerinfo.color][4] -- Generate layer texture local layer = "(("..pattern.."^[colorize:"..color..":"..layer_ratio..")^[mask:"..pattern..")" @@ -97,7 +99,7 @@ minetest.register_node("mcl_banners:standing_banner", { _mcl_blast_resistance = 5, }) -for colorid, colortab in pairs(colors) do +for colorid, colortab in pairs(mcl_banners.colors) do local itemid = colortab[1] local desc = colortab[2] local wool = colortab[3] @@ -221,7 +223,7 @@ minetest.register_entity("mcl_banners:standing_banner", { pos.y = pos.y + 1 if not minetest.settings:get_bool("creative_mode") and self._base_color then - minetest.add_item(pos, "mcl_banners:banner_item_"..colors[self._base_color][1]) + minetest.add_item(pos, "mcl_banners:banner_item_"..mcl_banners.colors[self._base_color][1]) end -- Destroy entity diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index 699a1a6fae..cc808009a2 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -1,42 +1,192 @@ +-- List of patterns with crafting rules + +local d = "%D" -- dye +local e = "" -- empty slot (one of them must contain the banner) local patterns = { - "border", - "bricks", - "circle", - "creeper", - "cross", - "curly_border", - "diagonal_left", - "diagonal_right", - "diagonal_up_left", - "diagonal_up_right", - "flower", - "gradient", - "gradient_up", - "half_horizontal_bottom", - "half_horizontal", - "half_vertical", - "half_vertical_right", - "thing", - "rhombus", - "skull", - "small_stripes", - "square_bottom_left", - "square_bottom_right", - "square_top_left", - "square_top_right", - "straight_cross", - "stripe_bottom", - "stripe_center", - "stripe_downleft", - "stripe_downright", - "stripe_left", - "stripe_middle", - "stripe_right", - "stripe_top", - "triangle_bottom", - "triangles_bottom", - "triangles_top", - "triangle_top", + ["border"] = { + { d, d, d }, + { d, e, d }, + { d, d, d }, + }, + ["bricks"] = { + type = "shapeless", + { "mcl_core:brick_block", d }, + }, + ["circle"] = { + { e, e, e }, + { e, d, e }, + { e, e, e }, + }, + ["creeper"] = { + type = "shapeless", + { "mcl_heads:creeper", d }, + }, + ["cross"] = { + { d, e, d }, + { e, d, e }, + { d, e, d }, + }, + ["curly_border"] = { + type = "shapless", + { "mcl_core:vine", d }, + }, + ["diagonal_left"] = { + { e, e, e }, + { d, e, e }, + { d, d, e }, + }, + ["diagonal_right"] = { + { e, e, e }, + { e, e, d }, + { e, d, d }, + }, + ["diagonal_up_left"] = { + { e, d, d }, + { e, e, d }, + { e, e, e }, + }, + ["diagonal_up_right"] = { + { d, d, e }, + { d, e, e }, + { e, e, e }, + }, + ["flower"] = { + type = "shapeless", + { "mcl_flowers:oxeye_daisy", d }, + }, + ["gradient"] = { + { d, e, d }, + { e, d, e }, + { e, d, e }, + }, + ["gradient_up"] = { + { e, d, e }, + { e, d, e }, + { d, e, d }, + }, + ["half_horizontal_bottom"] = { + { e, e, e }, + { d, d, d }, + { d, d, d }, + }, + ["half_horizontal"] = { + { d, d, d }, + { d, d, d }, + { e, e, e }, + }, + ["half_vertical"] = { + { d, d, e }, + { d, d, e }, + { d, d, e }, + }, + ["half_vertical_right"] = { + { e, d, d }, + { e, d, d }, + { e, d, d }, + }, + ["thing"] = { + type = "shapeless", + { "mcl_core:apple_gold", d }, + }, + ["rhombus"] = { + { e, d, e }, + { d, e, d }, + { e, d, e }, + }, + ["skull"] = { + type = "shapeless", + { "mcl_heads:wither_skeleton", d }, + }, + ["small_stripes"] = { + { d, e, d }, + { d, e, d }, + { e, e, e }, + }, + ["square_bottom_left"] = { + { e, e, e }, + { e, e, e }, + { d, e, e }, + }, + ["square_bottom_right"] = { + { e, e, e }, + { e, e, e }, + { e, e, d }, + }, + ["square_top_left"] = { + { d, e, e }, + { e, e, e }, + { e, e, e }, + }, + ["square_top_right"] = { + { e, e, d }, + { e, e, e }, + { e, e, e }, + }, + ["straight_cross"] = { + { e, d, e }, + { d, d, d }, + { e, d, e }, + }, + ["stripe_bottom"] = { + { e, e, e }, + { e, e, e }, + { d, d, d }, + }, + ["stripe_center"] = { + { e, e, e }, + { d, d, d }, + { e, e, e }, + }, + ["stripe_downleft"] = { + { e, e, d }, + { e, d, e }, + { d, e, e }, + }, + ["stripe_downright"] = { + { d, e, e }, + { e, d, e }, + { e, e, d }, + }, + ["stripe_left"] = { + { d, e, e }, + { d, e, e }, + { d, e, e }, + }, + ["stripe_middle"] = { + { e, d, e }, + { e, d, e }, + { e, d, e }, + }, + ["stripe_right"] = { + { e, e, d }, + { e, e, d }, + { e, e, d }, + }, + ["stripe_top"] = { + { d, d, d }, + { e, e, e }, + { e, e, e }, + }, + ["triangle_bottom"] = { + { e, e, e }, + { e, d, e }, + { d, e, d }, + }, + ["triangles_bottom"] = { + { e, e, e }, + { d, e, d }, + { e, d, e }, + }, + ["triangles_top"] = { + { e, d, e }, + { d, e, d }, + { e, e, e }, + }, + ["triangle_top"] = { + { d, e, d }, + { e, d, e }, + { e, e, e }, + }, } minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) @@ -97,50 +247,36 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv return itemstack end) - -minetest.register_craft({ - recipe = { - { "", "", "" }, - { "", "mcl_banners:banner_item_red", "" }, - { "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, - }, - output = "mcl_banners:banner_item_red", -}) - -minetest.register_craft({ - recipe = { - { "mcl_dye:yellow", "mcl_dye:yellow", "mcl_dye:yellow" }, - { "", "mcl_banners:banner_item_red", "" }, - { "", "", "" }, - }, - output = "mcl_banners:banner_item_red", -}) - -minetest.register_craft({ - recipe = { - { "mcl_dye:yellow", "", "" }, - { "mcl_dye:yellow", "mcl_banners:banner_item_red", "" }, - { "mcl_dye:yellow", "", "" }, - }, - output = "mcl_banners:banner_item_red", -}) - -minetest.register_craft({ - recipe = { - { "", "mcl_dye:yellow", "" }, - { "", "mcl_dye:yellow", "mcl_banners:banner_item_red", }, - { "", "mcl_dye:yellow", "" }, - }, - output = "mcl_banners:banner_item_red", -}) - -minetest.register_craft({ - recipe = { - { "", "", "mcl_dye:yellow", }, - { "", "mcl_banners:banner_item_red", "mcl_dye:yellow", }, - { "", "", "mcl_dye:yellow" }, - }, - output = "mcl_banners:banner_item_red", -}) +-- Register crafting recipes for all the patterns +for pattern_name, pattern in pairs(patterns) do + if pattern.type == nil then + for colorid, colortab in pairs(mcl_banners.colors) do + local banner = "mcl_banners:banner_item_"..colortab[1] + local bannered = false + local recipe = {} + for row_id=1, #pattern do + local row = pattern[row_id] + local newrow = {} + for r=1, #row do + if row[r] == d then + newrow[r] = "group:dye" + elseif row[r] == e and not bannered then + newrow[r] = banner + bannered = true + else + newrow[r] = row[r] + end + end + table.insert(recipe, newrow) + end + minetest.register_craft({ + output = "mcl_banners:banner_item_"..colortab[1], + recipe = recipe, + }) + end + elseif pattern.type == "shapeless" then + -- TODO + end +end From b01850e182923fe5b965d9cd8e7b6c7ad1098c73 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 17:25:59 +0200 Subject: [PATCH 05/12] Tweak craftguide stereotypes --- mods/HELP/mcl_craftguide/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mods/HELP/mcl_craftguide/init.lua b/mods/HELP/mcl_craftguide/init.lua index d7d07238df..10680426e3 100644 --- a/mods/HELP/mcl_craftguide/init.lua +++ b/mods/HELP/mcl_craftguide/init.lua @@ -44,7 +44,7 @@ local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil local group_stereotypes = { wool = "mcl_wool:white", carpet = "mcl_wool:white_carpet", - dye = "mcl_dye:white", + dye = "mcl_dye:red", water_bucket = "bucket:bucket_water", flower = "mcl_flowers:dandelion", mushroom = "mcl_mushrooms:mushroom_brown", @@ -53,7 +53,7 @@ local group_stereotypes = { coal = "mcl_core:coal_lump", shulker_box = "mcl_chests:violet_shulker_box", quartz_block = "mcl_nether:quartz_block", - banner = "mcl_banners:standing_banner_white", + banner = "mcl_banners:banner_item_white", mesecon_conductor_craftable = "mesecons:wire_00000000_off", compass = mcl_compass.stereotype, clock = mcl_clock.sterotype, From ece1569f232726a80c1454ac2a28a27d3230984b Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 17:32:39 +0200 Subject: [PATCH 06/12] Add banner pattern crafts first --- mods/ITEMS/mcl_banners/init.lua | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index eacf5171a9..63a313d056 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -30,6 +30,10 @@ mcl_banners.colors = { ["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00", "mcl_dye:green" }, ["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF", "mcl_dye:lightblue" }, } + +-- Add pattern/emblazoning crafting recipes +dofile(minetest.get_modpath("mcl_banners").."/patterncraft.lua") + -- Overlay ratios (0-255) local base_color_ratio = 224 local layer_ratio = 255 @@ -245,8 +249,6 @@ minetest.register_entity("mcl_banners:standing_banner", { end, }) -dofile(minetest.get_modpath("mcl_banners").."/patterncraft.lua") - minetest.register_craft({ type = "fuel", recipe = "group:banner", From b46ac0658e09ccc5b8da7837200a5c8fd0ca5a48 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 17:41:04 +0200 Subject: [PATCH 07/12] Add shapeless banner pattern crafts --- mods/ITEMS/mcl_banners/patterncraft.lua | 44 +++++++++++++++++-------- 1 file changed, 31 insertions(+), 13 deletions(-) diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index cc808009a2..de891859e6 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -1,6 +1,6 @@ -- List of patterns with crafting rules -local d = "%D" -- dye +local d = "group:dye" -- dye local e = "" -- empty slot (one of them must contain the banner) local patterns = { ["border"] = { @@ -10,7 +10,7 @@ local patterns = { }, ["bricks"] = { type = "shapeless", - { "mcl_core:brick_block", d }, + { e, "mcl_core:brick_block", d }, }, ["circle"] = { { e, e, e }, @@ -19,7 +19,7 @@ local patterns = { }, ["creeper"] = { type = "shapeless", - { "mcl_heads:creeper", d }, + { e, "mcl_heads:creeper", d }, }, ["cross"] = { { d, e, d }, @@ -27,8 +27,8 @@ local patterns = { { d, e, d }, }, ["curly_border"] = { - type = "shapless", - { "mcl_core:vine", d }, + type = "shapeless", + { e, "mcl_core:vine", d }, }, ["diagonal_left"] = { { e, e, e }, @@ -52,7 +52,7 @@ local patterns = { }, ["flower"] = { type = "shapeless", - { "mcl_flowers:oxeye_daisy", d }, + { e, "mcl_flowers:oxeye_daisy", d }, }, ["gradient"] = { { d, e, d }, @@ -86,7 +86,8 @@ local patterns = { }, ["thing"] = { type = "shapeless", - { "mcl_core:apple_gold", d }, + -- TODO: Replace with enchanted golden apple + { e, "mcl_core:apple_gold", d }, }, ["rhombus"] = { { e, d, e }, @@ -95,7 +96,7 @@ local patterns = { }, ["skull"] = { type = "shapeless", - { "mcl_heads:wither_skeleton", d }, + { e, "mcl_heads:wither_skeleton", d }, }, ["small_stripes"] = { { d, e, d }, @@ -249,6 +250,7 @@ end) -- Register crafting recipes for all the patterns for pattern_name, pattern in pairs(patterns) do + -- Shaped and fixed recipes if pattern.type == nil then for colorid, colortab in pairs(mcl_banners.colors) do local banner = "mcl_banners:banner_item_"..colortab[1] @@ -258,9 +260,7 @@ for pattern_name, pattern in pairs(patterns) do local row = pattern[row_id] local newrow = {} for r=1, #row do - if row[r] == d then - newrow[r] = "group:dye" - elseif row[r] == e and not bannered then + if row[r] == e and not bannered then newrow[r] = banner bannered = true else @@ -270,12 +270,30 @@ for pattern_name, pattern in pairs(patterns) do table.insert(recipe, newrow) end minetest.register_craft({ - output = "mcl_banners:banner_item_"..colortab[1], + output = banner, recipe = recipe, }) end + -- Shapeless recipes elseif pattern.type == "shapeless" then - -- TODO + for colorid, colortab in pairs(mcl_banners.colors) do + local banner = "mcl_banners:banner_item_"..colortab[1] + local orig = pattern[1] + local recipe = {} + for r=1, #orig do + if orig[r] == e then + recipe[r] = banner + else + recipe[r] = orig[r] + end + end + + minetest.register_craft({ + type = "shapeless", + output = banner, + recipe = recipe, + }) + end end end From f566241bb6953433ed7151818b7f1d82188811d2 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 18:12:16 +0200 Subject: [PATCH 08/12] Force same dye color on banner crafting --- mods/ITEMS/mcl_banners/patterncraft.lua | 38 ++++++++++++++++++------- 1 file changed, 27 insertions(+), 11 deletions(-) diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index de891859e6..97232ee5ec 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -195,16 +195,25 @@ minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craf return end - local original + local banner + local dye local index for i = 1, player:get_inventory():get_size("craft") do - if minetest.get_item_group(old_craft_grid[i]:get_name(), "banner") == 1 then - original = old_craft_grid[i] + local itemname = old_craft_grid[i]:get_name() + if minetest.get_item_group(itemname, "banner") == 1 then + banner = old_craft_grid[i] index = i + -- Check if all dyes are equal + elseif minetest.get_item_group(itemname, "dye") == 1 then + if dye == nil then + dye = itemname + elseif itemname ~= dye then + return ItemStack("") + end end end - if not original then - return + if not banner then + return ItemStack("") end local imeta = itemstack:get_meta() @@ -219,27 +228,34 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv return end - local original + local banner, dye local index for i = 1, player:get_inventory():get_size("craft") do local itemname = old_craft_grid[i]:get_name() if minetest.get_item_group(itemname, "banner") == 1 then - original = old_craft_grid[i] + banner = old_craft_grid[i] index = i + -- Check if all dyes are equal + elseif minetest.get_item_group(itemname, "dye") == 1 then + if dye == nil then + dye = itemname + elseif itemname ~= dye then + return ItemStack("") + end end end - if not original then - return + if not banner then + return ItemStack("") end - local ometa = original:get_meta() + local ometa = banner:get_meta() local layers_raw = ometa:get_string("layers") local layers = minetest.deserialize(layers_raw) if type(layers) ~= "table" then layers = {} end - table.insert(layers, {pattern="circle", color = "unicolor_yellow"}) + table.insert(layers, {pattern="circle", color="unicolor_yellow"}) local imeta = itemstack:get_meta() imeta:set_string("layers", minetest.serialize(layers)) From b79d4a9bb959974b7bf20503a25ce686ff943701 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 22:23:21 +0200 Subject: [PATCH 09/12] Basic implementation of banner pattern crafting --- mods/ITEMS/mcl_banners/patterncraft.lua | 61 +++++++++++++++++++++---- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index 97232ee5ec..eb8be4ee64 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -197,12 +197,12 @@ minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craf local banner local dye - local index + local banner_index for i = 1, player:get_inventory():get_size("craft") do local itemname = old_craft_grid[i]:get_name() if minetest.get_item_group(itemname, "banner") == 1 then banner = old_craft_grid[i] - index = i + banner_index = i -- Check if all dyes are equal elseif minetest.get_item_group(itemname, "dye") == 1 then if dye == nil then @@ -222,19 +222,19 @@ minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craf return itemstack end) - +-- This is for handling all those complex pattern crafting recipes minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then return end local banner, dye - local index + local banner_index for i = 1, player:get_inventory():get_size("craft") do local itemname = old_craft_grid[i]:get_name() if minetest.get_item_group(itemname, "banner") == 1 then banner = old_craft_grid[i] - index = i + banner_index = i -- Check if all dyes are equal elseif minetest.get_item_group(itemname, "dye") == 1 then if dye == nil then @@ -248,6 +248,7 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv return ItemStack("") end + -- Get old layers local ometa = banner:get_meta() local layers_raw = ometa:get_string("layers") local layers = minetest.deserialize(layers_raw) @@ -255,12 +256,57 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv layers = {} end - table.insert(layers, {pattern="circle", color="unicolor_yellow"}) + local matching_pattern + local max_i = player:get_inventory():get_size("craft") + -- Find the matching pattern + for pattern_name, pattern in pairs(patterns) do + -- Shaped / fixed + if pattern.type == nil then + local pattern_ok = true + local inv_i = 1 + -- This complex code just iterates through the pattern slots one-by-one and compares them with the pattern + for p=1, #pattern do + local row = pattern[p] + if inv_i > max_i then + break + end + for r=1, #row do + local itemname = old_craft_grid[inv_i]:get_name() + local pitem = row[r] + if (pitem == d and minetest.get_item_group(itemname, "dye") == 0) or (pitem == e and itemname ~= e and inv_i ~= banner_index) then + pattern_ok = false + break + else + end + inv_i = inv_i + 1 + end + end + -- Everything matched! We found our pattern! + if pattern_ok then + matching_pattern = pattern_name + break + end + + elseif pattern.type == "shapeless" then + -- TODO + end + + if matching_pattern then + break + end + end + if not matching_pattern then + return ItemStack("") + end + + -- Add the new layer + + table.insert(layers, {pattern=matching_pattern, color="unicolor_yellow"}) local imeta = itemstack:get_meta() imeta:set_string("layers", minetest.serialize(layers)) - imeta:set_string("description", "Emblazoned Banner") + imeta:set_string("description", "Emblazoned Banner ("..matching_pattern..")") return itemstack end) @@ -313,4 +359,3 @@ for pattern_name, pattern in pairs(patterns) do end end - From 5192f3e88b939747b6ccd6fc03fe9810e21e48db Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 22:26:37 +0200 Subject: [PATCH 10/12] Banners: Combine pattern craft w/ craft predict --- mods/ITEMS/mcl_banners/patterncraft.lua | 40 ++++--------------------- 1 file changed, 6 insertions(+), 34 deletions(-) diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index eb8be4ee64..4c26099f35 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -190,40 +190,8 @@ local patterns = { }, } -minetest.register_craft_predict(function(itemstack, player, old_craft_grid, craft_inv) - if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then - return - end - - local banner - local dye - local banner_index - for i = 1, player:get_inventory():get_size("craft") do - local itemname = old_craft_grid[i]:get_name() - if minetest.get_item_group(itemname, "banner") == 1 then - banner = old_craft_grid[i] - banner_index = i - -- Check if all dyes are equal - elseif minetest.get_item_group(itemname, "dye") == 1 then - if dye == nil then - dye = itemname - elseif itemname ~= dye then - return ItemStack("") - end - end - end - if not banner then - return ItemStack("") - end - - local imeta = itemstack:get_meta() - - imeta:set_string("description", "Emblazoned Banner") - return itemstack -end) - -- This is for handling all those complex pattern crafting recipes -minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv) +local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_inv) if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then return end @@ -308,7 +276,11 @@ minetest.register_on_craft(function(itemstack, player, old_craft_grid, craft_inv imeta:set_string("description", "Emblazoned Banner ("..matching_pattern..")") return itemstack -end) +end + +minetest.register_craft_predict(banner_pattern_craft) +minetest.register_on_craft(banner_pattern_craft) + -- Register crafting recipes for all the patterns for pattern_name, pattern in pairs(patterns) do From 51f28a4317762d4fce98dab0612ac4787d781d88 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 22:46:39 +0200 Subject: [PATCH 11/12] Update description of emblazoned banners --- mods/ITEMS/mcl_banners/patterncraft.lua | 36 ++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index 4c26099f35..47a88a7b9e 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -190,6 +190,35 @@ local patterns = { }, } +-- Number of maximum lines in the descriptions for the banner layers. +-- To avoid huge tooltips. +local max_layer_lines = 6 + +-- Create a banner description containing all the layer names +local make_advanced_banner_description = function(description, layers) + if layers == nil or #layers == 0 then + -- No layers, revert to default + return "" + else + local d = description + local layerstrings = {} + for l=1, #layers do + if l > max_layer_lines then + break + end + table.insert(layerstrings, string.format("%s %s", layers[l].color, layers[l].pattern)) + end + if #layers == max_layer_lines + 1 then + table.insert(layerstrings, "And one addional layer") + elseif #layers > max_layer_lines + 1 then + table.insert(layerstrings, string.format("And %d addional layers", #layers - max_layer_lines)) + end + local append = table.concat(layerstrings, "\n") + d = d .. "\n" .. core.colorize("#8F8F8F", append) + return d + end +end + -- This is for handling all those complex pattern crafting recipes local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_inv) if minetest.get_item_group(itemstack:get_name(), "banner") ~= 1 then @@ -267,14 +296,15 @@ local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_i return ItemStack("") end - -- Add the new layer - + -- Add the new layer and update other metadata table.insert(layers, {pattern=matching_pattern, color="unicolor_yellow"}) local imeta = itemstack:get_meta() imeta:set_string("layers", minetest.serialize(layers)) - imeta:set_string("description", "Emblazoned Banner ("..matching_pattern..")") + local odesc = itemstack:get_definition().description + local description = make_advanced_banner_description(odesc, layers) + imeta:set_string("description", description) return itemstack end From 709ac59b31784dc7a720fce606e4aefe353b65a7 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 28 Jul 2017 23:12:40 +0200 Subject: [PATCH 12/12] Human-readable banner layer descriptions --- mods/ITEMS/mcl_banners/init.lua | 35 +++++++------- mods/ITEMS/mcl_banners/patterncraft.lua | 63 +++++++++++++++++++++---- 2 files changed, 72 insertions(+), 26 deletions(-) diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 63a313d056..17f1d0a264 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -12,23 +12,24 @@ end mcl_banners = {} mcl_banners.colors = { - -- ID, description, wool, unified dyes color group, overlay color, dye - ["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF", "mcl_dye:white" }, - ["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030", "mcl_dye:dark_grey" }, - ["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B", "mcl_dye:grey" }, - ["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000", "mcl_dye:black" }, - ["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000", "mcl_dye:red" }, - ["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800", "mcl_dye:yellow" }, - ["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000", "mcl_dye:dark_green" }, - ["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC", "mcl_dye:cyan" }, - ["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC", "mcl_dye:blue" }, - ["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C", "mcl_dye:magenta" }, - ["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900", "mcl_dye:orange" }, - ["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC", "mcl_dye:violet" }, - ["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100", "mcl_dye:brown" }, - ["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C", "mcl_dye:pink" }, - ["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00", "mcl_dye:green" }, - ["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF", "mcl_dye:lightblue" }, + -- Format: + -- [ID] = { banner description, wool, unified dyes color group, overlay color, dye, color name for emblazonings } + ["unicolor_white"] = {"white", "White Banner", "mcl_wool:white", "#FFFFFF", "mcl_dye:white", "White" }, + ["unicolor_darkgrey"] = {"grey", "Grey Banner", "mcl_wool:grey", "#303030", "mcl_dye:dark_grey", "Grey" }, + ["unicolor_grey"] = {"silver", "Light Grey Banner", "mcl_wool:silver", "#5B5B5B", "mcl_dye:grey", "Light Grey" }, + ["unicolor_black"] = {"black", "Black Banner", "mcl_wool:black", "#000000", "mcl_dye:black", "Black" }, + ["unicolor_red"] = {"red", "Red Banner", "mcl_wool:red", "#BC0000", "mcl_dye:red", "Red" }, + ["unicolor_yellow"] = {"yellow", "Yellow Banner", "mcl_wool:yellow", "#BCA800", "mcl_dye:yellow", "Yellow" }, + ["unicolor_dark_green"] = {"green", "Green Banner", "mcl_wool:green", "#006000", "mcl_dye:dark_green", "Green" }, + ["unicolor_cyan"] = {"cyan", "Cyan Banner", "mcl_wool:cyan", "#00ACAC", "mcl_dye:cyan", "Cyan" }, + ["unicolor_blue"] = {"blue", "Blue Banner", "mcl_wool:blue", "#0000AC", "mcl_dye:blue", "Blue" }, + ["unicolor_red_violet"] = {"magenta", "Magenta Banner", "mcl_wool:magenta", "#AC007C", "mcl_dye:magenta", "Magenta"}, + ["unicolor_orange"] = {"orange", "Orange Banner", "mcl_wool:orange", "#BC6900", "mcl_dye:orange", "Orange" }, + ["unicolor_violet"] = {"purple", "Purple Banner", "mcl_wool:purple", "#6400AC", "mcl_dye:violet", "Violet" }, + ["unicolor_brown"] = {"brown", "Brown Banner", "mcl_wool:brown", "#402100", "mcl_dye:brown", "Brown" }, + ["unicolor_pink"] = {"pink", "Pink Banner", "mcl_wool:pink", "#DE557C", "mcl_dye:pink", "Pink" }, + ["unicolor_lime"] = {"lime", "Lime Banner", "mcl_wool:lime", "#30AC00", "mcl_dye:green", "Lime" }, + ["unicolor_light_blue"] = {"light_blue", "Light Blue Banner", "mcl_wool:light_blue", "#4040CF", "mcl_dye:lightblue", "Light Blue" }, } -- Add pattern/emblazoning crafting recipes diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index 47a88a7b9e..cd75f9b068 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -4,190 +4,228 @@ local d = "group:dye" -- dye local e = "" -- empty slot (one of them must contain the banner) local patterns = { ["border"] = { + name = "%s Bordure", { d, d, d }, { d, e, d }, { d, d, d }, }, ["bricks"] = { + name = "%s Bricks", type = "shapeless", { e, "mcl_core:brick_block", d }, }, ["circle"] = { + name = "%s Circle", { e, e, e }, { e, d, e }, { e, e, e }, }, ["creeper"] = { + name = "%s Creeper Charge", type = "shapeless", { e, "mcl_heads:creeper", d }, }, ["cross"] = { + name = "%s Saltire", { d, e, d }, { e, d, e }, { d, e, d }, }, ["curly_border"] = { + name = "%s Intented Bordure", type = "shapeless", { e, "mcl_core:vine", d }, }, ["diagonal_left"] = { + name = "%s Inverted Per Bend", { e, e, e }, { d, e, e }, { d, d, e }, }, ["diagonal_right"] = { + name = "%s Inverted Per Bend Sinister", { e, e, e }, { e, e, d }, { e, d, d }, }, ["diagonal_up_left"] = { + name = "%s Per Bend", { e, d, d }, { e, e, d }, { e, e, e }, }, ["diagonal_up_right"] = { + name = "%s Per Bend Sinister", { d, d, e }, { d, e, e }, { e, e, e }, }, ["flower"] = { + name = "%s Flower Charge", type = "shapeless", { e, "mcl_flowers:oxeye_daisy", d }, }, ["gradient"] = { + name = "%s Gradient", { d, e, d }, { e, d, e }, { e, d, e }, }, ["gradient_up"] = { + name = "%s Base Gradient", { e, d, e }, { e, d, e }, { d, e, d }, }, ["half_horizontal_bottom"] = { + name = "%s Inverted Per Fess", { e, e, e }, { d, d, d }, { d, d, d }, }, ["half_horizontal"] = { + name = "%s Per Fess", { d, d, d }, { d, d, d }, { e, e, e }, }, ["half_vertical"] = { + name = "%s Per Pale", { d, d, e }, { d, d, e }, { d, d, e }, }, ["half_vertical_right"] = { + name = "%s Inverted Per Pale", { e, d, d }, { e, d, d }, { e, d, d }, }, ["thing"] = { + name = "%s Thing", type = "shapeless", -- TODO: Replace with enchanted golden apple { e, "mcl_core:apple_gold", d }, }, ["rhombus"] = { + name = "%s Lozenge", { e, d, e }, { d, e, d }, { e, d, e }, }, ["skull"] = { + name = "%s Skull Charge", type = "shapeless", { e, "mcl_heads:wither_skeleton", d }, }, ["small_stripes"] = { + name = "%s Paly", { d, e, d }, { d, e, d }, { e, e, e }, }, ["square_bottom_left"] = { + name = "%s Base Dexter Canton", { e, e, e }, { e, e, e }, { d, e, e }, }, ["square_bottom_right"] = { + name = "%s Base Sinister Canton", { e, e, e }, { e, e, e }, { e, e, d }, }, ["square_top_left"] = { + name = "%s Chief Dexter Canton", { d, e, e }, { e, e, e }, { e, e, e }, }, ["square_top_right"] = { + name = "%s Chief Sinister Canton", { e, e, d }, { e, e, e }, { e, e, e }, }, ["straight_cross"] = { + name = "%s Cross", { e, d, e }, { d, d, d }, { e, d, e }, }, ["stripe_bottom"] = { + name = "%s Base", { e, e, e }, { e, e, e }, { d, d, d }, }, ["stripe_center"] = { + name = "%s Fess", { e, e, e }, { d, d, d }, { e, e, e }, }, ["stripe_downleft"] = { + name = "%s Bend Sinister", { e, e, d }, { e, d, e }, { d, e, e }, }, ["stripe_downright"] = { + name = "%s Bend", { d, e, e }, { e, d, e }, { e, e, d }, }, ["stripe_left"] = { + name = "%s Pale Dexter", { d, e, e }, { d, e, e }, { d, e, e }, }, ["stripe_middle"] = { + name = "%s Pale", { e, d, e }, { e, d, e }, { e, d, e }, }, ["stripe_right"] = { + name = "%s Pale Sinister", { e, e, d }, { e, e, d }, { e, e, d }, }, ["stripe_top"] = { + name = "%s Chief", { d, d, d }, { e, e, e }, { e, e, e }, }, ["triangle_bottom"] = { + name = "%s Chevron", { e, e, e }, { e, d, e }, { d, e, d }, }, + ["triangle_top"] = { + name = "%s Inverted Chevron", + { d, e, d }, + { e, d, e }, + { e, e, e }, + }, ["triangles_bottom"] = { + name = "%s Base Indented", { e, e, e }, { d, e, d }, { e, d, e }, }, ["triangles_top"] = { + name = "%s Chief Indented", { e, d, e }, { d, e, d }, { e, e, e }, }, - ["triangle_top"] = { - { d, e, d }, - { e, d, e }, - { e, e, e }, - }, } -- Number of maximum lines in the descriptions for the banner layers. @@ -200,22 +238,29 @@ local make_advanced_banner_description = function(description, layers) -- No layers, revert to default return "" else - local d = description local layerstrings = {} for l=1, #layers do + -- Prevent excess length description if l > max_layer_lines then break end - table.insert(layerstrings, string.format("%s %s", layers[l].color, layers[l].pattern)) + -- Layer text line. + local color = mcl_banners.colors[layers[l].color][6] + local pattern_name = patterns[layers[l].pattern].name + -- The pattern name is a format string (e.g. “%s Base”) + table.insert(layerstrings, string.format(pattern_name, color)) end + -- Warn about missing information if #layers == max_layer_lines + 1 then table.insert(layerstrings, "And one addional layer") elseif #layers > max_layer_lines + 1 then table.insert(layerstrings, string.format("And %d addional layers", #layers - max_layer_lines)) end + + -- Final string concatenations: Just a list of strings local append = table.concat(layerstrings, "\n") - d = d .. "\n" .. core.colorize("#8F8F8F", append) - return d + description = description .. "\n" .. core.colorize("#8F8F8F", append) + return description end end