Jump to content

Metadata/Blockstates 15 blocks only 2 blocks/names


Recommended Posts

Hey I am trying to make a mod for my daughter so she can make textures/designs for it. However I have no programming experience and have run into an issue I cant figure out. I am creating a set of metadata blocks and they all show the different textures in the inventory. The issue is there are only two names from the first 2 items. I have 1 Black Dyed Stone and 14 Blue Dyed Stone. Also because of this only the black and blue stones can be placed in the world. I can change the stone names for the two that appear as well as the textures that appear in the world in the areas that I believe the problem is in but cannot figure out how to add more names to the list without errors.



package com.panex.coloryourworld.blocks;

import java.util.List;

import com.panex.coloryourworld.creativetabs.MTabs;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.block.properties.IProperty;
import net.minecraft.block.properties.PropertyEnum;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos;
import net.minecraft.util.IStringSerializable;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;

public class StoneBlockProperties extends Block implements IMetaBlockName {

public static final PropertyEnum TYPE = PropertyEnum.create("type", StoneBlockProperties.EnumType.class);

public StoneBlockProperties(String unlocalizedName) {
	this.setHarvestLevel("pickaxe", 0);
	this.setDefaultState(this.blockState.getBaseState().withProperty(TYPE, EnumType.BLACK));

public IBlockState getStateFromMeta(int meta) {
	return this.getDefaultState().withProperty(TYPE, meta == 0 ? EnumType.BLACK : EnumType.BLUE) ;

public int getMetaFromState(IBlockState state) {
	EnumType type = (EnumType) state.getValue(TYPE);
	return type.getID();

public int damageDropped(IBlockState state) {
	return getMetaFromState(state);

protected BlockState createBlockState() {
	return new BlockState(this, new IProperty[] { TYPE });

@SuppressWarnings({ "unchecked", "rawtypes" })
public void getSubBlocks(Item itemIn, CreativeTabs tab, List list) {
	list.add(new ItemStack(itemIn, 1, 0));
	list.add(new ItemStack(itemIn, 1, 1));
	list.add(new ItemStack(itemIn, 1, 2));
	list.add(new ItemStack(itemIn, 1, 3));
	list.add(new ItemStack(itemIn, 1, 4));
	list.add(new ItemStack(itemIn, 1, 5));
	list.add(new ItemStack(itemIn, 1, 6));
	list.add(new ItemStack(itemIn, 1, 7));
	list.add(new ItemStack(itemIn, 1, );
	list.add(new ItemStack(itemIn, 1, 9));
	list.add(new ItemStack(itemIn, 1, 10));
	list.add(new ItemStack(itemIn, 1, 11));
	list.add(new ItemStack(itemIn, 1, 12));
	list.add(new ItemStack(itemIn, 1, 13));
	list.add(new ItemStack(itemIn, 1, 14));


public String getSpecialName(ItemStack stack) {
	return stack.getItemDamage() == 0 ? "black" :  "blue";  


public ItemStack getPickBlock(MovingObjectPosition target, World world, BlockPos pos) {
	return new ItemStack(Item.getItemFromBlock(this), 1, this.getMetaFromState(world.getBlockState(pos)));

public enum EnumType implements IStringSerializable {
	BLACK(0, "black"), BLUE(1, "blue"), BROWN(2, "brown"), CYAN(3, "cyan"), GREEN(4, "green"), LIGHTBLUE(5, "lightblue"), LIGHTGRAY(6, "lightgray"), LIME(7, "lime"), MAGENTA(8, "magenta"), ORANGE(9, "orange"), PINK(10, "pink"), PURPLE(11, "purple"), RED(12, "red"), WHITE(13, "white"), YELLOW(14, "yellow");

	private int ID;
	private String name;

	private EnumType(int ID, String name) {
		this.ID = ID;
		this.name = name;

	public String getName() {
		return this.name;

	public int getID() {
		return this.ID;

	public String toString() {
		return this.getName();



package com.panex.coloryourworld.blocks;

import net.minecraft.item.ItemStack;

public interface IMetaBlockName {

String getSpecialName(ItemStack stack);



package com.panex.coloryourworld.blocks;

import net.minecraft.block.Block;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;

public class ItemBlockMeta extends ItemBlock {

public ItemBlockMeta(Block block) {
	if (!(block instanceof IMetaBlockName)) {
		throw new IllegalArgumentException(String.format("The given Block %s is not an instance of ISpecialBlockName!", block.getUnlocalizedName()));

public int getMetadata(int damage)
        return damage;

public String getUnlocalizedName(ItemStack stack) {
	return super.getUnlocalizedName(stack) + "." + ((IMetaBlockName)this.block).getSpecialName(stack);



package com.panex.coloryourworld.blocks;

import com.panex.coloryourworld.items.MItems;

import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraftforge.fml.common.registry.GameRegistry;

public final class MBlocks {

//gray stone
public static Block stoneBlock;

//gem blocks
 public static Block ruby_block;
 public static Block amethyst_block;    
 public static Block amber_block;
 public static Block aquamarine_block;
 public static Block lepidolite_block;
 public static Block onyx_block;
 public static Block opal_block;
 public static Block peridot_block;
 public static Block rubellite_block;
 public static Block sapphire_block;
 public static Block silvertopaz_block;
 public static Block tigerseye_block;
 public static Block topaz_block;
 public static Block tourmaline_block;

//gem ore
    public static Block ruby_ore;
    public static Block amethyst_ore;    
    public static Block amber_ore;
    public static Block aquamarine_ore;
    public static Block lepidolite_ore;
    public static Block onyx_ore;
    public static Block opal_ore;
    public static Block peridot_ore;
    public static Block rubellite_ore;
    public static Block sapphire_ore;
    public static Block silvertopaz_ore;
    public static Block tigerseye_ore;
    public static Block topaz_ore;
    public static Block tourmaline_ore;

    public static void createBlocks() {
    	//gray stone
    	GameRegistry.registerBlock(stoneBlock = new StoneBlockProperties("stoneblock_properties"), ItemBlockMeta.class, "stoneblock_properties");
    	//gem block
    	GameRegistry.registerBlock(amethyst_block = new GemBlock("amethyst_block", Material.rock), "amethyst_block");
    	GameRegistry.registerBlock(amber_block = new GemBlock("amber_block", Material.rock), "amber_block");
    	GameRegistry.registerBlock(aquamarine_block = new GemBlock("aquamarine_block", Material.rock), "aquamarine_block");
    	GameRegistry.registerBlock(lepidolite_block = new GemBlock("lepidolite_block", Material.rock), "lepidolite_block");
    	GameRegistry.registerBlock(onyx_block = new GemBlock("onyx_block", Material.rock), "onyx_block");
    	GameRegistry.registerBlock(opal_block = new GemBlock("opal_block", Material.rock), "opal_block");
    	GameRegistry.registerBlock(peridot_block = new GemBlock("peridot_block", Material.rock), "peridot_block");
    	GameRegistry.registerBlock(rubellite_block = new GemBlock("rubellite_block", Material.rock), "rubellite_block");
    	GameRegistry.registerBlock(ruby_block = new GemBlock("ruby_block", Material.rock), "ruby_block");
    	GameRegistry.registerBlock(sapphire_block = new GemBlock("sapphire_block", Material.rock), "sapphire_block");
    	GameRegistry.registerBlock(silvertopaz_block = new GemBlock("silvertopaz_block", Material.rock), "silvertopaz_block");
    	GameRegistry.registerBlock(tigerseye_block = new GemBlock("tigerseye_block", Material.rock), "tigerseye_block");
    	GameRegistry.registerBlock(topaz_block = new GemBlock("topaz_block", Material.rock), "topaz_block");
    	GameRegistry.registerBlock(tourmaline_block = new GemBlock("tourmaline_block", Material.rock), "tourmaline_block");

    	//gem ore
    	GameRegistry.registerBlock(amethyst_ore = new OreBlock("amethyst_ore", Material.rock, MItems.amethystgem, 1, 2), "amethyst_ore");
    	GameRegistry.registerBlock(ruby_ore = new OreBlock("ruby_ore", Material.rock, MItems.rubygem, 1, 2), "ruby_ore");    	
    	GameRegistry.registerBlock(amber_ore = new OreBlock("amber_ore", Material.rock, MItems.ambergem, 1, 2), "amber_ore");
    	GameRegistry.registerBlock(aquamarine_ore = new OreBlock("aquamarine_ore", Material.rock, MItems.aquamarinegem, 1, 2), "aquamarine_ore");
    	GameRegistry.registerBlock(lepidolite_ore = new OreBlock("lepidolite_ore", Material.rock, MItems.lepidolitegem, 1, 2), "lepidolite_ore");
    	GameRegistry.registerBlock(onyx_ore = new OreBlock("onyx_ore", Material.rock, MItems.onyxgem, 1, 2), "onyx_ore");
    	GameRegistry.registerBlock(opal_ore = new OreBlock("opal_ore", Material.rock, MItems.opalgem, 1, 2), "opal_ore");
    	GameRegistry.registerBlock(peridot_ore = new OreBlock("peridot_ore", Material.rock, MItems.peridotgem, 1, 2), "peridot_ore");
    	GameRegistry.registerBlock(rubellite_ore = new OreBlock("rubellite_ore", Material.rock, MItems.rubellitegem, 1, 2), "rubellite_ore");
    	GameRegistry.registerBlock(sapphire_ore = new OreBlock("sapphire_ore", Material.rock, MItems.sapphiregem, 1, 2), "sapphire_ore");
    	GameRegistry.registerBlock(silvertopaz_ore = new OreBlock("silvertopaz_ore", Material.rock, MItems.silvertopazgem, 1, 2), "silvertopaz_ore");
    	GameRegistry.registerBlock(tigerseye_ore = new OreBlock("tigerseye_ore", Material.rock, MItems.tigerseyegem, 1, 2), "tigerseye_ore");
    	GameRegistry.registerBlock(topaz_ore = new OreBlock("topaz_ore", Material.rock, MItems.topazgem, 1, 2), "topaz_ore");
    	GameRegistry.registerBlock(tourmaline_ore = new OreBlock("tourmaline_ore", Material.rock, MItems.tourmalinegem, 1, 2), "tourmaline_ore");




package com.panex.coloryourworld.client.render.blocks;

import com.panex.coloryourworld.Main;
import com.panex.coloryourworld.blocks.MBlocks;

import net.minecraft.block.Block;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.model.ModelBakery;
import net.minecraft.client.resources.model.ModelResourceLocation;
import net.minecraft.item.Item;

public final class BlockRenderRegister {

public static void preInit() {
			"coloryourworld:stoneblock_properties_yellow" );

 public static void registerBlockRenderer() {

	 //stone blocks
	 	reg(MBlocks.stoneBlock, 0, "stoneblock_properties_black");
		reg(MBlocks.stoneBlock, 1, "stoneblock_properties_blue");
		reg(MBlocks.stoneBlock, 2, "stoneblock_properties_brown");
		reg(MBlocks.stoneBlock, 3, "stoneblock_properties_cyan");
		reg(MBlocks.stoneBlock, 4, "stoneblock_properties_green");
		reg(MBlocks.stoneBlock, 5, "stoneblock_properties_lightblue");
		reg(MBlocks.stoneBlock, 6, "stoneblock_properties_lightgray");
		reg(MBlocks.stoneBlock, 7, "stoneblock_properties_lime");
		reg(MBlocks.stoneBlock, 8, "stoneblock_properties_magenta");
		reg(MBlocks.stoneBlock, 9, "stoneblock_properties_orange");
		reg(MBlocks.stoneBlock, 10, "stoneblock_properties_pink");
		reg(MBlocks.stoneBlock, 11, "stoneblock_properties_purple");
		reg(MBlocks.stoneBlock, 12, "stoneblock_properties_red");
		reg(MBlocks.stoneBlock, 13, "stoneblock_properties_white");
		reg(MBlocks.stoneBlock, 14, "stoneblock_properties_yellow");

	 //gem block

	 //gem ore

	public static String modid = Main.MODID;

	public static void reg(Block block) {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), 0, new ModelResourceLocation(modid + ":" + block.getUnlocalizedName().substring(5), "inventory"));
	public static void reg(Block block, int meta, String file) {
		Minecraft.getMinecraft().getRenderItem().getItemModelMesher().register(Item.getItemFromBlock(block), meta, new ModelResourceLocation(modid + ":" + file, "inventory"));



tile.stoneblock_properties.black.name=Black Dyed Stone
tile.stoneblock_properties.blue.name=Blue Dyed Stone
tile.stoneblock_properties.brown.name=Brown Dyed Stone
tile.stoneblock_properties.cyan.name=Cyan Dyed Stone
tile.stoneblock_properties.green.name=Green Dyed Stone
tile.stoneblock_properties.lightblue.name=Light Blue Dyed Stone
tile.stoneblock_properties.lightgray.name=Light Gray Dyed Stone
tile.stoneblock_properties.lime.name=Lime Dyed Stone
tile.stoneblock_properties.magenta.name=Magenta Dyed Stone
tile.stoneblock_properties.orange.name=Orange Dyed Stone
tile.stoneblock_properties.pink.name=Pink Dyed Stone
tile.stoneblock_properties.purple.name=Purple Dyed Stone
tile.stoneblock_properties.red.name=Red Dyed Stone
tile.stoneblock_properties.white.name=White Dyed Stone
tile.stoneblock_properties.yellow.name=Yellow Dyed Stone




    "variants": {
        "type=black": { "model":"coloryourworld:stoneblock_properties_black" },
        "type=blue": { "model":"coloryourworld:stoneblock_properties_blue" },
"type=brown": { "model":"coloryourworld:stoneblock_properties_brown" },
"type=cyan": { "model":"coloryourworld:stoneblock_properties_cyan" },
"type=green": { "model":"coloryourworld:stoneblock_properties_green" },
"type=lightblue": { "model":"coloryourworld:stoneblock_properties_lightblue" },
"type=lightgray": { "model":"coloryourworld:stoneblock_properties_lightgray" },
"type=lime": { "model":"coloryourworld:stoneblock_properties_lime" },
"type=magenta": { "model":"coloryourworld:stoneblock_properties_magenta" },
"type=orange": { "model":"coloryourworld:stoneblock_properties_orange" },
"type=pink": { "model":"coloryourworld:stoneblock_properties_pink" },
"type=purple": { "model":"coloryourworld:stoneblock_properties_purple" },
"type=red": { "model":"coloryourworld:stoneblock_properties_red" },
"type=white": { "model":"coloryourworld:stoneblock_properties_white" },
"type=yellow": { "model":"coloryourworld:stoneblock_properties_yellow" }


model/blocks stoneblock_properties_black.json

this is one of the 15 files all the rest are the same except for the color names change both in name of file and inside the file.


"textures": {
	"all": "coloryourworld:blocks/stoneblock_properties_black"


model/items stoneblock_properties_black.json


this is one of the 15 files all the rest are the same except for the color names change both in name of file and inside the file.


    "display": {
        "thirdperson": {
            "rotation": [ 10, -45, 170 ],
            "translation": [ 0, 1.5, -2.75 ],
            "scale": [ 0.375, 0.375, 0.375 ]


If I have forgotten to put in anything that will help please let me know and I will get it posted. Also like I said I am new to programming so the dumber the explanation can be the better. I really appreciate any help that can be given. Thank you.












You mean, you put down your rock and I put down my sword, and we try kill each other like civilized people?


Link to comment
Share on other sites

I found that problem and its the area I mentioned that I could change the names of the enumtypes but for the life of me I cant figure out how to add more to it. Everytime I try adding the other names to that list I get errors to the whole section of code. If I change one of the existing ones it does change the block texture placed in game. Also the same goes for the .getspecialname if I change the types there it changes the names but if I try to add more I get errors on that entire section of code as well.

You mean, you put down your rock and I put down my sword, and we try kill each other like civilized people?


Link to comment
Share on other sites

Then you need to Google the syntax of Java enum. After fixing that (or deciding to use one of vanilla Minecraft's existing color types), then replace your expression in the state from meta method.


Get rid of the trinary operator. I recommend using an enum's built in values array to return the enum value for a given integer.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.

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.

  • Create New...

Important Information

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