Jump to content

[1.10] Custom Grass-Like Block


drok0920

Recommended Posts

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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});

Link to comment
Share on other sites

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.

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.