Class UpdateEvent

java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.general.UpdateEvent

public final class UpdateEvent extends Event
Called every tick.

Attention: This is a high frequency event! Be careful when doing extensive computations in this event or calling blocking methods, since that may have a big impact on Performance
  • Constructor Details

    • UpdateEvent

      public UpdateEvent(float tpf)
  • Method Details

    • getTpf

      public float getTpf()
      Gets the time-per-frame, i.e the amount of seconds between the last call and this call. You can use this variable to calculate the passed time, for example (e.g increment a value
      Returns:
      the time-per-frame (in seconds).
      Example: Use tpf as a counter variable
      1//Our counter variable somehwere in our plugin
      2public float counter = 0f;
      3
      4//Our event method
      5@EventMethod
      6public void onUpdate(UpdateEvent evt) {
      7 //Increment timer by tpf
      8 counter += evt.getTpf();
      9
      10 //If counter is greater than 10, this means 10 seconds have passed
      11 if(counter >= 10f){
      12 //Reset counter again
      13 counter = 0f;
      14
      15 //Do something
      16 //...
      17 }
      18}