Jump to content

[1.8.9] Biome color


Ragagno

Recommended Posts

Hi,

I am creating a grass block with the top texture on all faces, but can't get the biome color to work : I'm stuck with the grey texture.

I tried to do like the vanilla grass is done so here's my grass class :

 

public class BlockRagagrass extends Block

{

 

    protected BlockRagagrass()

    {

        super(Material.grass);

        this.setCreativeTab(Ragamod.tabRagamod);

    }

 

    @SideOnly(Side.CLIENT)

    public int getBlockColor()

    {

        return ColorizerGrass.getGrassColor(0.5D, 1.0D);

    }

 

    @SideOnly(Side.CLIENT)

    public int getRenderColor(IBlockState state)

    {

        return this.getBlockColor();

    }

 

    @SideOnly(Side.CLIENT)

    public int colorMultiplier(IBlockAccess worldIn, BlockPos pos, int renderPass)

    {

        return BiomeColorHelper.getGrassColorAtPos(worldIn, pos);

    }

}

 

And here's a part of my init method :

 

grass_full = (new BlockRagagrass()).setHardness(0.6F).setResistance(2.0F).setStepSound(Block.soundTypeGrass).setUnlocalizedName("grass_full");

 

 

Did i miss something or there's a trick?

Thanks.

 

edit : is it something with the json block model?

Link to comment
Share on other sites

If you look at assets/minecraft/models/block/grass.json, you'll see that it sets the

"tintindex"

property for the

"up"

face of the first element (the base cube) and all faces of the second element (the side overlay). This allows the textures of those faces to be coloured and is passed as the

renderPass

argument of

Block#colorMultiplier(IBlockAccess, BlockPos, int)

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

If you use

ItemColored

for the block's item form,

Item#getColorFromItemStack

is overridden to call

Block#getRenderColor

with the state corresponding to the item metadata.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

ItemColored

would work fine, but

GameRegistry

can't actually instantiate it because of the way it uses reflection to find the constructor. Essentially the

ItemColored

constructor takes a primitive

boolean

argument, but passing a primitive

boolean

value in a vararg boxes it to a

Boolean

; so

GameRegistry

tries (and fails) to find a constructor with a

Boolean

argument. Vanilla doesn't have this issue because it instantiates its

ItemBlock

s directly instead of using reflection.

 

You can create your own class that extends

ItemColored

and has a

(Block, Boolean)

constructor (like this) and then use this as the item form of your block. You shouldn't actually need to override anything.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Link to comment
Share on other sites

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.