Jump to content

MC 1.12.2 getMapcolor


winnetrie

Recommended Posts

I made many variations of existing vanilla blocks and therefore i have an IBlockState argument in my constructor in each class.

For example for stairs and slabs you need to know on what block it is based. So i made a var called modelBlock wich i declare as "modelBlock = state.getBlock();

I use this also to get the mapcolor for the block:

    @Override
    public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    {
        //return ((BlockBaseSlabColoredA.EnumType)state.getValue(COLOR)).getMapColor();
    	return this.modelBlock.getMapColor(modelBlock.getDefaultState(), null, null);
    }

I used another aproach before, wich i commented out. I wanted to have a more/ better approach.

I wonder if this is a good approach since it looks like this getMapColor:

 

return this.modelBlock.getMapColor(modelBlock.getDefaultState(), null, null);

 

Link to comment
Share on other sites

Many methods from the Block class have been moved to IBlockState (or it's superinterfaces IBlockBehaviors and IBlockProperties). The corresponding methods in the Block class have been deprecated to signify "don't call me". Instead you should call the methods on the IBlockState. In your case you should not store a "model block" but a "model block state".

Link to comment
Share on other sites

Oh right i see. I changed it to this:

    @Override
    public MapColor getMapColor(IBlockState state, IBlockAccess worldIn, BlockPos pos)
    {
        //return ((BlockBaseSlabColoredA.EnumType)state.getValue(COLOR)).getMapColor();
    	//return this.modelBlock.getMapColor(modelBlock.getDefaultState(), null, null);
    	return this.modelState.getMapColor(null, null);
    }

I'm putting "null" for both arguments. I'm not sure this is right, but it feels wrong to enter an IBlockAccess and a BlockPos here.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now


×
×
  • Create New...

Important Information

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