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

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

  • Author

Ok, I'm an idiot, I was initializing the value of the block with the wrong class, I was overthinking the error  :-X. Thanks diesieben07!!!!

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

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.