Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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 by TheOnlyTrueEnte

  • 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.

  • 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!

 

  • 2 months later...

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 by Drachenbauer

  • 8 months later...

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.