Add an event for registering block/item colour handlers (#4565)

This commit is contained in:
Ben Staddon 2017-12-17 01:34:00 +00:00 committed by LexManos
parent e3c630ecb8
commit 98997061f0
4 changed files with 99 additions and 6 deletions

View File

@ -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_)
{

View File

@ -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_)
{

View File

@ -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)
{

View File

@ -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;
}
}
}