2016-01-01 12:08:17 -05:00
|
|
|
package WayofTime.bloodmagic.api.event;
|
|
|
|
|
2016-03-17 13:00:44 -07:00
|
|
|
import WayofTime.bloodmagic.api.BlockStack;
|
2016-05-11 20:29:16 -07:00
|
|
|
import net.minecraft.entity.Entity;
|
2016-01-01 12:08:17 -05:00
|
|
|
import net.minecraft.tileentity.TileEntity;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.util.math.BlockPos;
|
2016-01-01 12:08:17 -05:00
|
|
|
import net.minecraft.world.World;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Cancelable;
|
|
|
|
import net.minecraftforge.fml.common.eventhandler.Event;
|
|
|
|
|
2016-01-02 17:56:37 -05: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 12:08:17 -05:00
|
|
|
@Cancelable
|
|
|
|
public class TeleposeEvent extends Event
|
|
|
|
{
|
|
|
|
public final World initalWorld;
|
|
|
|
public final BlockPos initialBlockPos;
|
2016-01-05 15:26:24 -08:00
|
|
|
public final BlockStack initialStack;
|
2016-01-01 12:08:17 -05:00
|
|
|
|
|
|
|
public final World finalWorld;
|
|
|
|
public final BlockPos finalBlockPos;
|
2016-01-05 15:26:24 -08:00
|
|
|
public final BlockStack finalStack;
|
2016-01-01 12:08:17 -05:00
|
|
|
|
2016-01-05 15:26:24 -08:00
|
|
|
public TeleposeEvent(World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos)
|
2016-01-01 12:08:17 -05:00
|
|
|
{
|
|
|
|
this.initalWorld = initialWorld;
|
|
|
|
this.initialBlockPos = initialBlockPos;
|
2016-01-05 15:26:24 -08:00
|
|
|
this.initialStack = BlockStack.getStackFromPos(initialWorld, initialBlockPos);
|
2016-01-01 12:08:17 -05:00
|
|
|
|
|
|
|
this.finalWorld = finalWorld;
|
|
|
|
this.finalBlockPos = finalBlockPos;
|
2016-01-05 15:26:24 -08:00
|
|
|
this.finalStack = BlockStack.getStackFromPos(finalWorld, finalBlockPos);
|
2016-01-01 12:08:17 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
public TileEntity getInitialTile()
|
|
|
|
{
|
|
|
|
return initalWorld.getTileEntity(initialBlockPos);
|
|
|
|
}
|
|
|
|
|
|
|
|
public TileEntity getFinalTile()
|
|
|
|
{
|
|
|
|
return finalWorld.getTileEntity(finalBlockPos);
|
|
|
|
}
|
2016-05-11 20:29:16 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Fired when a Teleposer attempts to move an Entity between locations. Can be cancelled to
|
|
|
|
* stop transposition.
|
|
|
|
*/
|
|
|
|
@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.
|
|
|
|
*/
|
|
|
|
public static class Post extends Ent {
|
|
|
|
|
|
|
|
public Post(Entity entity, World initialWorld, BlockPos initialBlockPos, World finalWorld, BlockPos finalBlockPos) {
|
|
|
|
super(entity, initialWorld, initialBlockPos, finalWorld, finalBlockPos);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-01-01 12:08:17 -05:00
|
|
|
}
|