Block & Plant Color changing with the Biome [Possible Solutions]

Started by AOCAWOL on

Topic category: Help with Minecraft modding (Java Edition)

Joined Oct 2014
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Block & Plant Color changing with the Biome [Possible Solutions]

I found this while digging through Biome.java 

    @SideOnly(Side.CLIENT)
    public int getGrassColorAtPos(BlockPos pos)
    {
        double d0 = (double)MathHelper.clamp(this.getTemperature(pos), 0.0F, 1.0F);
        double d1 = (double)MathHelper.clamp(this.getRainfall(), 0.0F, 1.0F);
        return getModdedBiomeGrassColor(ColorizerGrass.getGrassColor(d0, d1));
    }

 

So that's I think the biome changes the grass block's color.

also saw this in grass block, not sure if it's helpful 

    @SideOnly(Side.CLIENT)
    public BlockRenderLayer getBlockLayer()
    {
        return BlockRenderLayer.CUTOUT_MIPPED;
    }

    /**
     * Convert the BlockState into the correct metadata value
     */
    public int getMetaFromState(IBlockState state)

----------------------------------------------------
If anyone has any coding experience and actually knows how to implement biome color-dependent blocks please speak up :D

It's something my mod heavily needs :)

Joined Nov 2017
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Some info about the extra…
Sat, 09/07/2019 - 22:31

Some info about the extra code:
public BlockRenderLayer getBlockLayer() describes how the block is rendered (they're the transparency settings you can chose when creating a custom block: solid, cutout, cutout-mipped, translucent)
public int getMetaFromState(IBlockState state) is used by blocks with block states and isn't related to grass color: grass uses block states to pick between "tall grass", "fern" and the unused "shrub"