Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

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?

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.

  • Author

It works! Thanks a lot dude!

Is it the same trick to get the "item" block colored?

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.

  • Author

I've tried a lot on my own, but didn't succeed just by looking at the Grass's code.

Do I have to create a new class that inherit from ItemColored like they did for LilyPad?

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.