java.lang.Object
me.deecaad.weaponmechanics.weapon.explode.shapes.CubeExplosion
All Implemented Interfaces:
me.deecaad.core.file.Serializer<ExplosionShape>, ExplosionShape, net.kyori.adventure.key.Keyed, org.bukkit.Keyed

public class CubeExplosion extends Object implements ExplosionShape
This explosion defines a rectangular prism shaped explosion, where a valid (non-negative) width and height are specified.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default constructor for serializer.
    CubeExplosion(double width, double height)
    Constructs a CuboidExplosion object.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Returns the area, measured in meters cubed (blocks cubed), of this shape.
    List<org.bukkit.block.Block>
    getBlocks(org.bukkit.Location origin)
    Gets all blocks between 2 points, where the 2 points are found using this width, and height as well as the method's origin parameter.
    List<org.bukkit.entity.LivingEntity>
    getEntities(org.bukkit.Location origin)
    Gets any LivingEntitys inside this CuboidExplosion by getting the entity's (x, y, z) coordinates, and checking if that point is in between the 2 points.
    org.bukkit.NamespacedKey
     
    double
    Returns the maximum distance from the origin of the explosion that an entity is considered to be contained in the explosion.
    boolean
    isContained(org.bukkit.Location origin, org.bukkit.Location point)
    Returns true if the given point is contained in this shape, assuming the shape's center is located at origin.
    boolean
    isNearEdge(double x, double y, double z, double distance)
     
    serialize(me.deecaad.core.file.SerializeData data)
     
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.bukkit.Keyed

    key

    Methods inherited from interface me.deecaad.core.file.Serializer

    canUsePathTo, getKeyword, getName, getParentKeywords, getWikiLink, letPassThrough, shouldSerialize, tryPathTo, useLater
  • Constructor Details

    • CubeExplosion

      public CubeExplosion()
      Default constructor for serializer.
    • CubeExplosion

      public CubeExplosion(double width, double height)
      Constructs a CuboidExplosion object. The width and height are divided by 2 to get the "radius" of the rectangle.

      This is used when finding points about the origin, the width input is the total width of the explosion. The width instance variable is the distance from one point to the origin.

      Parameters:
      width - Total width of the explosion
      height - Total height of the explosion
  • Method Details

    • getKey

      @NotNull public org.bukkit.NamespacedKey getKey()
      Specified by:
      getKey in interface org.bukkit.Keyed
    • getBlocks

      @NotNull public List<org.bukkit.block.Block> getBlocks(@NotNull org.bukkit.Location origin)
      Gets all blocks between 2 points, where the 2 points are found using this width, and height as well as the method's origin parameter.
      Specified by:
      getBlocks in interface ExplosionShape
      Parameters:
      origin - The center of the explosion Should not be null
      Returns:
      The blocks within the explosion
    • getEntities

      @NotNull public List<org.bukkit.entity.LivingEntity> getEntities(@NotNull org.bukkit.Location origin)
      Gets any LivingEntitys inside this CuboidExplosion by getting the entity's (x, y, z) coordinates, and checking if that point is in between the 2 points. This is done via
      
           point1.x <= entity.x <= point2.x
           point1.y <= entity.y <= point2.y
           point1.z <= entity.z <= point2.z
       
      Specified by:
      getEntities in interface ExplosionShape
      Parameters:
      origin - The center of the explosion Should not be null
      Returns:
      All entities within the explosion
    • getMaxDistance

      public double getMaxDistance()
      Description copied from interface: ExplosionShape
      Returns the maximum distance from the origin of the explosion that an entity is considered to be contained in the explosion. This method should NOT be used to determine whether a point is in an explosion (use ExplosionShape.isContained(Location, Location)). This method is useful for helping to determine an entity's exposure. See DistanceExposure.
      Specified by:
      getMaxDistance in interface ExplosionShape
      Returns:
      The maximum distance away an entity takes damage.
    • getArea

      public double getArea()
      Description copied from interface: ExplosionShape
      Returns the area, measured in meters cubed (blocks cubed), of this shape. Note that the returned value will be inaccurate to an unknown degree, since some shapes (like DefaultExplosion) are based on randomness and ray-tracing.
      Specified by:
      getArea in interface ExplosionShape
      Returns:
      The maximum area effected by this shape.
    • isContained

      public boolean isContained(@NotNull org.bukkit.Location origin, @NotNull org.bukkit.Location point)
      Description copied from interface: ExplosionShape
      Returns true if the given point is contained in this shape, assuming the shape's center is located at origin.
      Specified by:
      isContained in interface ExplosionShape
      Parameters:
      origin - The non-null origin of the explosion.
      point - The non-null point to test.
      Returns:
      True if the point is in this shape.
    • isNearEdge

      public boolean isNearEdge(double x, double y, double z, double distance)
    • serialize

      @NotNull public ExplosionShape serialize(@NotNull me.deecaad.core.file.SerializeData data) throws me.deecaad.core.file.SerializerException
      Specified by:
      serialize in interface me.deecaad.core.file.Serializer<ExplosionShape>
      Throws:
      me.deecaad.core.file.SerializerException
    • toString

      public String toString()
      Overrides:
      toString in class Object