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

Started by AOCAWOL on Fri, 09/06/2019 - 20:58

Topic category: Help with MCreator modding

Last seen on 02:36, 18. Oct 2019
Joined Oct 2014
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
Block & Plant Color changing with the Biome [Possible Solutions]
Fri, 09/06/2019 - 20:58

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 :)

Last seen on 05:56, 18. Oct 2019
Joined Nov 2017
User points:

Statistics:

  • Comments:
  • Forum topics:
  • Modifications:
  • Wiki pages:
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"