// Path: src/main/java/gr8pefish/openglider/api/helper/GliderHelper.java
// public class GliderHelper {
// 
// 
//     //ToDo: getIGlider/setIGlider
//     //return itemstack or IGlider?
// 
//     /**
//      * Get the gliderBasic used, contains all the stats/modifiers of it.
//      * Should only be needed when {@link IGliderCapabilityHandler#getIsPlayerGliding} is true.
//      * See {@link IGlider} for details.
//      * Currently only gets the currently held item of the player when they have it deployed.
//      *
//      * @return - the IGlider the player is using, null if not using any.
//      */
//     public static ItemStack getGlider(EntityPlayer player) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
// 
//         //if gliderBasic deployed
//         if (cap != null && cap.getIsGliderDeployed()) {
// 
//             //if player holding a gliderBasic
//             if (player != null && player.getHeldItemMainhand() != null && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof IGlider) {
// 
//                 //return that held gliderBasic
//                 return player.getHeldItemMainhand();
//             }
//         }
//         else
//             Logger.error("Cannot get gliderBasic used, gliderBasic capability not present.");
//         return null;
//     }
// 
//     /**
//      * Wrapper method for {@link IGliderCapabilityHandler#getIsPlayerGliding()}, taking into account capabilities.
//      *
//      * @param player - the player to check
//      * @return - True if gliding, False otherwise (includes no capability)
//      */
//     public static boolean getIsPlayerGliding(EntityPlayer player) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
//         if (cap != null)
//             return cap.getIsPlayerGliding();
//         else
//             Logger.error("Cannot get player gliding status, gliderBasic capability not present.");
//         return false;
//     }
// 
//     /**
//      * Wrapper method for {@link IGliderCapabilityHandler#setIsPlayerGliding(boolean)}, taking into account capabilities.
//      *
//      * @param player - the player to check
//      * @param isGliding - the gliding state to set
//      */
//     public static void setIsPlayerGliding(EntityPlayer player, boolean isGliding) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
//         if (cap != null)
//             cap.setIsPlayerGliding(isGliding);
//         else
//             Logger.error("Cannot set player gliding, gliderBasic capability not present.");
//     }
// 
//     /**
//      * Wrapper method for {@link IGliderCapabilityHandler#getIsGliderDeployed()}, taking into account capabilities.
//      *
//      * @param player - the player to check
//      * @return - True if deployed, False otherwise (includes no capability)
//      */
//     public static boolean getIsGliderDeployed(EntityPlayer player) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
//         if (cap != null)
//             return cap.getIsGliderDeployed();
//         else
//             Logger.error("Cannot get gliderBasic deployment status, gliderBasic capability not present.");
//         return false;
//     }
// 
//     /**
//      * Wrapper method for {@link IGliderCapabilityHandler#setIsGliderDeployed(boolean)}, taking into account capabilities.
//      *
//      * @param player - the player to check
//      * @param isDeployed - the gliderBasic deployment state to set
//      */
//     public static void setIsGliderDeployed(EntityPlayer player, boolean isDeployed) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
//         if (cap != null)
//             cap.setIsGliderDeployed(isDeployed);
//         else
//             Logger.error("Cannot set gliderBasic deployed, gliderBasic capability not present.");
//     }
// 
// }


import gr8pefish.openglider.api.helper.GliderHelper;
import io.netty.buffer.ByteBuf;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;
package gr8pefish.openglider.common.network;


/**
 * [UNUSED]
 * Syncs the gliding capability on the server side to a given player.
 */
public class PacketServerGliding implements IMessage {

    //the data sent
    private byte isGliding;

    public final static byte IS_GLIDING = 0;
    public final static byte IS_NOT_GLIDING = 1;

    public PacketServerGliding() {} //default constructor is necessary

    public PacketServerGliding(byte gliding) {
        this.isGliding = gliding;
    }

    @Override
    public void fromBytes(ByteBuf buf){
        isGliding = (byte) ByteBufUtils.readVarShort(buf);
    }

    @Override
    public void toBytes(ByteBuf buf){
        ByteBufUtils.writeVarShort(buf, isGliding);
    }

    public static class Handler implements IMessageHandler<PacketServerGliding, IMessage> {

        @Override
        public IMessage onMessage(PacketServerGliding message, MessageContext ctx) {

// Path: src/main/java/gr8pefish/openglider/api/helper/GliderHelper.java
// public class GliderHelper {
// 
// 
//     //ToDo: getIGlider/setIGlider
//     //return itemstack or IGlider?
// 
//     /**
//      * Get the gliderBasic used, contains all the stats/modifiers of it.
//      * Should only be needed when {@link IGliderCapabilityHandler#getIsPlayerGliding} is true.
//      * See {@link IGlider} for details.
//      * Currently only gets the currently held item of the player when they have it deployed.
//      *
//      * @return - the IGlider the player is using, null if not using any.
//      */
//     public static ItemStack getGlider(EntityPlayer player) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
// 
//         //if gliderBasic deployed
//         if (cap != null && cap.getIsGliderDeployed()) {
// 
//             //if player holding a gliderBasic
//             if (player != null && player.getHeldItemMainhand() != null && !player.getHeldItemMainhand().isEmpty() && player.getHeldItemMainhand().getItem() instanceof IGlider) {
// 
//                 //return that held gliderBasic
//                 return player.getHeldItemMainhand();
//             }
//         }
//         else
//             Logger.error("Cannot get gliderBasic used, gliderBasic capability not present.");
//         return null;
//     }
// 
//     /**
//      * Wrapper method for {@link IGliderCapabilityHandler#getIsPlayerGliding()}, taking into account capabilities.
//      *
//      * @param player - the player to check
//      * @return - True if gliding, False otherwise (includes no capability)
//      */
//     public static boolean getIsPlayerGliding(EntityPlayer player) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
//         if (cap != null)
//             return cap.getIsPlayerGliding();
//         else
//             Logger.error("Cannot get player gliding status, gliderBasic capability not present.");
//         return false;
//     }
// 
//     /**
//      * Wrapper method for {@link IGliderCapabilityHandler#setIsPlayerGliding(boolean)}, taking into account capabilities.
//      *
//      * @param player - the player to check
//      * @param isGliding - the gliding state to set
//      */
//     public static void setIsPlayerGliding(EntityPlayer player, boolean isGliding) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
//         if (cap != null)
//             cap.setIsPlayerGliding(isGliding);
//         else
//             Logger.error("Cannot set player gliding, gliderBasic capability not present.");
//     }
// 
//     /**
//      * Wrapper method for {@link IGliderCapabilityHandler#getIsGliderDeployed()}, taking into account capabilities.
//      *
//      * @param player - the player to check
//      * @return - True if deployed, False otherwise (includes no capability)
//      */
//     public static boolean getIsGliderDeployed(EntityPlayer player) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
//         if (cap != null)
//             return cap.getIsGliderDeployed();
//         else
//             Logger.error("Cannot get gliderBasic deployment status, gliderBasic capability not present.");
//         return false;
//     }
// 
//     /**
//      * Wrapper method for {@link IGliderCapabilityHandler#setIsGliderDeployed(boolean)}, taking into account capabilities.
//      *
//      * @param player - the player to check
//      * @param isDeployed - the gliderBasic deployment state to set
//      */
//     public static void setIsGliderDeployed(EntityPlayer player, boolean isDeployed) {
//         IGliderCapabilityHandler cap = CapabilityHelper.getGliderCapability(player);
//         if (cap != null)
//             cap.setIsGliderDeployed(isDeployed);
//         else
//             Logger.error("Cannot set gliderBasic deployed, gliderBasic capability not present.");
//     }
// 
// }


// Path: src/main/java/gr8pefish/openglider/common/network/PacketServerGliding.java
import gr8pefish.openglider.api.helper.GliderHelper;
import io.netty.buffer.ByteBuf;
import net.minecraftforge.fml.common.network.ByteBufUtils;
import net.minecraftforge.fml.common.network.simpleimpl.IMessage;
import net.minecraftforge.fml.common.network.simpleimpl.IMessageHandler;
import net.minecraftforge.fml.common.network.simpleimpl.MessageContext;

package gr8pefish.openglider.common.network;


/**
 * [UNUSED]
 * Syncs the gliding capability on the server side to a given player.
 */
public class PacketServerGliding implements IMessage {

    //the data sent
    private byte isGliding;

    public final static byte IS_GLIDING = 0;
    public final static byte IS_NOT_GLIDING = 1;

    public PacketServerGliding() {} //default constructor is necessary

    public PacketServerGliding(byte gliding) {
        this.isGliding = gliding;
    }

    @Override
    public void fromBytes(ByteBuf buf){
        isGliding = (byte) ByteBufUtils.readVarShort(buf);
    }

    @Override
    public void toBytes(ByteBuf buf){
        ByteBufUtils.writeVarShort(buf, isGliding);
    }

    public static class Handler implements IMessageHandler<PacketServerGliding, IMessage> {

        @Override
        public IMessage onMessage(PacketServerGliding message, MessageContext ctx) {

            GliderHelper.setIsGliderDeployed(ctx.getServerHandler().player, message.isGliding == IS_GLIDING);