Class CubeExplosion
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
This explosion defines a rectangular prism shaped explosion, where a valid (non-negative) width
and height are specified.
-
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor for serializer.CubeExplosion(double width, double height) Constructs aCuboidExplosionobject. -
Method Summary
Modifier and TypeMethodDescriptiondoublegetArea()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 anyLivingEntitys inside thisCuboidExplosionby getting the entity's (x, y, z) coordinates, and checking if that point is in between the 2 points.org.bukkit.NamespacedKeygetKey()doubleReturns the maximum distance from the origin of the explosion that an entity is considered to be contained in the explosion.booleanisContained(org.bukkit.Location origin, 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) serialize(me.deecaad.core.file.SerializeData data) toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.bukkit.Keyed
keyMethods 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 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
-
getKey
@NotNull public org.bukkit.NamespacedKey getKey()- Specified by:
getKeyin interfaceorg.bukkit.Keyed
-
getBlocks
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 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. 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 org.bukkit.Location origin, @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) -
serialize
@NotNull public ExplosionShape serialize(@NotNull me.deecaad.core.file.SerializeData data) throws me.deecaad.core.file.SerializerException - Specified by:
serializein interfaceme.deecaad.core.file.Serializer<ExplosionShape>- Throws:
me.deecaad.core.file.SerializerException
-
toString
-