From dca095171c573bd8b4ecae91b09fd32f3310a610 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 1 Mar 2019 17:48:00 +0100 Subject: [PATCH] Restrict banner layers to 3 if has a gradient --- mods/ITEMS/mcl_banners/init.lua | 3 ++- mods/ITEMS/mcl_banners/patterncraft.lua | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/mods/ITEMS/mcl_banners/init.lua b/mods/ITEMS/mcl_banners/init.lua index 541a69c9f..49af2de63 100644 --- a/mods/ITEMS/mcl_banners/init.lua +++ b/mods/ITEMS/mcl_banners/init.lua @@ -193,7 +193,8 @@ minetest.register_node("mcl_banners:standing_banner", { _doc_items_entry_name = "Banner", _doc_items_image = "mcl_banners_item_base.png^mcl_banners_item_overlay.png", _doc_items_longdesc = "Banners are tall colorful decorative blocks. They can be placed on the floor and at walls. Banners can be emblazoned with a variety of patterns using a lot of dye in crafting.", - _doc_items_usagehelp = "Use crafting to draw a pattern on top of the banner. Emblazoned banners can be emblazoned again to combine various patterns. You can draw up to 6 layers on a banner that way. You can copy the pattern of a banner by placing two banners of the same color in the crafting grid—one needs to be emblazoned, the other one must be clean. Finally, you can use a banner on a cauldron with water to wash off its top-most layer.", + _doc_items_usagehelp = [[Use crafting to draw a pattern on top of the banner. Emblazoned banners can be emblazoned again to combine various patterns. You can draw up to 6 layers on a banner that way. If the banner includes a gradient, only 3 layers are possible. +You can copy the pattern of a banner by placing two banners of the same color in the crafting grid—one needs to be emblazoned, the other one must be clean. Finally, you can use a banner on a cauldron with water to wash off its top-most layer.]], walkable = false, is_ground_content = false, paramtype = "light", diff --git a/mods/ITEMS/mcl_banners/patterncraft.lua b/mods/ITEMS/mcl_banners/patterncraft.lua index 8d202c78c..2858b3d23 100644 --- a/mods/ITEMS/mcl_banners/patterncraft.lua +++ b/mods/ITEMS/mcl_banners/patterncraft.lua @@ -5,6 +5,9 @@ -- Maximum number of layers which can be put on a banner by crafting. local max_layers_crafting = 6 +-- Maximum number of layers when banner includes a gradient (workaround, see below). +local max_layers_gradient = 3 + -- Max. number lines in the descriptions for the banner layers. -- This is done to avoid huge tooltips. local max_layer_lines = 6 @@ -386,6 +389,16 @@ local banner_pattern_craft = function(itemstack, player, old_craft_grid, craft_i if #layers >= max_layers_crafting then return ItemStack("") end + -- Lower layer limit when banner includes any gradient. + -- Workaround to circumvent bug #340 (gradients are likely to cause transparent pixels). + -- FIXME: Remove this restriction when bug #340 is fixed. + if #layers >= max_layers_gradient then + for l=1, #layers do + if layers[l].pattern == "gradient" or layers[l].pattern == "gradient_up" then + return ItemStack("") + end + end + end local matching_pattern local max_i = player:get_inventory():get_size("craft")