package net.minecraftforge.event.world;
import java.util.List;
import cpw.mods.fml.common.eventhandler.Cancelable;
import cpw.mods.fml.common.eventhandler.Event;
import net.minecraft.entity.Entity;
import net.minecraft.world.ChunkPosition;
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
/** ExplosionEvent triggers when an explosion happens in the world.<br>
* <br>
* ExplosionEvent.Start is fired before the explosion actually occurs.<br>
* ExplosionEvent.Detonate is fired once the explosion has a list of affected blocks and entities.<br>
* <br>
* ExplosionEvent.Start is {@link Cancelable}.<br>
* ExplosionEvent.Detonate can modify the affected blocks and entities.<br>
* Children do not use {@link HasResult}.<br>
* Children of this event are fired on the {@link MinecraftForge#EVENT_BUS}.<br>
*/
public class ExplosionEvent extends Event
{
public final World world;
public final Explosion explosion;
public ExplosionEvent(World world, Explosion explosion)
{
this.world = world;
this.explosion = explosion;
}
/** ExplosionEvent.Start is fired before the explosion actually occurs. Canceling this event will stop the explosion.<br>
* <br>
* This event is {@link Cancelable}.<br>
* This event does not use {@link HasResult}.<br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
*/
@Cancelable
public static class Start extends ExplosionEvent
{
public Start(World world, Explosion explosion)
{
super(world, explosion);
}
}
/** ExplosionEvent.Detonate is fired once the explosion has a list of affected blocks and entities. These lists can be modified to change the outcome.<br>
* <br>
* This event is not {@link Cancelable}.<br>
* This event does not use {@link HasResult}.<br>
* This event is fired on the {@link MinecraftForge#EVENT_BUS}.<br>
*/
public static class Detonate extends ExplosionEvent
{
private final List<Entity> entityList;
public Detonate(World world, Explosion explosion, List<Entity> entityList)
{
super(world, explosion);
this.entityList = entityList;
}
/** return the list of blocks affected by the explosion. */
public List<ChunkPosition> getAffectedBlocks()
{
return explosion.affectedBlockPositions;
}
/** return the list of entities affected by the explosion. */
public List<Entity> getAffectedEntities()
{
return entityList;
}
}
}