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;
}
Aggregations