Jump to content
  • Home
  • Files
  • Docs
Topics
  • All Content

  • This Topic
  • This Forum

  • Advanced Search
  • Existing user? Sign In  

    Sign In



    • Not recommended on shared computers


    • Forgot your password?

  • Sign Up
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • updateTick() for Blocks is Being Slow
The update for 1.13 is being worked on - please be patient. (Updated 02/19/19)
1.13 Update Notes for Mod Creators
Sign in to follow this  
Followers 2
Cyberdragon

updateTick() for Blocks is Being Slow

Started by Cyberdragon, November 17, 2018

9 posts in this topic

Cyberdragon    1

Cyberdragon

Cyberdragon    1

  • Tree Puncher
  • Cyberdragon
  • Members
  • 1
  • 16 posts
  • Report post
Posted November 17, 2018

I've been trying to figure this out for awhile now. I have a block with an updateTick() and setTickRandomly() on true. https://pastebin.com/u1zz4LZT However, the ticks are incredibly slow, sometimes minutes apart. I found reference to a similar issue in a really old thread elsewhere, but no answer. I have tried playing with tickRate() with no effect, and also randomTick(). I tried doing something with scheduleBlockUpdate() by forcing a tick with onBlockAdded() then again in the updateTick() (massively bad idea?), and it sort of worked but led to strange and unintended behavior. Note: It does not need to be the full tick speed, just fast enough to not be noticeable in-game.

 

Strangely, it works fine for anything extending blockBush. Does it have to be a plant to work correctly? (I would think not)

Share this post


Link to post
Share on other sites

Draco18s    1928

Draco18s

Draco18s    1928

  • Reality Controller
  • Draco18s
  • Members
  • 1928
  • 12868 posts
  • Report post
Posted November 17, 2018

Blocks do not update every tick. That's not how that function works. 

 

tickRate() does fuckall unless you call it yourself. 

Share this post


Link to post
Share on other sites

Laike_Endaril    7

Laike_Endaril

Laike_Endaril    7

  • Creeper Killer
  • Laike_Endaril
  • Members
  • 7
  • 117 posts
  • Report post
Posted November 17, 2018 (edited)

In general I'm not sure I'd suggest using those methods for something you want to happen "every tick".  There are several different forge handles that fire on tick events, but I think the one you'd be most interested in is TickEvent.WorldTickEvent (this is the tick that usually happens 20 times per second for each given dimension, and is shown if you run the in-game command "/forge tps")

 

The other tick events can also be found in the same class (TickEvent).

 

Any chance you could tell us what it is you're trying to do every tick?  Better make sure it's not too expensive or you'll break the game pretty fast.

 

Edit 1 ===============

If you decide to subscribe your block itself to the world tick event, make sure you have it check the event to see what world it is for, or else each block will be using the event once for each loaded dimension.

Edited November 17, 2018 by Laike_Endaril

Share this post


Link to post
Share on other sites

Cadiboo    145

Cadiboo

Cadiboo    145

  • World Shaper
  • Cadiboo
  • Members
  • 145
  • 2121 posts
  • Report post
Posted November 17, 2018
3 hours ago, Laike_Endaril said:

In general I'm not sure I'd suggest using those methods for something you want to happen "every tick".  There are several different forge handles that fire on tick events, but I think the one you'd be most interested in is TickEvent.WorldTickEvent (this is the tick that usually happens 20 times per second for each given dimension, and is shown if you run the in-game command "/forge tps")

 

The other tick events can also be found in the same class (TickEvent).

 

Any chance you could tell us what it is you're trying to do every tick?  Better make sure it's not too expensive or you'll break the game pretty fast.

 

Edit 1 ===============

If you decide to subscribe your block itself to the world tick event, make sure you have it check the event to see what world it is for, or else each block will be using the event once for each loaded dimension.

This is pretty much the entire purpose of tile entities

Share this post


Link to post
Share on other sites

Cyberdragon    1

Cyberdragon

Cyberdragon    1

  • Tree Puncher
  • Cyberdragon
  • Members
  • 1
  • 16 posts
  • Report post
Posted November 17, 2018 (edited)

The problem is tileEntities would probably cause way too much lag for the purpose (which is why I'm avoiding them). It only needs to spawn and despawn that block above it based on conditions, nothing more or less. And there will be alot of these blocks, they are naturally generating.

 

It also does not need to update every tick, just a few times per second. But why can plants do that (breaking when not on a solid block is an updateTick), but my block can't?

Edited November 17, 2018 by Cyberdragon

Share this post


Link to post
Share on other sites

V0idWa1k3r    308

V0idWa1k3r

V0idWa1k3r    308

  • World Shaper
  • V0idWa1k3r
  • Members
  • 308
  • 1443 posts
  • Report post
Posted November 17, 2018
19 minutes ago, Cyberdragon said:

breaking when not on a solid block is an updateTick

Plants check whether they can stay or not when their neighbour changes, not when the block receives the update tick. Actually a lot of blocks work like that - crops, torches, end rods, flowers, fire, snow layers, cactus, chorus plants, tallgrass, mushrooms, sugar cane, vines, ladders, pots... I could go on but you hopefully get my point. All these blocks don't update(most of them don't even allow the world to "tick" them) but rather detect neighbours changing and re-evaluate themselves. See any of those block's classes to see how they do that. I would recommend BlockLadder since it is probably the least complex of them all.

 

If that doesn't work for you then you might need to use forge's WorldTickEvent to manually run whatever logic you need. There is really no way to make the block "tick" every X ticks without either using a TE(which you want to avoid) or scheduling block updates(which is just as slow as TEs are pretty much but has additional issues that can easily crash your world, especially if there are a lot of them scheduled, I've personally experienced the "ticknexttick list out of sync" issue as an example)

Share this post


Link to post
Share on other sites

Cyberdragon    1

Cyberdragon

Cyberdragon    1

  • Tree Puncher
  • Cyberdragon
  • Members
  • 1
  • 16 posts
  • Report post
Posted November 17, 2018

As I said, I have tried scheduled ticks and it does sort of work but yeah, it glitches. I'll try an eventbus with tick events then and see what happens.

Share this post


Link to post
Share on other sites

diesieben07    6112

diesieben07

diesieben07    6112

  • Reality Controller
  • diesieben07
  • Forum Team
  • 6112
  • 40239 posts
  • Report post
Posted November 17, 2018

Doing it with a tile entity will not cause any more performance issues than ticking it in some other way. In fact, I have found repeatedly scheduled block ticks to be way less performant than just using a tile entity.

Share this post


Link to post
Share on other sites

Cadiboo    145

Cadiboo

Cadiboo    145

  • World Shaper
  • Cadiboo
  • Members
  • 145
  • 2121 posts
  • Report post
Posted November 18, 2018
9 hours ago, Cyberdragon said:

As I said, I have tried scheduled ticks and it does sort of work but yeah, it glitches. I'll try an eventbus with tick events then and see what happens.

Please don't, either make a TileEntity or use net.minecraft.block.Block#onNeighborChange

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
Followers 2
Go To Topic Listing Modder Support

  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      [1.13.2] Getting Instance of LootTableManager

      By diesieben07 · Posted 5 minutes ago

      Probably due to the rewrite to use data packs.
    • DavidM
      [1.13.2] Getting Instance of LootTableManager

      By DavidM · Posted 10 minutes ago

      Just out of curiosity, why is LootTableManager MinecraftServer specific instead of World specific in 1.13.2?
    • diesieben07
      [1.13.2] Getting Instance of LootTableManager

      By diesieben07 · Posted 19 minutes ago

      ServerLifecycleHooks.getCurrentServer().getLootTableManager
    • DavidM
      Why does FORGE Forum not provide Chinese?

      By DavidM · Posted 19 minutes ago

      1. Minecraft is not originated in China, thus the majority of the gaming community speaks English. 2. Adding support for another language takes a long time. 3. There really is no need to. There is already a Chinese forum called Mcbbs. 4. Learn English. It is easier to adapt to the world than to make the world adapt to you. 
    • DavidM
      [1.13.2] Getting Instance of LootTableManager

      By DavidM · Posted 39 minutes ago

      I am trying to create a LootTable from a ResourceLocation. I am doing so with LootTableManager#getLootTableFromLocation.   How would I get an instance of LootTableManager in 1.13.2? Back in 1.12.2, I used World#getLootTableManager.
  • Topics

    • DavidM
      3
      [1.13.2] Getting Instance of LootTableManager

      By DavidM
      Started 39 minutes ago

    • QWQ
      2
      Why does FORGE Forum not provide Chinese?

      By QWQ
      Started January 4

    • MrMarnic
      3
      No Values in ForgeRegistries.ENTITIES 1.13.2

      By MrMarnic
      Started 13 hours ago

    • HeberonYT
      3
      Version Manifest - Forge

      By HeberonYT
      Started Yesterday at 02:02 AM

    • DavidM
      1
      [1.13.2] Config Files

      By DavidM
      Started 22 hours ago

  • Who's Online (See full list)

    • KonanTheRabbit
    • DavidM
    • DutchM
    • Melonslise
    • LTNightshade
    • portablejim
    • diesieben07
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • updateTick() for Blocks is Being Slow
  • Theme
  • Contact Us

Copyright © 2017 ForgeDevelopment LLC Powered by Invision Community