Class PlayerCreateBlueprintEvent

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

public final class PlayerCreateBlueprintEvent extends PlayerEvent implements Cancellable
Called when a player wants to create a new blueprint (i.e when he has already selected an area and wants to finally create the blueprint).
  • Method Details

    • getBounds

      public Bounds getBounds()
      Gets the bounds of the blueprint object, or more precisely, of the selected area.
      Returns:
      the bounds.
      Example: Get the min position and max position of the affected area of this 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}
    • getPosition

      public Vector3f getPosition()
      Gets the target world position of the blueprint, or more precisely, the center position of the affected area. This is the same as calling getBounds().getCenter()
      Returns:
      the target world position.
    • 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.
    • isCancelled

      public boolean isCancelled()
      Description copied from interface: 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.
      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}