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.

[Solved] [1.16.5] Schedule block ticks -- can't get new system to work?

Featured Replies

Posted

In 1.12, it was easy to have things occur on a block at regular intervals without a block entity: just schedule a block tick, override the block's tick method, and everything worked. I'm trying that now in 1.16.5 and getting nowhere.

I have this in my block's class:

	@Override
	public void setPlacedBy(World world, BlockPos pos, BlockState state, @Nullable LivingEntity player,
			ItemStack stack) {
		super.setPlacedBy(world, pos, state, player, stack);
		System.out.println("Placed block!");
		world.getChunk(pos).getBlockTicks().scheduleTick(pos, this, 1);
		if (world.getChunk(pos).getBlockTicks().hasScheduledTick(pos, this)) {
			System.out.println("SCHEDULED TICK");
		} else {
			System.out.println("DID NOT SCHEDULE TICK");
		}
	}

It always logs "DID NOT SCHEDULE TICK". I continued testing by implementing the block's tick method, which I saw is now deprecated, to log stuff, and it's never called. Since it's deprecated, it looks like I'm meant to somehow handle block ticks through the block state's tick method, but I'm not sure how to do that since block states go through layers of builders and abstraction. I tried just creating my own class that extends BlockState, except it implements the tick method, and then copying the Block class's constructor's code for registering state except using my custom class, and that also failed to get any results.

How am I meant to schedule and handle block ticks in the new version of Forge? I can't even seem to find any documentation on the changes online anywhere.

Edited by IceMetalPunk
Solved

Whatever Minecraft needs, it is most likely not yet another tool tier.

  • Author
43 minutes ago, diesieben07 said:

Do not use the Chunk's tick list. Use ServerWorld#getBlockTicks to schedule ticks.

Mojang uses deprecations in the block class usually to mean "do not call this", overriding th emethod is fine.

๐Ÿคฆโ€โ™‚๏ธ It would be a misunderstanding like that... Thank you, it works perfectly now! You're becoming quite invaluable to my return to modding, and I fully appreciate all your help!

Whatever Minecraft needs, it is most likely not yet another tool tier.

  • IceMetalPunk changed the title to [Solved] [1.16.5] Schedule block ticks -- can't get new system to work?

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.