From a365582b58ce98dba658261945684c8c9f423540 Mon Sep 17 00:00:00 2001 From: LexManos Date: Mon, 21 Mar 2016 19:24:12 -0700 Subject: [PATCH] Added support for custom dyes with Banners. Closes #2596 --- .../item/crafting/RecipesBanners.java.patch | 74 ++++++++++++++++++- 1 file changed, 72 insertions(+), 2 deletions(-) diff --git a/patches/minecraft/net/minecraft/item/crafting/RecipesBanners.java.patch b/patches/minecraft/net/minecraft/item/crafting/RecipesBanners.java.patch index bddf21f35e..d5afab9c37 100644 --- a/patches/minecraft/net/minecraft/item/crafting/RecipesBanners.java.patch +++ b/patches/minecraft/net/minecraft/item/crafting/RecipesBanners.java.patch @@ -1,6 +1,19 @@ --- ../src-base/minecraft/net/minecraft/item/crafting/RecipesBanners.java +++ ../src-work/minecraft/net/minecraft/item/crafting/RecipesBanners.java -@@ -135,11 +135,7 @@ +@@ -89,9 +89,10 @@ + { + ItemStack itemstack2 = p_77572_1_.func_70301_a(j); + +- if (itemstack2 != null && itemstack2.func_77973_b() == Items.field_151100_aR) ++ int color = getColor(itemstack2); ++ if (color != -1) + { +- k = itemstack2.func_77960_j(); ++ k = color; + break; + } + } +@@ -135,11 +136,7 @@ for (int i = 0; i < aitemstack.length; ++i) { ItemStack itemstack = p_179532_1_.func_70301_a(i); @@ -13,7 +26,64 @@ } return aitemstack; -@@ -356,9 +352,9 @@ +@@ -164,7 +161,7 @@ + + if (itemstack != null && itemstack.func_77973_b() != Items.field_179564_cE) + { +- if (itemstack.func_77973_b() == Items.field_151100_aR) ++ if (isDye(itemstack)) + { + if (flag2) + { +@@ -204,7 +201,7 @@ + + if (itemstack1 != null && itemstack1.func_77973_b() != Items.field_179564_cE) + { +- if (itemstack1.func_77973_b() != Items.field_151100_aR) ++ if (!isDye(itemstack1)) + { + flag = false; + break; +@@ -245,6 +242,38 @@ + + return null; + } ++ ++ private static String[] colors = { "Black", "Red", "Green", "Brown", "Blue", "Purple", "Cyan", "LightGray", "Gray", "Pink", "Lime", "Yellow", "LightBlue", "Magenta", "Orange", "White" }; ++ @SuppressWarnings("unchecked") //Why java... ++ private static java.util.List[] colored = new java.util.List[colors.length]; ++ private static java.util.List dyes; ++ private static boolean hasInit = false; ++ private static void init() ++ { ++ if (hasInit) return; ++ for (int x = 0; x < colors.length; x++) ++ colored[x] = net.minecraftforge.oredict.OreDictionary.getOres("dye" + colors[x]); ++ dyes = net.minecraftforge.oredict.OreDictionary.getOres("dye"); ++ hasInit = true; ++ } ++ private boolean isDye(ItemStack stack) ++ { ++ init(); ++ for (ItemStack ore : dyes) ++ if (net.minecraftforge.oredict.OreDictionary.itemMatches(ore, stack, false)) ++ return true; ++ return false; ++ } ++ private int getColor(ItemStack stack) ++ { ++ init(); ++ if (stack == null) return -1; ++ for (int x = 0; x < colored.length; x++) ++ for (ItemStack ore : colored[x]) ++ if (net.minecraftforge.oredict.OreDictionary.itemMatches(ore, stack, true)) ++ return x; ++ return -1; ++ } + } + + public static class RecipeDuplicatePattern implements IRecipe +@@ -356,9 +385,9 @@ if (itemstack != null) {