Class CuboidExplosion
java.lang.Object
me.deecaad.weaponmechanics.weapon.explode.shapes.CuboidExplosion
- All Implemented Interfaces:
ExplosionShape
This explosion defines a rectangular prism shaped
explosion, where a valid (non-negative) width and
height are specified.
-
Constructor Summary
ConstructorsConstructorDescriptionCuboidExplosion(double width, double height) Constructs aCuboidExplosionobject. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetArea()Returns the area, measured in meters cubed (blocks cubed), of this shape.@NotNull 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.@NotNull List<org.bukkit.entity.LivingEntity>getEntities(@NotNull org.bukkit.Location origin) Gets anyLivingEntitys inside thisCuboidExplosionby getting the entity's (x, y, z) coordinates, and checking if that point is in between the 2 points.doubleReturns the maximum distance from the origin of the explosion that an entity is considered to be contained in the explosion.booleanisContained(@NotNull org.bukkit.Location origin, @NotNull org.bukkit.Location point) Returnstrueif the given point is contained in this shape, assuming the shape's center is located atorigin.booleanisNearEdge(double x, double y, double z, double distance) toString()
-
Constructor Details
-
CuboidExplosion
public CuboidExplosion(double width, double height) Constructs aCuboidExplosionobject. 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 explosionheight- Total height of the explosion
-
-
Method Details
-
getBlocks
@NotNull public @NotNull List<org.bukkit.block.Block> getBlocks(@NotNull @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:
getBlocksin interfaceExplosionShape- Parameters:
origin- The center of the explosion Should not be null- Returns:
- The blocks within the explosion
-
getEntities
@NotNull public @NotNull List<org.bukkit.entity.LivingEntity> getEntities(@NotNull @NotNull org.bukkit.Location origin) Gets anyLivingEntitys inside thisCuboidExplosionby getting the entity's (x, y, z) coordinates, and checking if that point is in between the 2 points. This is done viapoint1.x <= entity.x <= point2.x point1.y <= entity.y <= point2.y point1.z <= entity.z <= point2.z- Specified by:
getEntitiesin interfaceExplosionShape- 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:ExplosionShapeReturns 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 (useExplosionShape.isContained(Location, Location)). This method is useful for helping to determine an entity's exposure. SeeDistanceExposure.- Specified by:
getMaxDistancein interfaceExplosionShape- Returns:
- The maximum distance away an entity takes damage.
-
getArea
public double getArea()Description copied from interface:ExplosionShapeReturns 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 (likeDefaultExplosion) are based on randomness and ray-tracing.- Specified by:
getAreain interfaceExplosionShape- Returns:
- The maximum area effected by this shape.
-
isContained
public boolean isContained(@NotNull @NotNull org.bukkit.Location origin, @NotNull @NotNull org.bukkit.Location point) Description copied from interface:ExplosionShapeReturnstrueif the given point is contained in this shape, assuming the shape's center is located atorigin.- Specified by:
isContainedin interfaceExplosionShape- 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) -
toString
-