131 lines
2.9 KiB
Java
131 lines
2.9 KiB
Java
package icbm.api.explosion;
|
|
|
|
import net.minecraft.entity.Entity;
|
|
import net.minecraft.world.Explosion;
|
|
import net.minecraft.world.World;
|
|
import net.minecraftforge.event.Cancelable;
|
|
import net.minecraftforge.event.Event;
|
|
|
|
/**
|
|
* Use ForgeSubscribe to subscribe to this event. This event is called every single time when an
|
|
* ICBM explosion happens.
|
|
*
|
|
* @author Calclavia
|
|
*
|
|
*/
|
|
@Cancelable
|
|
public class ExplosionEvent extends Event
|
|
{
|
|
/**
|
|
* The explosion object. Can be cast into {@link Explosion}. This event can be canceled to
|
|
* prevent a specific part of an explosion from being executed.
|
|
*/
|
|
public World world;
|
|
public double x, y, z;
|
|
public IExplosion iExplosion;
|
|
|
|
/**
|
|
* Pre-cast explosion class.
|
|
*/
|
|
public Explosion explosion;
|
|
|
|
public ExplosionEvent(World world, IExplosion iExplosion)
|
|
{
|
|
this.world = world;
|
|
this.iExplosion = iExplosion;
|
|
this.x = ((Explosion) iExplosion).explosionX;
|
|
this.y = ((Explosion) iExplosion).explosionY;
|
|
this.z = ((Explosion) iExplosion).explosionZ;
|
|
}
|
|
|
|
/**
|
|
* Called before an explosive is detonated to check if detonation is possible. You may cancel
|
|
* and explosion here if needed. After this it will be a bit too late to prevent destruction
|
|
* without any losses.
|
|
*
|
|
* @author Calclavia
|
|
*
|
|
*/
|
|
@Cancelable
|
|
public static class ExplosivePreDetonationEvent extends Event
|
|
{
|
|
public World world;
|
|
public Entity entity;
|
|
public double x, y, z;
|
|
|
|
public IExplosive explosion;
|
|
public ExplosiveType type;
|
|
|
|
public ExplosivePreDetonationEvent(World world, double x, double y, double z, ExplosiveType type, IExplosive explosion)
|
|
{
|
|
this.world = world;
|
|
this.type = type;
|
|
this.explosion = explosion;
|
|
}
|
|
|
|
public ExplosivePreDetonationEvent(World world, Entity entity, ExplosiveType type, IExplosive explosion)
|
|
{
|
|
this.world = world;
|
|
this.entity = entity;
|
|
this.type = type;
|
|
this.explosion = explosion;
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Called when an explosion is constructed.
|
|
*
|
|
* @author Calclavia
|
|
*
|
|
*/
|
|
public static class ExplosionConstructionEvent extends ExplosionEvent
|
|
{
|
|
public ExplosionConstructionEvent(World world, IExplosion explosion)
|
|
{
|
|
super(world, explosion);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Called before an explosion happens.
|
|
*
|
|
* @author Calclavia
|
|
*
|
|
*/
|
|
public static class PreExplosionEvent extends ExplosionEvent
|
|
{
|
|
public PreExplosionEvent(World world, IExplosion explosion)
|
|
{
|
|
super(world, explosion);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Called while an explosion happens. May be called every single tick if explosion is
|
|
* procedural. (E.g: Red matter explosive)
|
|
*
|
|
* @author Calclavia
|
|
*
|
|
*/
|
|
public static class DoExplosionEvent extends ExplosionEvent
|
|
{
|
|
public DoExplosionEvent(World world, IExplosion explosion)
|
|
{
|
|
super(world, explosion);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Called after an explosion happens.
|
|
*
|
|
* @author Calclavia
|
|
*
|
|
*/
|
|
public static class PostExplosionEvent extends ExplosionEvent
|
|
{
|
|
public PostExplosionEvent(World world, IExplosion explosion)
|
|
{
|
|
super(world, explosion);
|
|
}
|
|
}
|
|
}
|