Search in sources :

Example 1 with ITileEntityPilotable

use of org.valkyrienskies.mod.common.piloting.ITileEntityPilotable in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.

the class MessagePlayerStoppedPilotingHandler method onMessage.

@Override
public IMessage onMessage(MessagePlayerStoppedPiloting message, MessageContext ctx) {
    IThreadListener mainThread = ctx.getServerHandler().server;
    mainThread.addScheduledTask(() -> {
        if (message.posToStopPiloting != null) {
            BlockPos pos = message.posToStopPiloting;
            EntityPlayerMP player = ctx.getServerHandler().player;
            TileEntity tileEntity = player.world.getTileEntity(pos);
            if (tileEntity instanceof ITileEntityPilotable) {
                ((ITileEntityPilotable) tileEntity).playerWantsToStopPiloting(player);
            }
        } else {
            final UUID shipID = message.shipIDToStopPiloting;
            final PhysicsObject physicsObject = ValkyrienUtils.getPhysObjWorld(ctx.getServerHandler().player.world).getPhysObjectFromUUID(shipID);
            if (physicsObject != null && physicsObject.getShipPilot() != null && ctx.getServerHandler().player.getUniqueID().equals(physicsObject.getShipPilot().getPilot())) {
                physicsObject.setShipPilot(null);
            }
        }
    });
    return null;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IThreadListener(net.minecraft.util.IThreadListener) BlockPos(net.minecraft.util.math.BlockPos) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) UUID(java.util.UUID) PhysicsObject(org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject) ITileEntityPilotable(org.valkyrienskies.mod.common.piloting.ITileEntityPilotable)

Aggregations

UUID (java.util.UUID)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 TileEntity (net.minecraft.tileentity.TileEntity)1 IThreadListener (net.minecraft.util.IThreadListener)1 BlockPos (net.minecraft.util.math.BlockPos)1 ITileEntityPilotable (org.valkyrienskies.mod.common.piloting.ITileEntityPilotable)1 PhysicsObject (org.valkyrienskies.mod.common.ships.ship_world.PhysicsObject)1