Class PlayerPlaceBlueprintEvent

java.lang.Object
net.risingworld.api.events.Event
net.risingworld.api.events.player.PlayerEvent
net.risingworld.api.events.player.world.PlayerPlaceBlueprintEvent
All Implemented Interfaces:
Cancellable

public final class PlayerPlaceBlueprintEvent extends PlayerEvent implements Cancellable
Called when a player wants to place a blueprint, i.e a blueprint which was already created previously.
  • Field Summary

    Fields inherited from class Event

    cancelled, pointer
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Gets the ID of the blueprint.
    Gets the bounds of the blueprint object.
    int
    Gets the amount of construction elements (blocks) this blueprint contains.
    long
    Gets an order-independent content hash (FNV-1a) of all construction elements this blueprint contains.
    long
    Gets the date when the blueprint was originally created, as unix timestamp (seconds since epoch).
    Gets the name of the player who originally created the blueprint.
    Gets the UID of the player who originally created the blueprint.
    float
    Gets the max radius of the affected area.
    int
    Gets the amount of objects (i.e furniture, doors, lamps etc) this blueprint contains.
    long
    Gets an order-independent content hash (FNV-1a) of all objects (i.e furniture, doors, lamps etc) this blueprint contains.
    int
     
    int
    Gets the amount of plants (vegetation) this blueprint contains.
    long
    Gets an order-independent content hash (FNV-1a) of all plants (vegetation) this blueprint contains.
    Gets the world position of the blueprint center (i.e where the blueprint will be placed).
    Gets the world rotation of the blueprint.
    Gets the scale factor of the blueprint.
    int
    Gets the amount of terrain blocks this blueprint contains.
    long
    Gets a content hash of the terrain data this blueprint contains.
    boolean
    /////////////////////////////////////////////////////////////////////////
    void
    setCancelled(boolean cancel)
    Cancels this event.
    void
    setPosition(float x, float y, float z)
    Changes the world position for the blueprint (i.e the position where the blueprint will be placed).
    void
    Changes the world position for the blueprint (i.e the position where the blueprint will be placed).
    void
    Changes the rotation of the blueprint.
    void
    Changes the scale factor of the blueprint.

    Methods inherited from class PlayerEvent

    getPlayer

    Methods inherited from class Event

    equals, hashCode, isValid

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • getBlueprintID

      public long getBlueprintID()
      Gets the ID of the blueprint.
      Returns:
      the blueprint ID.
    • getPlaceID

      public int getPlaceID()
    • getPosition

      public Vector3f getPosition()
      Gets the world position of the blueprint center (i.e where the blueprint will be placed). This is the same as calling getBounds().getCenter()
      Returns:
      the blueprint world position.
    • setPosition

      public void setPosition(Vector3f position)
      Changes the world position for the blueprint (i.e the position where the blueprint will be placed).
      Parameters:
      position - the new target world position.
    • setPosition

      public void setPosition(float x, float y, float z)
      Changes the world position for the blueprint (i.e the position where the blueprint will be placed).
      Parameters:
      x - the new target world x position.
      y - the new target world y position.
      z - the new target world z position.
    • getRotation

      public Quaternion getRotation()
      Gets the world rotation of the blueprint.
      Returns:
      the blueprint rotation.
    • setRotation

      public void setRotation(Quaternion rotation)
      Changes the rotation of the blueprint.
      Parameters:
      rotation - the new rotation.
    • getScale

      public Vector3f getScale()
      Gets the scale factor of the blueprint. By default it's 1 1 1
      Returns:
      the blueprint scale factor.
    • setScale

      public void setScale(Vector3f scale)
      Changes the scale factor of the blueprint.
      Parameters:
      scale - the new scale factor for the blueprint.
    • getBounds

      public Bounds getBounds()
      Gets the bounds of the blueprint object.
      Returns:
      the bounds.
      Example: Get the min position and max position of the blueprint
      1@EventMethod
      2public void onPlayerPlaceBlueprint(PlayerPlaceBlueprintEvent event){
      3 Bounds bounds = event.getBounds();
      4
      5 //Our vector to store the min world position of the bounds
      6 Vector3f minPosition = new Vector3f();
      7
      8 //Our vector to store the max world position of the bounds
      9 Vector3f maxPosition = new Vector3f();
      10
      11 //getCenter() gets the center of the bounds. By subtracting the half
      12 //extents (half sizes), we get the min world position of the bounds
      13 minPosition.set(bounds.getCenter());
      14 minPosition.subtractLocal(bounds.getXExtent(), bounds.getYExtent(), bounds.getZExtent());
      15
      16 //...by adding the half extents, we get the max world position instead
      17 maxPosition.set(bounds.getCenter());
      18 maxPosition.addLocal(bounds.getXExtent(), bounds.getYExtent(), bounds.getZExtent());
      19}
    • getMaxExtent

      public float getMaxExtent()
      Gets the max radius of the affected area. This function simply compares the half extents of the bounds and returns the greatest result.
      Returns:
      the max radius of the affected area.
    • getConstructionCount

      public int getConstructionCount()
      Gets the amount of construction elements (blocks) this blueprint contains.
      Returns:
      the amount of construction elements.
    • getObjectCount

      public int getObjectCount()
      Gets the amount of objects (i.e furniture, doors, lamps etc) this blueprint contains.
      Returns:
      the amount of objects.
    • getPlantCount

      public int getPlantCount()
      Gets the amount of plants (vegetation) this blueprint contains.
      Returns:
      the amount of plants.
    • getTerrainCount

      public int getTerrainCount()
      Gets the amount of terrain blocks this blueprint contains.
      Returns:
      the amount of terrain blocks.
    • getCreatorName

      public String getCreatorName()
      Gets the name of the player who originally created the blueprint. This information is taken from the blueprint file metadata, so please keep in mind that the name is unreliable: it might be a player from a different server.
      Returns:
      the name of the original blueprint creator, or null if unknown.
    • getCreatorUID

      public String getCreatorUID()
      Gets the UID of the player who originally created the blueprint. See getCreatorName() for details about the origin (and trustworthiness) of this information.
      Returns:
      the UID of the original blueprint creator, or null if unknown.
    • getCreationDate

      public long getCreationDate()
      Gets the date when the blueprint was originally created, as unix timestamp (seconds since epoch). This information is taken from the blueprint file metadata (which is provided by the client when crafting the blueprint item), so it cannot be fully trusted.
      Returns:
      the original creation date (unix timestamp, seconds), or 0 if unknown.
    • getConstructionsHash

      public long getConstructionsHash()
      Gets an order-independent content hash (FNV-1a) of all construction elements this blueprint contains. Two blueprints containing the same construction elements (same types, textures, colors and relative positions) produce the same hash, regardless of where or when they were created - so this hash can be used to compare blueprints for identical content.
      Returns:
      the content hash of all construction elements, or 0 if the blueprint contains no construction elements (or the hash is unknown, e.g for blueprints crafted with an older game version).
    • getObjectsHash

      public long getObjectsHash()
      Gets an order-independent content hash (FNV-1a) of all objects (i.e furniture, doors, lamps etc) this blueprint contains. See getConstructionsHash() for details about this hash.
      Returns:
      the content hash of all objects, or 0 if the blueprint contains no objects (or the hash is unknown).
    • getPlantsHash

      public long getPlantsHash()
      Gets an order-independent content hash (FNV-1a) of all plants (vegetation) this blueprint contains. See getConstructionsHash() for details about this hash.
      Returns:
      the content hash of all plants, or 0 if the blueprint contains no plants (or the hash is unknown).
    • getTerrainHash

      public long getTerrainHash()
      Gets a content hash of the terrain data this blueprint contains. Unlike the element hashes, this hash is order-dependent, because the terrain is stored as a positional grid (the grid dimensions are taken into account as well). See getConstructionsHash() for general details about content hashes.
      Returns:
      the content hash of the terrain data, or 0 if the blueprint contains no terrain (or the hash is unknown, e.g for blueprints crafted with an older game version).
    • isCancelled

      public boolean isCancelled()
      /////////////////////////////////////////////////////////////////////////
      Specified by:
      isCancelled in interface Cancellable
      Returns:
      true if the event is cancelled, or false if not.
    • setCancelled

      public void setCancelled(boolean cancel)
      Description copied from interface: Cancellable
      Cancels this event. This means it will no longer be executed, but other plugins will still receive the event.

      Specified by:
      setCancelled in interface Cancellable
      Parameters:
      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}