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

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

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

 

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.

  • Author
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.

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.