Jump to content

Pause/Start ticker


Alioth Merak

Recommended Posts

I have a block entity which I want to tick only in certain cases. I want to enable ticking based on user interaction, and disable it based on internal logic. This is for performance reasons. I have implemented the ticker using getTicker, but I am not sure how to terminate it. I found that updating the block state calls the method to get the ticker. Do I have to do something with this block state, so that I can return null in the getTicker method? Or, can I just remove and add the ticker some other way?

Link to comment
Share on other sites

3 minutes ago, ChampionAsh5357 said:

You should either keep the block state ticking or not have it tick. You can essentially emulate not ticking by doing nothing in the tick method. If you really wanted to remove the ticker, you could use a separate BlockState to determine whether the ticker exists or is null.

I wanted to preserve performance, as I mentioned. I'll have thousands of those block entities in the world. I've implemented the blockstate method and did not like it very much, so I opted for an access transformer.

Link to comment
Share on other sites

22 minutes ago, Alioth Merak said:

I wanted to preserve performance, as I mentioned. I'll have thousands of those block entities in the world. I've implemented the blockstate method and did not like it very much, so I opted for an access transformer.

Sure, though I typically don't recommend reflection or ATs if there is a viable alternative without them.

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.