diff --git a/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch b/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch index ebd19d26c..2965f527f 100644 --- a/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/color/BlockColors.java.patch @@ -10,7 +10,13 @@ public static BlockColors func_186723_a() { -@@ -164,7 +165,7 @@ +@@ -159,12 +160,13 @@ + return p_186720_2_ != null && p_186720_3_ != null ? 2129968 : 7455580; + } + }, Blocks.field_150392_bi); ++ net.minecraftforge.client.ForgeHooksClient.onBlockColorsInit(blockcolors); + return blockcolors; + } public int func_189991_a(IBlockState p_189991_1_, World p_189991_2_, BlockPos p_189991_3_) { @@ -19,7 +25,7 @@ if (iblockcolor != null) { -@@ -179,7 +180,7 @@ +@@ -179,7 +181,7 @@ public int func_186724_a(IBlockState p_186724_1_, @Nullable IBlockAccess p_186724_2_, @Nullable BlockPos p_186724_3_, int p_186724_4_) { @@ -28,7 +34,7 @@ return iblockcolor == null ? -1 : iblockcolor.func_186720_a(p_186724_1_, p_186724_2_, p_186724_3_, p_186724_4_); } -@@ -187,7 +188,9 @@ +@@ -187,7 +189,9 @@ { for (Block block : p_186722_2_) { diff --git a/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch b/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch index 37be2b90c..c465eb3f2 100644 --- a/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch +++ b/patches/minecraft/net/minecraft/client/renderer/color/ItemColors.java.patch @@ -10,7 +10,13 @@ public static ItemColors func_186729_a(final BlockColors p_186729_0_) { -@@ -142,7 +143,7 @@ +@@ -137,12 +138,13 @@ + return p_186726_2_ == 0 ? -1 : ItemMap.func_190907_h(p_186726_1_); + } + }, Items.field_151098_aY); ++ net.minecraftforge.client.ForgeHooksClient.onItemColorsInit(itemcolors, p_186729_0_); + return itemcolors; + } public int func_186728_a(ItemStack p_186728_1_, int p_186728_2_) { @@ -19,7 +25,7 @@ return iitemcolor == null ? -1 : iitemcolor.func_186726_a(p_186728_1_, p_186728_2_); } -@@ -150,7 +151,9 @@ +@@ -150,7 +152,9 @@ { for (Block block : p_186731_2_) { @@ -30,7 +36,7 @@ } } -@@ -158,7 +161,9 @@ +@@ -158,7 +162,9 @@ { for (Item item : p_186730_2_) { diff --git a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java index 178caa20f..0db7192a2 100644 --- a/src/main/java/net/minecraftforge/client/ForgeHooksClient.java +++ b/src/main/java/net/minecraftforge/client/ForgeHooksClient.java @@ -61,6 +61,8 @@ import net.minecraft.client.renderer.block.model.ModelManager; import net.minecraft.client.renderer.block.model.ModelResourceLocation; import net.minecraft.client.renderer.block.model.ModelRotation; import net.minecraft.client.renderer.block.model.SimpleBakedModel; +import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.client.renderer.color.ItemColors; import net.minecraft.client.renderer.texture.TextureAtlasSprite; import net.minecraft.client.renderer.texture.TextureManager; import net.minecraft.client.renderer.texture.TextureMap; @@ -91,6 +93,7 @@ import net.minecraft.util.text.TextFormatting; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.biome.Biome; +import net.minecraftforge.client.event.ColorHandlerEvent; import net.minecraftforge.client.event.DrawBlockHighlightEvent; import net.minecraftforge.client.event.EntityViewRenderEvent; import net.minecraftforge.client.event.FOVUpdateEvent; @@ -185,6 +188,16 @@ public class ForgeHooksClient MinecraftForge.EVENT_BUS.post(new TextureStitchEvent.Post(map)); } + public static void onBlockColorsInit(BlockColors blockColors) + { + MinecraftForge.EVENT_BUS.post(new ColorHandlerEvent.Block(blockColors)); + } + + public static void onItemColorsInit(ItemColors itemColors, BlockColors blockColors) + { + MinecraftForge.EVENT_BUS.post(new ColorHandlerEvent.Item(itemColors, blockColors)); + } + static int renderPass = -1; public static void setRenderPass(int pass) { diff --git a/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java b/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java new file mode 100644 index 000000000..20d736f68 --- /dev/null +++ b/src/main/java/net/minecraftforge/client/event/ColorHandlerEvent.java @@ -0,0 +1,68 @@ +/* + * Minecraft Forge + * Copyright (c) 2017. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation version 2.1 + * of the License. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.minecraftforge.client.event; + +import net.minecraft.client.renderer.color.BlockColors; +import net.minecraft.client.renderer.color.ItemColors; +import net.minecraftforge.fml.common.eventhandler.Event; + +/** + * Use these events to register block/item + * color handlers at the appropriate time. + */ +public abstract class ColorHandlerEvent extends Event +{ + public static class Block extends ColorHandlerEvent + { + private final BlockColors blockColors; + + public Block(BlockColors blockColors) + { + this.blockColors = blockColors; + } + + public BlockColors getBlockColors() + { + return blockColors; + } + } + + public static class Item extends ColorHandlerEvent + { + private final ItemColors itemColors; + private final BlockColors blockColors; + + public Item(ItemColors itemColors, BlockColors blockColors) + { + this.itemColors = itemColors; + this.blockColors = blockColors; + } + + public ItemColors getItemColors() + { + return itemColors; + } + + public BlockColors getBlockColors() + { + return blockColors; + } + } +}