Posted May 10, 20196 yr SOLUTION: Extra class for the color registration event: public static class RegistryEvents { @SubscribeEvent public static void registerBlockColors(final ColorHandlerEvent.Block event) { BlockColors blockColors = event.getBlockColors().register(MY_BLOCK_COLOR, MY_BLOCK); } } Then, in the main mod method, register that class to the main event bus: MinecraftForge.EVENT_BUS.register(RegistryEvents.class); PROBLEM: I'm trying to create a block like grass that changes its color depending on the biome it's in. I know that I'm supposed to create an IBlockColor, then call Minecraft.getInstance().getBlockColors().register(IBlockColor, Block); However, everywhere that I've tried this, getBlockColors() returns null. I've tried creating an event "registerBlockColors" within my RegistryEvents class, but it never gets fired. @Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD) public static class RegistryEvents { @SubscribeEvent public static void registerBlockColors(final ColorHandlerEvent.Block event){ //this event is never fired Minecraft.getInstance().getBlockColors().register(MY_BLOCK_COLOR, MY_BLOCK); //EDIT: This doesn't work either because the surrounding function is never called. event.getBlockColors().register(MY_BLOCK_COLOR, MY_BLOCK); } //other SubscribeEvents are in here } What am I doing wrong? I've tried adding the BlockColors via Minecraft.getInstance()... in an onBlockActivated function just to see if my colors work and they do. But this is very obviously the wrong place to register them. Edited May 10, 20196 yr by TheOnlyTrueEnte
May 10, 20196 yr Author 36 minutes ago, diesieben07 said: Oh, if only there was a method in the event that to access the BlockColors instance like in all the other registry events... Oh wait. There is. Yeah, you mean this, right? @SubscribeEvent public static void registerBlockColors(final ColorHandlerEvent.Block event){ event.getBlockColors().register(MY_BLOCK_COLOR, MY_BLOCK); } This doesn't work either. The function is never called.
May 10, 20196 yr Author 5 minutes ago, diesieben07 said: ColorHandlerEvent is fired on the main event bus (MinecraftForge.EVENT_BUS). You registered your event handler to the mod event bus. That was it. Thank you so much!
July 31, 20196 yr For me it says "Type mismatch: cannot convert from void to BlockColors" @SubscribeEvent public static void registerBlockColors(final ColorHandlerEvent.Block event) { BlockColors blockColors = event.getBlockColors().register(blockColor, AngryBirdsBlocks.balloon_block, AngryBirdsBlocks.slingshot_block, AngryBirdsBlocks.slingshot2_block); } Is there any change for using it in 1.14.3? I noticed, if i delete the part before the "=" i get no more red underlines. Is this the right way to make it work in 1.14.3 Edited August 2, 20196 yr by Drachenbauer
April 19, 20205 yr As a note to those trying to use IBlockColor in 1.15, ColorHandlerEvent is now on the Mod Event Bus (Mod.EventBusSubscriber.Bus.MOD).
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.