electrodynamics/APIs/icbm/api/explosion/ExplosionEvent.java

142 lines
3.3 KiB
Java
Raw Normal View History

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;
/**
2013-07-23 00:24:55 +02:00
* Use ForgeSubscribe to subscribe to this event. This event is called every single time when an
* ICBM explosion happens.
*
* @author Calclavia
*
*/
@Cancelable
2013-07-23 00:24:55 +02:00
public class ExplosionEvent extends Event
{
/**
2013-07-23 00:24:55 +02:00
* 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;
2013-07-23 00:24:55 +02:00
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;
}
/**
2013-10-09 23:55:28 +02:00
* Called before an explosive is detonated or a missile is placed 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
2013-07-23 00:24:55 +02:00
public static class ExplosivePreDetonationEvent extends Event
{
2013-10-09 23:55:28 +02:00
/** The world object */
public World world;
2013-10-09 23:55:28 +02:00
/** The entity causing the explosion. This could be null */
public Entity entity;
2013-10-09 23:55:28 +02:00
/** The position in which the explosion might happen. */
public double x, y, z;
2013-10-09 23:55:28 +02:00
/** The explosive object. */
public IExplosive explosion;
2013-10-09 23:55:28 +02:00
/** The explosive type. */
public ExplosiveType type;
2013-07-23 00:24:55 +02:00
public ExplosivePreDetonationEvent(World world, double x, double y, double z, ExplosiveType type, IExplosive explosion)
{
this.world = world;
this.type = type;
this.explosion = explosion;
2013-10-09 23:55:28 +02:00
this.x = x;
this.y = y;
this.z = z;
}
2013-07-23 00:24:55 +02:00
public ExplosivePreDetonationEvent(World world, Entity entity, ExplosiveType type, IExplosive explosion)
{
this.world = world;
this.entity = entity;
this.type = type;
this.explosion = explosion;
2013-10-09 23:55:28 +02:00
this.x = entity.posX;
this.y = entity.posY;
this.z = entity.posZ;
}
}
/**
* Called when an explosion is constructed.
*
* @author Calclavia
*
*/
2013-07-23 00:24:55 +02:00
public static class ExplosionConstructionEvent extends ExplosionEvent
{
public ExplosionConstructionEvent(World world, IExplosion explosion)
{
super(world, explosion);
}
}
/**
* Called before an explosion happens.
*
* @author Calclavia
*
*/
2013-07-23 00:24:55 +02:00
public static class PreExplosionEvent extends ExplosionEvent
{
public PreExplosionEvent(World world, IExplosion explosion)
{
super(world, explosion);
}
}
/**
2013-07-23 00:24:55 +02:00
* Called while an explosion happens. May be called every single tick if explosion is
* procedural. (E.g: Red matter explosive)
*
* @author Calclavia
*
*/
2013-07-23 00:24:55 +02:00
public static class DoExplosionEvent extends ExplosionEvent
{
public DoExplosionEvent(World world, IExplosion explosion)
{
super(world, explosion);
}
}
/**
* Called after an explosion happens.
*
* @author Calclavia
*
*/
2013-07-23 00:24:55 +02:00
public static class PostExplosionEvent extends ExplosionEvent
{
public PostExplosionEvent(World world, IExplosion explosion)
{
super(world, explosion);
}
}
}