Class PlayerPlaceConstructionEvent

All Implemented Interfaces:
Cancellable

public final class PlayerPlaceConstructionEvent extends PlayerConstructionEvent
Called when a player places a construction element.
  • Method Details

    • getConstructionElement

      protected ConstructionElement getConstructionElement()
      Note: This function returns null because the construction element had not yet been created at the time of the event!
      To access information (like position, rotation etc), please check out the other functions of this event
      Overrides:
      getConstructionElement in class PlayerConstructionEvent
      Returns:
      always null
    • getGlobalIDs

      public long[] getGlobalIDs()
      If the player places multiple construction elements in a row, this method gets the unique, global IDs of all construction elements which are about to be placed. If only a single element is placed, use PlayerConstructionEvent.getGlobalID() instead. To find out if the player only places a single element, check if getTotalCount() returns 1
      Returns:
      a new array containing all global IDs of the construction elements. If just a single element was placed, the array just contains the global ID of that element.
      Example:
      1@EventMethod
      2public void onPlayerPlaceConstruction(PlayerPlaceConstructionEvent evt) {
      3 //If count is greater than 1, player placed multiple blocks in a row
      4 if (evt.getTotalCount() > 1) {
      5 long[] array = evt.getGlobalIDs(pointer);
      6 System.out.println("Player placed multiple blocks. IDs: " + Arrays.toString(array));
      7 }
      8 //Otherwise player just placed a single block
      9 else {
      10 System.out.println("Player placed single block. ID: " + evt.getGlobalID());
      11 }
      12}
    • setTypeID

      public void setTypeID(byte id)
      Sets the type ID of the construction element.
      Parameters:
      id - the new type ID.
    • setTextureID

      public void setTextureID(int texture)
      Sets the texture of the construction element.
      Parameters:
      texture - the new texture ID. If this is a "poster" construction element, the texture ID is the custom image ID.
    • setPosition

      public void setPosition(Vector3f position)
      Changes the world position of the construction element.
      Parameters:
      position - the new world position of the construction element.
    • setPosition

      public void setPosition(float x, float y, float z)
      Changes the world position of the construction element.
      Parameters:
      x - the new world x position of the construction element.
      y - the new world y position of the construction element.
      z - the new world z position of the construction element.
    • setRotation

      public void setRotation(Quaternion rotation)
      Changes the rotation of the construction element.
      Parameters:
      rotation - the new construction element rotation. Set to null to reset the rotation (Quaternion.IDENTITY).
    • setRotation

      public void setRotation(float pitch, float yaw, float roll)
      Changes the rotation of the construction element.
      Parameters:
      pitch - the new x angle, as euler rotation (pitch).
      yaw - the new y angle, as euler rotation (yaw).
      roll - the new z angle, as euler rotation (roll).
    • setSize

      public void setSize(Vector3f size)
      Changes the size of the construction element.
      Parameters:
      size - the new size (x, y, z, as a Vector3f) of the construction element.
    • setSize

      public void setSize(float x, float y, float z)
      Changes the size of the construction element.
      Parameters:
      x - the new size of the construction element along the x axis.
      y - the new size of the construction element along the y axis.
      z - the new size of the construction element along the z axis.
    • setColor

      public void setColor(int color)
    • getMultiPlaceRowX

      public int getMultiPlaceRowX()
      Gets the amount of additional elements the player wants to place in a row (multi-placement) along the x axis. By default this is 0 (which means that no additional elements are about to placed along x). The value is negative if the direction is along -x
      Returns:
      amount of extra elements the player wants to place along x. A positive value means that this amount of elements is placed additionally along +x, a negative value means that this amount of elements (abs) if placed additionally along -x
    • getMultiPlaceRowY

      public int getMultiPlaceRowY()
      Gets the amount of additional elements the player wants to place in a row (multi-placement) along the y axis. By default this is 0 (which means that no additional elements are about to placed along y). The value is negative if the direction is along -y
      Returns:
      amount of extra elements the player wants to place along y. A positive value means that this amount of elements is placed additionally along +y, a negative value means that this amount of elements (abs) if placed additionally along -y
    • getMultiPlaceRowZ

      public int getMultiPlaceRowZ()
      Gets the amount of additional elements the player wants to place in a row (multi-placement) along the z axis. By default this is 0 (which means that no additional elements are about to placed along z). The value is negative if the direction is along -z
      Returns:
      amount of extra elements the player wants to place along z. A positive value means that this amount of elements is placed additionally along +z, a negative value means that this amount of elements (abs) if placed additionally along -z
    • getMultiPlaceGap

      public float getMultiPlaceGap()
      If multiple elements are about to be placed in a row (multi-placement), this determines the gap between the elements.
      Returns:
      the gap between elements when placing multiple elements in a row.
    • setMultiPlaceGap

      public void setMultiPlaceGap(float gap)
      Sets the gap between elements if multiple elements are about to be placed in a row (multi-placement).
      Parameters:
      gap - the gap between multiple elements.
    • getTotalCount

      public int getTotalCount()
      Gets the total amount of elements the player is about to place.
      Returns:
      the number of elements the player wants to place. Returns 1 if the player wants to place a single element only, or a higher value when placing multiple elements in a row.
    • getAllPositions

      public Vector3f[] getAllPositions()