Klasse PlantGrowthEvent

java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.world.PlantGrowthEvent
Alle implementierten Schnittstellen:
Cancellable

public final class PlantGrowthEvent extends Event implements Cancellable
Called when a plant grows (i.e transition to next growth stage).
Note: Most growable plants have multiple "growth stages", so a sapling usually never turns into a fully grown plant directly. For example, a tomato sapling (internal name "tomato_sapling") first turns into a tiny tomato plant ("tomato_s0"), then into a bigger plant ("tomtato_s1"), then it turns into a grown plant without fruits ("tomato_s2"), then some unripe tomatoes appear ("tomato_s3"), and finally you get the fully grown tomato plant ("tomato"). In total, the PlantGrowthEvent will be triggered 5 times in this case (for every growth stage).
  • Methodendetails

    • getGlobalID

      public long getGlobalID()
      Gets the global ID of the plant which is about to grow
      Gibt zurück:
      the unique global ID of the plant.
    • getPlantTypeID

      public short getPlantTypeID()
      Gets the current type ID of the plant.
      Gibt zurück:
      the plant type ID.
    • getNextStageTypeID

      public short getNextStageTypeID()
      Gets the next type ID of the plant, i.e of the next growth stage.
      Gibt zurück:
      the type ID of the next growth stage.
    • setNextStageTypeID

      public void setNextStageTypeID(short typeID)
      Changes the type ID of the next growth stage.
      Parameter:
      typeID - the new type ID.
      Example: If a plant grows, it should turn into flowers, no matter which plant it is
      1@EventMethod
      2public void onPlantGrowth(PlantGrowthEvent event){
      3 //Get the definition for the "flowers1" plant
      4 Plants.PlantDefinition plantDef = Definitions.getPlantDefinition("flowers1");
      5
      6 //Change the next growth stage type ID to the "flowers1" ID
      7 event.setNextStageTypeID(plantDef.getID());
      8}
    • getNextGrowthTime

      public int getNextGrowthTime()
      Gets the growth time for the next plant stage (in seconds). The growth time determines how long it takes until this plant grows (until it reaches the next growth stage). Returns 0 if this plant cannot grow.
      Gibt zurück:
      the growth time, in seconds.
    • setNextGrowthTime

      public void setNextGrowthTime(int growthTime)
      Sets the growth time (seconds) for the next plant stage, i.e how long it takes until this plant grows and reaches the next growth stage. Has no effect if this plant cannot grow (see getNextGrowthTime().
      Parameter:
      growthTime - the growth time, in seconds.
      Siehe auch:
    • isGrowable

      public boolean isGrowable()
      Gets whether or not this new plant stage can grow. If this method returns false, it means that the final growth stage is already reached (i.e fully grown tree, for example).
      Gibt zurück:
      true if the plant can still grow, false if not.
    • getChunkPositionX

      public int getChunkPositionX()
      Gets the x offset of the chunk (which contains the plant).
      Gibt zurück:
      the x chunk offset.
    • getChunkPositionY

      public int getChunkPositionY()
      Gets the y offset of the chunk (which contains the plant).
      Gibt zurück:
      the y chunk offset.
    • getChunkPositionZ

      public int getChunkPositionZ()
      Gets the z offset of the chunk (which contains the plant).
      Gibt zurück:
      the z chunk offset.
    • getPlantPosition

      public Vector3f getPlantPosition()
      Gets the world position of the plant as a Vector3f.
      Gibt zurück:
      the global plant position as a Vector3f.
    • getPlantRotation

      public Quaternion getPlantRotation()
      Gets the current rotation of the plant as a Quaternion. Keep in mind that the rotation can change for the new growth stage.
      Gibt zurück:
      the current plant rotation as a Quaternion.
    • getPlantDefinition

      public Plants.PlantDefinition getPlantDefinition()
    • getNextStagePlantDefinition

      public Plants.PlantDefinition getNextStagePlantDefinition()
    • isCancelled

      public boolean isCancelled()
      Beschreibung aus Schnittstelle kopiert: Cancellable
      Determines if the event is cancelled. If an event is cancelled, it will no longer be executed, but other plugins will still receive the event.

      Please note: If the event is threaded, cancellation has no effect, i.e the event will still be executed.
      Angegeben von:
      isCancelled in Schnittstelle Cancellable
      Gibt zurück:
      true if the event is cancelled, or false if not.
    • setCancelled

      public void setCancelled(boolean cancel)
      Beschreibung aus Schnittstelle kopiert: Cancellable
      Cancels this event. This means it will no longer be executed, but other plugins will still receive the event.

      Angegeben von:
      setCancelled in Schnittstelle Cancellable
      Parameter:
      cancel - set to true if you want to cancel this event.
      Example: Cancel "PlayerEnterAreaEvent", i.e prevent player from entering an area
      1//Listener class
      2public class PlayerListener implements Listener{
      3 @EventMethod
      4 public void onEnterArea(PlayerEnterAreaEvent evt){
      5 //Now the player will not be able to enter the area, i.e.
      6 //he will be teleported back to his old position (outside the area)
      7 evt.setCancelled(true);
      8 }
      9}