use of org.valkyrienskies.mod.common.piloting.IShipPilotClient in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class VSKeyHandler method playerTick.
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void playerTick(PlayerTickEvent event) {
if (event.side == Side.SERVER) {
return;
}
if (event.phase == Phase.START) {
IShipPilotClient clientPilot = (IShipPilotClient) event.player;
clientPilot.onClientTick();
if (dismountKey.isKeyDown() && clientPilot.isPilotingATile()) {
BlockPos pilotedPos = clientPilot.getPosBeingControlled();
MessagePlayerStoppedPiloting stopPilotingMessage = new MessagePlayerStoppedPiloting(pilotedPos);
ValkyrienSkiesMod.controlNetwork.sendToServer(stopPilotingMessage);
clientPilot.stopPilotingEverything();
}
if (dismountKey.isKeyDown() && clientPilot.getShipIDBeingControlled() != null) {
MessagePlayerStoppedPiloting stopPilotingMessage = new MessagePlayerStoppedPiloting(clientPilot.getShipIDBeingControlled());
ValkyrienSkiesMod.controlNetwork.sendToServer(stopPilotingMessage);
clientPilot.stopPilotingEverything();
}
}
}
use of org.valkyrienskies.mod.common.piloting.IShipPilotClient in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MessageStartPilotingHandler method onMessage.
@Override
@SideOnly(Side.CLIENT)
public IMessage onMessage(MessageStartPiloting message, MessageContext ctx) {
IThreadListener mainThread = Minecraft.getMinecraft();
mainThread.addScheduledTask(() -> {
IShipPilotClient pilot = (IShipPilotClient) Minecraft.getMinecraft().player;
pilot.setControllerInputEnum(message.controlType);
if (message.posToStartPiloting != null) {
pilot.setPosBeingControlled(message.posToStartPiloting);
if (message.setPhysicsWrapperEntityToPilot) {
Optional<PhysicsObject> physicsObject = ValkyrienUtils.getPhysoManagingBlock(Minecraft.getMinecraft().world, message.posToStartPiloting);
if (physicsObject.isPresent()) {
pilot.setPilotedShip(physicsObject.get());
} else {
new IllegalStateException("Received incorrect piloting message!").printStackTrace();
}
} else {
pilot.setPilotedShip(null);
}
}
if (message.shipPilotingId != null)
pilot.setShipIDBeingControlled(message.shipPilotingId);
});
return null;
}
use of org.valkyrienskies.mod.common.piloting.IShipPilotClient in project Valkyrien-Warfare-Revamped by ValkyrienWarfare.
the class MessageStopPilotingHandler method onMessage.
@Override
public IMessage onMessage(MessageStopPiloting message, MessageContext ctx) {
IThreadListener mainThread = Minecraft.getMinecraft();
mainThread.addScheduledTask(() -> {
IShipPilotClient pilot = (IShipPilotClient) Minecraft.getMinecraft().player;
BlockPos posToStopPiloting = message.posToStopPiloting;
if (pilot.getPosBeingControlled() != null && pilot.getPosBeingControlled().equals(posToStopPiloting)) {
pilot.stopPilotingEverything();
}
});
return null;
}
Aggregations