Package net.minestom.server.instance
Class Explosion
java.lang.Object
net.minestom.server.instance.Explosion
public abstract class Explosion
extends java.lang.Object
Abstract explosion.
Instance can provide a supplier through
Instance.setExplosionSupplier(net.minestom.server.instance.ExplosionSupplier)
-
Constructor Summary
Constructors Constructor Description Explosion(float centerX, float centerY, float centerZ, float strength)
-
Method Summary
Modifier and Type Method Description void
apply(Instance instance)
Performs the explosion and send the corresponding packetfloat
getCenterX()
float
getCenterY()
float
getCenterZ()
float
getStrength()
protected void
postExplosion(Instance instance, java.util.List<BlockPosition> blocks, ExplosionPacket packet)
Called after removing blocks and preparing the packet, but before sending it.protected void
postSend(Instance instance, java.util.List<BlockPosition> blocks)
Called after sending the explosion packet.protected abstract java.util.List<BlockPosition>
prepare(Instance instance)
Prepares the list of blocks that will be broken.
-
Constructor Details
-
Explosion
public Explosion(float centerX, float centerY, float centerZ, float strength)
-
-
Method Details
-
getStrength
public float getStrength() -
getCenterX
public float getCenterX() -
getCenterY
public float getCenterY() -
getCenterZ
public float getCenterZ() -
prepare
Prepares the list of blocks that will be broken. Also pushes and damage entities affected by this explosion- Parameters:
instance
- instance to perform this explosion in- Returns:
- list of blocks that will be broken.
-
apply
Performs the explosion and send the corresponding packet- Parameters:
instance
- instance to perform this explosion in
-
postExplosion
protected void postExplosion(Instance instance, java.util.List<BlockPosition> blocks, ExplosionPacket packet)Called after removing blocks and preparing the packet, but before sending it.- Parameters:
instance
- the instance in which the explosion occursblocks
- the block positions returned by preparepacket
- the explosion packet to sent to the client. Be careful with what you're doing. It is initialized with the center and radius of the explosion. The positions in 'blocks' are also stored in the packet before this call, but you are free to modify 'records' to modify the blocks sent to the client. Just be careful, you might just crash the server or the client. Or you're lucky, both at the same time.
-
postSend
Called after sending the explosion packet. Can be used to (re)set blocks that have been destroyed. This is necessary to do after the packet being sent, because the client sets the positions received to air.- Parameters:
instance
- the instance in which the explosion occursblocks
- the block positions returned by prepare
-