Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

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


Recommended Posts

Posted (edited)

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.

Link to post
Share on other sites

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.

  • Like 1
Link to post
Share on other sites
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.

Link to post
Share on other sites
  • 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.

Guest
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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.