From 02e228095e7d5dd302bd2fa2256829fdc0138d8b Mon Sep 17 00:00:00 2001 From: Adubbz Date: Thu, 17 Mar 2016 13:11:12 +1100 Subject: [PATCH] BlockColors and ItemColors no longer assume non-Vanilla id constancy. Added a getter for ItemColors. --- .../net/minecraft/client/Minecraft.java.patch | 11 +++++ .../renderer/color/BlockColors.java.patch | 32 ++++++++++++++ .../renderer/color/ItemColors.java.patch | 43 +++++++++++++++++++ 3 files changed, 86 insertions(+) create mode 100644 patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch create mode 100644 patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch diff --git a/patches/minecraft/net/minecraft/client/Minecraft.java.patch b/patches/minecraft/net/minecraft/client/Minecraft.java.patch index 8a29254d6..d77815310 100644 --- a/patches/minecraft/net/minecraft/client/Minecraft.java.patch +++ b/patches/minecraft/net/minecraft/client/Minecraft.java.patch @@ -474,3 +474,14 @@ } public boolean func_70002_Q() +@@ -3192,4 +3084,10 @@ + { + return this.field_184127_aH; + } ++ ++ // FORGE ++ public ItemColors getItemColors() ++ { ++ return this.field_184128_aI; ++ } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch b/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch new file mode 100644 index 000000000..93ce7f14e --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch @@ -0,0 +1,32 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/color/BlockColors.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/color/BlockColors.java +@@ -25,7 +25,8 @@ + @SideOnly(Side.CLIENT) + public class BlockColors + { +- private final ObjectIntIdentityMap field_186725_a = new ObjectIntIdentityMap(32); ++ // FORGE: Use RegistryDelegates as non-Vanilla block ids are not constant ++ private final java.util.Map, IBlockColor> blockColorMap = com.google.common.collect.Maps.newHashMap(); + + public static BlockColors func_186723_a() + { +@@ -145,7 +146,7 @@ + + public int func_186724_a(IBlockState p_186724_1_, IBlockAccess p_186724_2_, BlockPos p_186724_3_, int p_186724_4_) + { +- IBlockColor iblockcolor = (IBlockColor)this.field_186725_a.func_148745_a(Block.func_149682_b(p_186724_1_.func_177230_c())); ++ IBlockColor iblockcolor = (IBlockColor)this.blockColorMap.get(p_186724_1_.func_177230_c().delegate); + return iblockcolor == null ? -1 : iblockcolor.func_186720_a(p_186724_1_, p_186724_2_, p_186724_3_, p_186724_4_); + } + +@@ -155,7 +156,9 @@ + + for (int j = p_186722_2_.length; i < j; ++i) + { +- this.field_186725_a.func_148746_a(p_186722_1_, Block.func_149682_b(p_186722_2_[i])); ++ if (p_186722_2_[i] == null) throw new IllegalArgumentException("Block registered to block color handler cannot be null!"); ++ if (p_186722_2_[i].getRegistryName() == null) throw new IllegalArgumentException("Block must be registered before assigning color handler."); ++ this.blockColorMap.put(p_186722_2_[i].delegate, p_186722_1_); + } + } + } diff --git a/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch b/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch new file mode 100644 index 000000000..c9764c984 --- /dev/null +++ b/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch @@ -0,0 +1,43 @@ +--- ../src-base/minecraft/net/minecraft/client/renderer/color/ItemColors.java ++++ ../src-work/minecraft/net/minecraft/client/renderer/color/ItemColors.java +@@ -26,7 +26,8 @@ + @SideOnly(Side.CLIENT) + public class ItemColors + { +- private final ObjectIntIdentityMap field_186732_a = new ObjectIntIdentityMap(32); ++ // FORGE: Use RegistryDelegates as non-Vanilla item ids are not constant ++ private final java.util.Map, IItemColor> itemColorMap = com.google.common.collect.Maps.newHashMap(); + + public static ItemColors func_186729_a(final BlockColors p_186729_0_) + { +@@ -136,7 +137,7 @@ + + public int func_186728_a(ItemStack p_186728_1_, int p_186728_2_) + { +- IItemColor iitemcolor = (IItemColor)this.field_186732_a.func_148745_a(Item.field_150901_e.func_148757_b(p_186728_1_.func_77973_b())); ++ IItemColor iitemcolor = (IItemColor)this.itemColorMap.get(p_186728_1_.func_77973_b().delegate); + return iitemcolor == null ? -1 : iitemcolor.func_186726_a(p_186728_1_, p_186728_2_); + } + +@@ -146,7 +147,9 @@ + + for (int j = p_186731_2_.length; i < j; ++i) + { +- this.field_186732_a.func_148746_a(p_186731_1_, Item.func_150891_b(Item.func_150898_a(p_186731_2_[i]))); ++ if (p_186731_2_[i] == null) throw new IllegalArgumentException("Block registered to item color handler cannot be null!"); ++ if (p_186731_2_[i].getRegistryName() == null) throw new IllegalArgumentException("Block must be registered before assigning color handler."); ++ this.itemColorMap.put(Item.func_150898_a(p_186731_2_[i]).delegate, p_186731_1_); + } + } + +@@ -156,7 +159,9 @@ + + for (int j = p_186730_2_.length; i < j; ++i) + { +- this.field_186732_a.func_148746_a(p_186730_1_, Item.func_150891_b(p_186730_2_[i])); ++ if (p_186730_2_[i] == null) throw new IllegalArgumentException("Item registered to item color handler cannot be null!"); ++ if (p_186730_2_[i].getRegistryName() == null) throw new IllegalArgumentException("Item must be registered before assigning color handler."); ++ this.itemColorMap.put(p_186730_2_[i].delegate, p_186730_1_); + } + } + }