use of ebf.tim.entities.EntityTrainCore 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()));
}
}
}
}
Aggregations