Class Explosion

java.lang.Object
net.minestom.server.instance.Explosion

public abstract class Explosion extends Object
Abstract explosion. Instance can provide a supplier through Instance.setExplosionSupplier(net.minestom.server.instance.ExplosionSupplier)
  • 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

      protected abstract List<Point> prepare(Instance instance)
      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

      public void apply(@NotNull @NotNull Instance instance)
      Performs the explosion and send the corresponding packet
      Parameters:
      instance - instance to perform this explosion in
    • postExplosion

      protected void postExplosion(Instance instance, List<Point> blocks, ExplosionPacket packet)
      Called after removing blocks and preparing the packet, but before sending it.
      Parameters:
      instance - the instance in which the explosion occurs
      blocks - the block positions returned by prepare
      packet - 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

      protected void postSend(Instance instance, List<Point> blocks)
      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 occurs
      blocks - the block positions returned by prepare