Quark Oddities

Quark Oddities

22M Downloads

Greener Grass through IMC

primetoxinz opened this issue ยท 2 comments

commented

would it possible to get an IMC call for the greener grass registry so mods can add their grass type blocks?

commented

I also need this feature for my DynamicTrees mod. I had to use java reflection, bubble gum and duct tape to make it work.

commented

Since this issue doesn't seem to be getting any traction I thought I'd propose an alternate method that might function as a work around to those modders that have custom grass blocks:

//Register Rooty Colorizers
Minecraft.getMinecraft().getBlockColors().registerBlockColorHandler(
new IBlockColor() {
	@Override
	public int colorMultiplier(IBlockState state, IBlockAccess world, BlockPos pos, int tintIndex) {
		return Minecraft.getMinecraft().getBlockColors().colorMultiplier(Blocks.GRASS.getDefaultState(), world, pos, tintIndex);
	}
}, new Block[] {ModBlocks.blockCustomGrass1, ModBlocks.blockCustomGrass2});

This works because the grass color multiplier blindly accepts that the position is a grass block and never pulls a fresh blockstate from the coordinates in the world. This will colorize the block to whatever IBlockColor is currently registered for the grass Block, even if it's been overwritten by Quark or whatever.
Using this method I was able to remove the dependency on Quark and my hobbled together hack and live happily ever after.