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

So I'm trying to create an instance of Block

static {
        Block funnyUselessBlockWithNoPurpose = new Block(BlockBehaviour.Properties.of(Material.AIR));
}

 

I don't want to register it in block registry or use it anywhere else, only need this temporary to measure a few things. However it fails with "Registry is already frozen".

Shouldn't block register when I actually call `BLOCKS.register(name, block);`?
 

Spoiler

 

java.lang.reflect.InvocationTargetException: null
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[?:?]
	at jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) ~[?:?]
	at jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[?:?]
	at java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) ~[?:?]
	at java.lang.reflect.Constructor.newInstance(Constructor.java:480) ~[?:?]
	at net.minecraftforge.fml.javafmlmod.FMLModContainer.constructMod(FMLModContainer.java:68) ~[javafmllanguage-1.19.3-44.1.4.jar%23187!/:?]
	at net.minecraftforge.fml.ModContainer.lambda$buildTransitionHandler$10(ModContainer.java:121) ~[fmlcore-1.19.3-44.1.4.jar%23190!/:?]
	at java.util.concurrent.CompletableFuture$AsyncRun.run(CompletableFuture.java:1804) ~[?:?]
	at java.util.concurrent.CompletableFuture$AsyncRun.exec(CompletableFuture.java:1796) ~[?:?]
	at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:373) ~[?:?]
	at java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1182) ~[?:?]
	at java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1655) ~[?:?]
	at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1622) ~[?:?]
	at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:165) ~[?:?]
Caused by: java.lang.ExceptionInInitializerError
	at ****.mod1.<init>(mod1.java:26) ~[%23191!/:?]
	... 14 more
Caused by: java.lang.IllegalStateException: Registry is already frozen
	at net.minecraftforge.registries.NamespacedWrapper.validateWrite(NamespacedWrapper.java:264) ~[forge-1.19.3-44.1.4_mapped_official_1.19.3-recomp.jar%23185%23192!/:?]
	at net.minecraftforge.registries.NamespacedWrapper.createIntrusiveHolder(NamespacedWrapper.java:358) ~[forge-1.19.3-44.1.4_mapped_official_1.19.3-recomp.jar%23185%23192!/:?]
	at net.minecraft.world.level.block.Block.<init>(Block.java:67) ~[forge-1.19.3-44.1.4_mapped_official_1.19.3-recomp.jar%23186!/:?]
	at ****.modBlocks.<clinit>(modBlocks.java:42) ~[%23191!/:?]
	at ****.<init>(mod1.java:26) ~[%23191!/:?]
	... 14 more

 

 

Edited by A_A

4 hours ago, A_A said:

So I'm trying to create an instance of Block

Can't you instead use one of the blocks in the Blocks class (such as Blocks.AIR) to do the measurements?

  • Author

No, I was measuring execution time for a method in my custom block 10000 (A-B testing) times and I was too lazy to wait for Minecraft to load up for every change. Looking at Minecraft code they can do it but with forge in place, it seems register somehow gets called via code injected into block init (probably to register vanilla blocks?).

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.