2013-07-22 07:05:40 +02:00
|
|
|
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.
|
2013-07-22 07:05:40 +02:00
|
|
|
*
|
|
|
|
* @author Calclavia
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
@Cancelable
|
2013-07-23 00:24:55 +02:00
|
|
|
public class ExplosionEvent extends Event
|
|
|
|
{
|
2013-07-22 07:05:40 +02:00
|
|
|
/**
|
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.
|
2013-07-22 07:05:40 +02:00
|
|
|
*/
|
|
|
|
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)
|
|
|
|
{
|
2013-07-22 07:05:40 +02:00
|
|
|
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.
|
2013-07-22 07:05:40 +02:00
|
|
|
*
|
|
|
|
* @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 */
|
2013-07-22 07:05:40 +02:00
|
|
|
public World world;
|
2013-10-09 23:55:28 +02:00
|
|
|
/** The entity causing the explosion. This could be null */
|
2013-07-22 07:05:40 +02:00
|
|
|
public Entity entity;
|
2013-10-09 23:55:28 +02:00
|
|
|
/** The position in which the explosion might happen. */
|
2013-07-22 07:05:40 +02:00
|
|
|
public double x, y, z;
|
2013-10-09 23:55:28 +02:00
|
|
|
/** The explosive object. */
|
2013-07-22 07:05:40 +02:00
|
|
|
public IExplosive explosion;
|
2013-10-09 23:55:28 +02:00
|
|
|
/** The explosive type. */
|
2013-07-22 07:05:40 +02:00
|
|
|
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)
|
|
|
|
{
|
2013-07-22 07:05:40 +02:00
|
|
|
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-22 07:05:40 +02:00
|
|
|
}
|
|
|
|
|
2013-07-23 00:24:55 +02:00
|
|
|
public ExplosivePreDetonationEvent(World world, Entity entity, ExplosiveType type, IExplosive explosion)
|
|
|
|
{
|
2013-07-22 07:05:40 +02:00
|
|
|
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;
|
2013-07-22 07:05:40 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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)
|
|
|
|
{
|
2013-07-22 07:05:40 +02:00
|
|
|
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)
|
|
|
|
{
|
2013-07-22 07:05:40 +02:00
|
|
|
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)
|
2013-07-22 07:05:40 +02:00
|
|
|
*
|
|
|
|
* @author Calclavia
|
|
|
|
*
|
|
|
|
*/
|
2013-07-23 00:24:55 +02:00
|
|
|
public static class DoExplosionEvent extends ExplosionEvent
|
|
|
|
{
|
|
|
|
public DoExplosionEvent(World world, IExplosion explosion)
|
|
|
|
{
|
2013-07-22 07:05:40 +02:00
|
|
|
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)
|
|
|
|
{
|
2013-07-22 07:05:40 +02:00
|
|
|
super(world, explosion);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|