Jump to content

[1.12.2] Block with property boolean error


American2050

Recommended Posts

I wonder what I'm doing wrong here. Trying to register a block with a property boolean for "Powered" but I get an error and not sure what causes it.

 

I have:

 

public class BlockZand extends GenericModBlockFalling implements IHasModel{
	
	public static final PropertyBool POWERED = PropertyBool.create("powered");
	
	public BlockZand(Material materialIn, String name) {
		super(materialIn, name);
		this.setUnlocalizedName(ModInfo.MODID + ":" + name);
		this.setHardness(1.0F);
		this.setSoundType(SoundType.SAND);
		this.setTickRandomly(true);
		this.setLightLevel(5F);
		
		this.setDefaultState(this.blockState.getBaseState().withProperty(POWERED, Boolean.valueOf(false)));
		
		ModBlocks.BLOCKS.add(this);
		ModItems.ITEMS.add(new ItemBlock(this).setRegistryName(this.getRegistryName()));
	}

 

The error:

 

[12:16:18] [main/ERROR] [FML]: Exception caught during firing event net.minecraftforge.event.RegistryEvent$Register@11c929a2:
java.lang.ExceptionInInitializerError: null
	at com.mramericanmike.zand.handlers.RegistryHandler.onBlockRegister(RegistryHandler.java:24) ~[RegistryHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler_5_RegistryHandler_onBlockRegister_Register.invoke(.dynamic) ~[?:?]
	at net.minecraftforge.fml.common.eventhandler.ASMEventHandler.invoke(ASMEventHandler.java:90) ~[ASMEventHandler.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus$1.invoke(EventBus.java:143) ~[EventBus$1.class:?]
	at net.minecraftforge.fml.common.eventhandler.EventBus.post(EventBus.java:179) [EventBus.class:?]
	at net.minecraftforge.registries.GameData.fireRegistryEvents(GameData.java:736) [GameData.class:?]
	at net.minecraftforge.fml.common.Loader.preinitializeMods(Loader.java:603) [Loader.class:?]
	at net.minecraftforge.fml.client.FMLClientHandler.beginMinecraftLoading(FMLClientHandler.java:270) [FMLClientHandler.class:?]
	at net.minecraft.client.Minecraft.init(Minecraft.java:513) [Minecraft.class:?]
	at net.minecraft.client.Minecraft.run(Minecraft.java:421) [Minecraft.class:?]
	at net.minecraft.client.main.Main.main(Main.java:118) [Main.class:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
	at net.minecraft.launchwrapper.Launch.launch(Launch.java:135) [launchwrapper-1.12.jar:?]
	at net.minecraft.launchwrapper.Launch.main(Launch.java:28) [launchwrapper-1.12.jar:?]
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_151]
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_151]
	at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_151]
	at net.minecraftforge.gradle.GradleStartCommon.launch(GradleStartCommon.java:97) [start/:?]
	at GradleStart.main(GradleStart.java:26) [start/:?]
Caused by: java.lang.IllegalArgumentException: Cannot set property PropertyBool{name=powered, clazz=class java.lang.Boolean, values=[true, false]} as it does not exist in BlockStateContainer{block=null, properties=[]}
	at net.minecraft.block.state.BlockStateContainer$StateImplementation.withProperty(BlockStateContainer.java:221) ~[BlockStateContainer$StateImplementation.class:?]
	at com.mramericanmike.zand.blocks.BlockZand.<init>(BlockZand.java:45) ~[BlockZand.class:?]
	at com.mramericanmike.zand.init.ModBlocks.<clinit>(ModBlocks.java:15) ~[ModBlocks.class:?]

 

The registration:

 

	@SubscribeEvent
	public static void onBlockRegister(RegistryEvent.Register<Block> event){
		event.getRegistry().registerAll(ModBlocks.BLOCKS.toArray(new Block[0]));
	}

 

I guess my problem is that I'm either extending wrong classes or trying to set the default value at the wrong time?

 

Thanks for your help.

Edited by American2050
Link to comment
Share on other sites

Caused by: java.lang.IllegalArgumentException: Cannot set property PropertyBool{name=powered, clazz=class java.lang.Boolean, values=[true, false]} as it does not exist in BlockStateContainer{block=null, properties=[]}
	

You haven't overriddencreateBlockState

 

  • Like 2

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Link to comment
Share on other sites

58 minutes ago, Draco18s said:

Caused by: java.lang.IllegalArgumentException: Cannot set property PropertyBool{name=powered, clazz=class java.lang.Boolean, values=[true, false]} as it does not exist in BlockStateContainer{block=null, properties=[]}
	

You haven't overriddencreateBlockState

 

Thanks you.

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.