Search in sources :

Example 1 with EntitySeat

use of ebf.tim.entities.EntitySeat in project Trains-In-Motion-1.7.10 by EternalBlueFlame.

the class EventManager method onClientKeyPress.

/**
     * <h2>Keybind management</h2>
     * called when a client presses a key. this coveres pretty much everything.
     * Most cases just send a packet to manage things
     * @see PacketKeyPress
     *
     * Credit to Ferdinand for help with this function.
     *
     * @param event the event of a key being pressed on client.
     */
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onClientKeyPress(InputEvent.KeyInputEvent event) {
    EntityClientPlayerMP player = Minecraft.getMinecraft().thePlayer;
    if (player.ridingEntity instanceof GenericRailTransport || player.ridingEntity instanceof EntitySeat) {
        //for lamp
        if (ClientProxy.KeyLamp.isPressed()) {
            TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(0, player.ridingEntity.getEntityId()));
            ((GenericRailTransport) player.ridingEntity).setBoolean(GenericRailTransport.boolValues.LAMP, !((GenericRailTransport) player.ridingEntity).getBoolean(GenericRailTransport.boolValues.LAMP));
        }
        //for inventory
        if (ClientProxy.KeyInventory.isPressed()) {
            TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(1, player.ridingEntity.getEntityId()));
        }
        if (player.ridingEntity instanceof EntityTrainCore) {
            //for speed change
            if (ClientProxy.KeyAccelerate.isPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(2, player.ridingEntity.getEntityId()));
            } else if (ClientProxy.KeyReverse.getIsKeyPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(3, player.ridingEntity.getEntityId()));
            } else if (ClientProxy.KeyHorn.isPressed()) {
                TrainsInMotion.keyChannel.sendToServer(new PacketKeyPress(4, player.ridingEntity.getEntityId()));
            }
        }
    }
}
Also used : EntityTrainCore(ebf.tim.entities.EntityTrainCore) PacketKeyPress(ebf.tim.networking.PacketKeyPress) EntityClientPlayerMP(net.minecraft.client.entity.EntityClientPlayerMP) EntitySeat(ebf.tim.entities.EntitySeat) GenericRailTransport(ebf.tim.entities.GenericRailTransport) SubscribeEvent(cpw.mods.fml.common.eventhandler.SubscribeEvent) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Aggregations

SubscribeEvent (cpw.mods.fml.common.eventhandler.SubscribeEvent)1 SideOnly (cpw.mods.fml.relauncher.SideOnly)1 EntitySeat (ebf.tim.entities.EntitySeat)1 EntityTrainCore (ebf.tim.entities.EntityTrainCore)1 GenericRailTransport (ebf.tim.entities.GenericRailTransport)1 PacketKeyPress (ebf.tim.networking.PacketKeyPress)1 EntityClientPlayerMP (net.minecraft.client.entity.EntityClientPlayerMP)1