Jump to content

Recommended Posts

Posted (edited)

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

  • 2 months later...
Posted (edited)

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

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

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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