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
  • [1.16] How to run code on world tick?
Currently Supported: 1.16.X (Latest) and 1.15.X (LTS)
Sign in to follow this  
Followers 1
kiou.23

[1.16] How to run code on world tick?

By kiou.23, December 4, 2020 in Modder Support

  • Reply to this topic
  • Start new topic

Recommended Posts

kiou.23    5

kiou.23

kiou.23    5

  • Creeper Killer
  • kiou.23
  • Members
  • 5
  • 156 posts
Posted December 4, 2020

I have some values attached to chunks through capabilities, and I would like to update this values on every tick (if there is a more commom, stantard, efficient way of doing this I'd like to know).

I've tried subscribing to the TickEvent, but the event doesn't have a reference to the world, I could use Minecraft.getInstance().world, but I heard that that can break the server.

So how should go about implementing this

 

  • Quote

Share this post


Link to post
Share on other sites

poopoodice    110

poopoodice

poopoodice    110

  • Dragon Slayer
  • poopoodice
  • Members
  • 110
  • 891 posts
Posted December 4, 2020

TickEvent has multiple sub events, in this case you should use WorldTickEvent which provides the world instance.

  • Quote

Share this post


Link to post
Share on other sites

kiou.23    5

kiou.23

kiou.23    5

  • Creeper Killer
  • kiou.23
  • Members
  • 5
  • 156 posts
Posted December 4, 2020
9 minutes ago, poopoodice said:

TickEvent has multiple sub events, in this case you should use WorldTickEvent which provides the world instance.

ohh Okay, when I typed TickEvent, intellisense didn't show the other events, only TickEvent.

  • Quote

Share this post


Link to post
Share on other sites

poopoodice    110

poopoodice

poopoodice    110

  • Dragon Slayer
  • poopoodice
  • Members
  • 110
  • 891 posts
Posted December 4, 2020

They are located inside TickEvent.

https://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

  • Quote

Share this post


Link to post
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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  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.

    • Insert image from URL
×
  • Desktop
  • Tablet
  • Phone
Sign in to follow this  
Followers 1
Go To Topic Listing



  • Recently Browsing

    No registered users viewing this page.

  • Posts

    • diesieben07
      Do stuff right after login

      By diesieben07 · Posted 4 minutes ago

      Yes, it is server side only. For client-side you can use ClientPlayerNetworkEvent.LoggedInEvent.
    • dotifo7120
      Do stuff right after login

      By dotifo7120 · Posted 9 minutes ago

      Is it only server-side? I tried to use in client and the event wasn't firing. 🙁
    • diesieben07
      Do stuff right after login

      By diesieben07 · Posted 49 minutes ago

      PlayerLoggedInEvent
    • dotifo7120
      Do stuff right after login

      By dotifo7120 · Posted 1 hour ago

      Is there an event called when a player enters into the world (fully logged)?
    • diesieben07
      Windows installer

      By diesieben07 · Posted 1 hour ago

      Just use the installer, it is cross-platform.
  • Topics

    • dotifo7120
      3
      Do stuff right after login

      By dotifo7120
      Started 1 hour ago

    • T_Jam1
      1
      Windows installer

      By T_Jam1
      Started 1 hour ago

    • Mounty
      3
      Meine Inkompetenz kennt mal wieder keine Grenzen.(Forge 1.16.1)

      By Mounty
      Started 3 hours ago

    • Amperka_pro
      5
      Как применить нбт к предмету.

      By Amperka_pro
      Started 5 hours ago

    • MistyMarshes
      9
      [1.16.4] Get IChunk World / get current World for the overworld.

      By MistyMarshes
      Started 15 hours ago

  • Who's Online (See full list)

    • jbredwards
    • Alexalien
    • magn919
    • Forix
    • Umpaz
    • dotifo7120
    • jbko6
    • diesieben07
    • ThatBearQuen
    • st4s1k
    • Orbital_Gaming
    • forresttrump
    • Mr. Crafty
  • All Activity
  • Home
  • Mod Developer Central
  • Modder Support
  • [1.16] How to run code on world tick?
  • Theme

Copyright © 2019 ForgeDevelopment LLC · Ads by Longitude Ads LLC Powered by Invision Community