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

Hello,

I have been working on a mod for a bit now and i have tried to create a custom block that chagned color based on biome.  I have gotten the overlay to work but i can't find a way to change the color.

 

Here is what i have so far:

 

 

Block Class:

package com.drok.buildersdream.blocks;

import com.drok.buildersdream.Ref;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockRenderLayer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class BlockMossyStone extends Block {

public BlockMossyStone() {
	super(Material.ROCK);
	this.setUnlocalizedName(Ref.ModBlocks.MOSSYSTONE.getUnlocalizedName());
	this.setRegistryName(Ref.ModBlocks.MOSSYSTONE.getRegistryName());
}

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

/spoiler

 

If anyone can pointme in the right dirrection that would be great!

You need to register an

IBlockColor

and

IItemColor

for the

Block

and

Item

from your client proxy in init.

 

Look at the

BlockColors

/

ItemColors

classes to see how vanilla does this.

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 added this to my Init Method but it doesnt seem to work.  What am i doing wrong?

 

final BlockColors blockcolors = new BlockColors();
    	blockcolors.registerBlockColorHandler(new IBlockColor()
        {
            public int colorMultiplier(IBlockState state, @Nullable IBlockAccess worldIn, @Nullable BlockPos pos, int tintIndex)
            {
                return worldIn != null && pos != null ? BiomeColorHelper.getGrassColorAtPos(worldIn, pos) : ColorizerGrass.getGrassColor(0.5D, 1.0D);
            }
        }, new Block[] {ModBlocks.mossyStone});

Don't create your own instance of

BlockColors

, it's a singleton. Minecraft will only use its own instance, stored in the

Minecraft#blockColors

field.

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.