2016-01-01 17:08:17 +00:00
|
|
|
package WayofTime.bloodmagic.api.event;
|
|
|
|
|
2017-08-16 01:14:28 +00:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2016-05-12 03:29:16 +00:00
|
|
|
import net.minecraft.entity.Entity;
|
2016-01-01 17:08:17 +00:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-03-17 20:00:44 +00:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-01-01 17:08:17 +00:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
|
|
|
|
2016-01-02 22:56:37 +00:00
|
|
|
/**
|
|
|
|
* Fired when a teleposer attempts to transpose two blocks. Use this to perform
|
|
|
|
* special cleanup or compensation, or cancel it entirely to prevent the
|
|
|
|
* transposition.
|
|
|
|
*/
|
2016-01-01 17:08:17 +00:00
|
|
|
@Cancelable
|
|
|
|
public class TeleposeEvent extends Event
|
|
|
|
{
|
|
|
|
public final World initalWorld;
|
|
|
|
public final BlockPos initialBlockPos;
|
2017-08-16 01:14:28 +00:00
|
|
|
public final IBlockState initialState;
|
2016-01-01 17:08:17 +00:00
|
|
|
|
|
|
|
public final World finalWorld;
|
|
|
|
public final BlockPos finalBlockPos;
|
2017-08-16 01:14:28 +00:00
|
|
|
public final IBlockState finalState;
|
2016-01-01 17:08:17 +00:00
|
|
|
|
2016-01-05 23:26:24 +00:00
|
|
|
public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
2016-01-01 17:08:17 +00:00
|
|
|
{
|
|
|
|
this.initalWorld = initialWorld;
|
|
|
|
this.initialBlockPos = initialBlockPos;
|
2017-08-16 01:14:28 +00:00
|
|
|
this.initialState = initialWorld.getBlockState(initialBlockPos);
|
2016-01-01 17:08:17 +00:00
|
|
|
|
|
|
|
this.finalWorld = finalWorld;
|
|
|
|
this.finalBlockPos = finalBlockPos;
|
2017-08-16 01:14:28 +00:00
|
|
|
this.finalState = finalWorld.getBlockState(finalBlockPos);
|
2016-01-01 17:08:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public TileEntity getInitialTile()
|
|
|
|
{
|
|
|
|
return initalWorld.getTileEntity(initialBlockPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
public TileEntity getFinalTile()
|
|
|
|
{
|
|
|
|
return finalWorld.getTileEntity(finalBlockPos);
|
|
|
|
}
|
2016-05-12 03:29:16 +00:00
|
|
|
|
|
|
|
/**
|
2016-06-24 01:43:27 +00:00
|
|
|
* Fired when a Teleposer attempts to move an Entity between locations. Can
|
|
|
|
* be cancelled to stop transposition.
|
2016-05-12 03:29:16 +00:00
|
|
|
*/
|
|
|
|
@Cancelable
|
|
|
|
public static class Ent extends TeleposeEvent
|
|
|
|
{
|
|
|
|
public final Entity entity;
|
|
|
|
|
|
|
|
public Ent(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
|
|
|
{
|
|
|
|
super(initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
|
|
|
|
|
|
|
this.entity = entity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TileEntity getInitialTile() throws IllegalArgumentException
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public TileEntity getFinalTile() throws IllegalArgumentException
|
|
|
|
{
|
|
|
|
throw new IllegalArgumentException("Attempted to get a TileEntity from an Entity Telepose Event.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called after the entity has been transposed.
|
|
|
|
*/
|
2016-06-24 01:43:27 +00:00
|
|
|
public static class Post extends Ent
|
|
|
|
{
|
2016-05-12 03:29:16 +00:00
|
|
|
|
2016-06-24 01:43:27 +00:00
|
|
|
public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
|
|
|
{
|
2016-05-12 03:29:16 +00:00
|
|
|
super(entity, initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-01 17:08:17 +00:00
|
|
|
}
|