Jump to content

[1.10.1] Set block custom state failing


JoseluGames

Recommended Posts

When I try to spawn a block it throws an error in the console telling the property doesn't exist in the BlockStateContainer

java.lang.IllegalArgumentException: Cannot set property PropertyEnum{name=soil, clazz=class com.jlgm.projfact.block.BlockOreCluster$EnumType, values=[grass, dirt, stone, gravel, sand]} as it does not exist in BlockStateContainer{block=jlgm_projfact:oreCluster, properties=[]}

 

This is the line I use to spawn it:

world.setBlockState(newPos, ProjFactBlock.oreCluster_Block.getDefaultState().withProperty(BlockOreCluster.SOIL, BlockOreCluster.EnumType.GRASS), 2);

 

And this my Block code:

 

public class BlockOreCluster extends Block{

public static final PropertyEnum<BlockOreCluster.EnumType> SOIL = PropertyEnum.<BlockOreCluster.EnumType>create("soil", BlockOreCluster.EnumType.class);

public BlockOreCluster(Material materialIn) {
	super(materialIn);
	this.setDefaultState(this.blockState.getBaseState().withProperty(SOIL, EnumType.GRASS));
}

@Override
public IBlockState getStateFromMeta(int meta){
	return this.getDefaultState().withProperty(SOIL, EnumType.values()[meta]);
}

@Override
public int getMetaFromState(IBlockState state){
	EnumType type = (EnumType) state.getValue(SOIL);
	return type.getID();
}

@Override
    protected BlockStateContainer createBlockState()
    {
        return new BlockStateContainer(this, new IProperty[] {SOIL});
    }

    public enum EnumType implements IStringSerializable{
    	GRASS(0, "grass"),
    	DIRT(1, "dirt"),
    	STONE(2, "stone"),
    	GRAVEL(3, "gravel"),
    	SAND(4, "sand");
    	
    	private int ID;
    	private String name;
    	
    	private EnumType(int ID, String name){
    		this.ID = ID;
    		this.name = name;
    	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public String toString(){
		return getName();
	}

	public int getID(){
		return ID;
	}
    }
}

 

 

Been trying to fix it for two days with no success... Help!  :'(

Come and say hi at www.twitter.com/JoseluGames

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.



×
×
  • Create New...

Important Information

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