// Path: src/main/java/tonius/simplyjetpacks/handler/SyncHandler.java
// public class SyncHandler {
//     
//     private static final Map<EntityPlayer, Boolean> flyKeyState = new HashMap<EntityPlayer, Boolean>();
//     private static final Map<EntityPlayer, Boolean> descendKeyState = new HashMap<EntityPlayer, Boolean>();
//     
//     private static final Map<EntityPlayer, Boolean> forwardKeyState = new HashMap<EntityPlayer, Boolean>();
//     private static final Map<EntityPlayer, Boolean> backwardKeyState = new HashMap<EntityPlayer, Boolean>();
//     private static final Map<EntityPlayer, Boolean> leftKeyState = new HashMap<EntityPlayer, Boolean>();
//     private static final Map<EntityPlayer, Boolean> rightKeyState = new HashMap<EntityPlayer, Boolean>();
//     
//     private static final Map<Integer, ParticleType> jetpackState = new HashMap<Integer, ParticleType>();
//     
//     public static boolean isFlyKeyDown(EntityLivingBase user) {
//         return !(user instanceof EntityPlayer) || flyKeyState.containsKey(user) && flyKeyState.get(user);
//     }
//     
//     public static boolean isDescendKeyDown(EntityLivingBase user) {
//         return user instanceof EntityPlayer && descendKeyState.containsKey(user) && descendKeyState.get(user);
//     }
//     
//     public static boolean isForwardKeyDown(EntityLivingBase user) {
//         return !(user instanceof EntityPlayer) || forwardKeyState.containsKey(user) && forwardKeyState.get(user);
//     }
//     
//     public static boolean isBackwardKeyDown(EntityLivingBase user) {
//         return user instanceof EntityPlayer && backwardKeyState.containsKey(user) && backwardKeyState.get(user);
//     }
//     
//     public static boolean isLeftKeyDown(EntityLivingBase user) {
//         return user instanceof EntityPlayer && leftKeyState.containsKey(user) && leftKeyState.get(user);
//     }
//     
//     public static boolean isRightKeyDown(EntityLivingBase user) {
//         return user instanceof EntityPlayer && rightKeyState.containsKey(user) && rightKeyState.get(user);
//     }
//     
//     public static void processKeyUpdate(EntityPlayer player, boolean keyFly, boolean keyDescend, boolean keyForward, boolean keyBackward, boolean keyLeft, boolean keyRight) {
//         flyKeyState.put(player, keyFly);
//         descendKeyState.put(player, keyDescend);
//         
//         forwardKeyState.put(player, keyForward);
//         backwardKeyState.put(player, keyBackward);
//         leftKeyState.put(player, keyLeft);
//         rightKeyState.put(player, keyRight);
//     }
//     
//     public static void processJetpackUpdate(int entityId, ParticleType particleType) {
//         if (particleType != null) {
//             jetpackState.put(entityId, particleType);
//         } else {
//             jetpackState.remove(entityId);
//         }
//     }
//     
//     public static Map<Integer, ParticleType> getJetpackStates() {
//         return jetpackState;
//     }
//     
//     public static void clearAll() {
//         flyKeyState.clear();
//         forwardKeyState.clear();
//         backwardKeyState.clear();
//         leftKeyState.clear();
//         rightKeyState.clear();
//     }
//     
//     private static void removeFromAll(EntityPlayer player) {
//         flyKeyState.remove(player);
//         forwardKeyState.remove(player);
//         backwardKeyState.remove(player);
//         leftKeyState.remove(player);
//         rightKeyState.remove(player);
//     }
//     
//     @SubscribeEvent
//     public void onPlayerLoggedIn(PlayerLoggedInEvent evt) {
//         PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player);
//     }
//     
//     @SubscribeEvent
//     public void onPlayerLoggedOut(PlayerLoggedOutEvent evt) {
//         removeFromAll(evt.player);
//     }
//     
//     @SubscribeEvent
//     public void onDimChanged(PlayerChangedDimensionEvent evt) {
//         removeFromAll(evt.player);
//     }
//     
//     @SubscribeEvent
//     public void onClientDisconnectedFromServer(ClientDisconnectionFromServerEvent evt) {
//         SoundJetpack.clearPlayingFor();
//         Config.onConfigChanged(SimplyJetpacks.MODID);
//     }
//     
// }


import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import tonius.simplyjetpacks.handler.SyncHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
        this.leftState = leftState;
        this.rightState = rightState;
    }
    
    @Override
    public void fromBytes(ByteBuf buf) {
        this.flyState = buf.readBoolean();
        this.descendState = buf.readBoolean();
        
        this.forwardState = buf.readBoolean();
        this.backwardState = buf.readBoolean();
        this.leftState = buf.readBoolean();
        this.rightState = buf.readBoolean();
    }
    
    @Override
    public void toBytes(ByteBuf buf) {
        buf.writeBoolean(this.flyState);
        buf.writeBoolean(this.descendState);
        
        buf.writeBoolean(this.forwardState);
        buf.writeBoolean(this.backwardState);
        buf.writeBoolean(this.leftState);
        buf.writeBoolean(this.rightState);
    }
    
    @Override
    public IMessage onMessage(MessageKeyboardSync msg, MessageContext ctx) {
        EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
        if (entityPlayer != null) {
// Path: src/main/java/tonius/simplyjetpacks/handler/SyncHandler.java
// public class SyncHandler {
//     
//     private static final Map<EntityPlayer, Boolean> flyKeyState = new HashMap<EntityPlayer, Boolean>();
//     private static final Map<EntityPlayer, Boolean> descendKeyState = new HashMap<EntityPlayer, Boolean>();
//     
//     private static final Map<EntityPlayer, Boolean> forwardKeyState = new HashMap<EntityPlayer, Boolean>();
//     private static final Map<EntityPlayer, Boolean> backwardKeyState = new HashMap<EntityPlayer, Boolean>();
//     private static final Map<EntityPlayer, Boolean> leftKeyState = new HashMap<EntityPlayer, Boolean>();
//     private static final Map<EntityPlayer, Boolean> rightKeyState = new HashMap<EntityPlayer, Boolean>();
//     
//     private static final Map<Integer, ParticleType> jetpackState = new HashMap<Integer, ParticleType>();
//     
//     public static boolean isFlyKeyDown(EntityLivingBase user) {
//         return !(user instanceof EntityPlayer) || flyKeyState.containsKey(user) && flyKeyState.get(user);
//     }
//     
//     public static boolean isDescendKeyDown(EntityLivingBase user) {
//         return user instanceof EntityPlayer && descendKeyState.containsKey(user) && descendKeyState.get(user);
//     }
//     
//     public static boolean isForwardKeyDown(EntityLivingBase user) {
//         return !(user instanceof EntityPlayer) || forwardKeyState.containsKey(user) && forwardKeyState.get(user);
//     }
//     
//     public static boolean isBackwardKeyDown(EntityLivingBase user) {
//         return user instanceof EntityPlayer && backwardKeyState.containsKey(user) && backwardKeyState.get(user);
//     }
//     
//     public static boolean isLeftKeyDown(EntityLivingBase user) {
//         return user instanceof EntityPlayer && leftKeyState.containsKey(user) && leftKeyState.get(user);
//     }
//     
//     public static boolean isRightKeyDown(EntityLivingBase user) {
//         return user instanceof EntityPlayer && rightKeyState.containsKey(user) && rightKeyState.get(user);
//     }
//     
//     public static void processKeyUpdate(EntityPlayer player, boolean keyFly, boolean keyDescend, boolean keyForward, boolean keyBackward, boolean keyLeft, boolean keyRight) {
//         flyKeyState.put(player, keyFly);
//         descendKeyState.put(player, keyDescend);
//         
//         forwardKeyState.put(player, keyForward);
//         backwardKeyState.put(player, keyBackward);
//         leftKeyState.put(player, keyLeft);
//         rightKeyState.put(player, keyRight);
//     }
//     
//     public static void processJetpackUpdate(int entityId, ParticleType particleType) {
//         if (particleType != null) {
//             jetpackState.put(entityId, particleType);
//         } else {
//             jetpackState.remove(entityId);
//         }
//     }
//     
//     public static Map<Integer, ParticleType> getJetpackStates() {
//         return jetpackState;
//     }
//     
//     public static void clearAll() {
//         flyKeyState.clear();
//         forwardKeyState.clear();
//         backwardKeyState.clear();
//         leftKeyState.clear();
//         rightKeyState.clear();
//     }
//     
//     private static void removeFromAll(EntityPlayer player) {
//         flyKeyState.remove(player);
//         forwardKeyState.remove(player);
//         backwardKeyState.remove(player);
//         leftKeyState.remove(player);
//         rightKeyState.remove(player);
//     }
//     
//     @SubscribeEvent
//     public void onPlayerLoggedIn(PlayerLoggedInEvent evt) {
//         PacketHandler.instance.sendTo(new MessageConfigSync(), (EntityPlayerMP) evt.player);
//     }
//     
//     @SubscribeEvent
//     public void onPlayerLoggedOut(PlayerLoggedOutEvent evt) {
//         removeFromAll(evt.player);
//     }
//     
//     @SubscribeEvent
//     public void onDimChanged(PlayerChangedDimensionEvent evt) {
//         removeFromAll(evt.player);
//     }
//     
//     @SubscribeEvent
//     public void onClientDisconnectedFromServer(ClientDisconnectionFromServerEvent evt) {
//         SoundJetpack.clearPlayingFor();
//         Config.onConfigChanged(SimplyJetpacks.MODID);
//     }
//     
// }


// Path: src/main/java/tonius/simplyjetpacks/network/message/MessageKeyboardSync.java
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import tonius.simplyjetpacks.handler.SyncHandler;
import cpw.mods.fml.common.network.simpleimpl.IMessage;
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
import cpw.mods.fml.common.network.simpleimpl.MessageContext;

        this.leftState = leftState;
        this.rightState = rightState;
    }
    
    @Override
    public void fromBytes(ByteBuf buf) {
        this.flyState = buf.readBoolean();
        this.descendState = buf.readBoolean();
        
        this.forwardState = buf.readBoolean();
        this.backwardState = buf.readBoolean();
        this.leftState = buf.readBoolean();
        this.rightState = buf.readBoolean();
    }
    
    @Override
    public void toBytes(ByteBuf buf) {
        buf.writeBoolean(this.flyState);
        buf.writeBoolean(this.descendState);
        
        buf.writeBoolean(this.forwardState);
        buf.writeBoolean(this.backwardState);
        buf.writeBoolean(this.leftState);
        buf.writeBoolean(this.rightState);
    }
    
    @Override
    public IMessage onMessage(MessageKeyboardSync msg, MessageContext ctx) {
        EntityPlayer entityPlayer = ctx.getServerHandler().playerEntity;
        if (entityPlayer != null) {
            SyncHandler.processKeyUpdate(entityPlayer, msg.flyState, msg.descendState, msg.forwardState, msg.backwardState, msg.leftState, msg.rightState);