Class InitialEnvironmentChangeResult<T>

java.lang.Object
com.github.thedeathlycow.thermoo.api.temperature.event.InitialEnvironmentChangeResult<T>
Direct Known Subclasses:
InitialSoakChangeResult, InitialTemperatureChangeResult

public abstract class InitialEnvironmentChangeResult<T> extends Object
This class is to ensure that changes in environmental effects, such as temperature from TemperatureAware or wetness from a Soakable that come from common sources dictated by the EnvironmentController are not applied more than once to an affectee.

Changes are not actually applied until after the event invocation is complete, so that it may be modified by listeners. By default, the change will NOT be applied by the event - a listener must explicitly tell Thermoo to do so. This is to allow for other mods or datapacks to define their own implementations for passive temperature changes, using the Thermoo temperature attribute. Or to allow for them to disable passive temperature changes in the case they do not want them.

  • Constructor Details

    • InitialEnvironmentChangeResult

      public InitialEnvironmentChangeResult(T affectee, int initialChange)
      Creates an initial environment change result with an affectee and an amount
      Parameters:
      affectee - The entity affected by the change
      initialChange - The change's initial value
  • Method Details

    • applyChange

      protected abstract void applyChange(T affectee, int amount)
      Applies the initial change to an affectee.
      Parameters:
      affectee - The affectee of the change
      amount - The amount of change to apply
    • getInitialChange

      public int getInitialChange()
      Returns:
      Returns the initial change value of the result
    • setInitialChange

      public void setInitialChange(int amount)
      Set the initial change to a new value
      Parameters:
      amount - The new value for the initial change
    • isInitialChangeApplied

      public boolean isInitialChangeApplied()
      Returns:
      Returns true if the initial change was applied
    • applyInitialChange

      public final void applyInitialChange()
      Tells Thermoo to apply the change to the affectee

      If multiple listeners call this, then it will only be applied once.

      Changes are not actually applied until after the event invocation is complete, so that it may be modified by listeners.

    • onEventComplete

      public void onEventComplete()
      Called AFTER the event this was created for has completed its invocation. Will actually apply the changes to from event so that listeners may modify the change if they so wish.