// Path: src/main/java/com/corwinjv/mobtotems/items/baubles/BaubleItem.java
// @Optional.Interface(modid = "baubles", iface = "baubles.api.IBauble")
// public class BaubleItem extends ModItem implements IBauble, IChargeable {
//     protected static final String CHARGE_LEVEL = "CHARGE_LEVEL";
// 
//     public BaubleItem() {
//         super();
//     }
// 
//     @Override
//     public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn) {
//         initNbtData(stack);
//     }
// 
//     protected NBTTagCompound initNbtData(ItemStack stack) {
//         NBTTagCompound nbtTagCompound = stack.getTagCompound();
//         if (nbtTagCompound == null) {
//             nbtTagCompound = new NBTTagCompound();
//         }
//         nbtTagCompound.setInteger(CHARGE_LEVEL, 0);
// 
//         stack.setTagCompound(nbtTagCompound);
//         return nbtTagCompound;
//     }
// 
//     @SuppressWarnings("all")
//     @Override
//     public int getChargeLevel(ItemStack stack) {
//         NBTTagCompound tagCompound = stack.getTagCompound();
//         if (tagCompound == null) {
//             tagCompound = initNbtData(stack);
//         }
//         return tagCompound.getInteger(CHARGE_LEVEL);
//     }
// 
//     @Override
//     public void setChargeLevel(ItemStack stack, int chargeLevel) {
//         NBTTagCompound tagCompound = stack.getTagCompound();
//         if (tagCompound == null) {
//             tagCompound = initNbtData(stack);
//         }
//         tagCompound.setInteger(CHARGE_LEVEL, chargeLevel);
//     }
// 
//     @Override
//     public void decrementChargeLevel(ItemStack stack, int amount) {
//         int chargeLevel = getChargeLevel(stack);
//         chargeLevel -= amount;
//         if (chargeLevel < 0) {
//             chargeLevel = 0;
//         }
// 
//         setChargeLevel(stack, chargeLevel);
//     }
// 
//     @Override
//     public void incrementChargeLevel(ItemStack stack, int amount) {
//         int chargeLevel = getChargeLevel(stack);
//         chargeLevel += amount;
//         if (chargeLevel > getMaxChargeLevel()) {
//             chargeLevel = getMaxChargeLevel();
//         }
//         setChargeLevel(stack, chargeLevel);
//     }
// 
//     @Override
//     public int getMaxChargeLevel() {
//         return 16;
//     }
// 
//     public void onBaubleActivated(ItemStack stack, EntityPlayer player) {
//     }
// 
//     @Override
//     @SideOnly(Side.CLIENT)
//     public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
//         super.addInformation(stack, worldIn, tooltip, flagIn);
//     }
// 
//     @Override
//     public BaubleType getBaubleType(ItemStack itemstack) {
//         return BaubleType.TRINKET;
//     }
// 
//     @Override
//     public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
//         return true;
//     }
// 
//     @Override
//     public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
//         return true;
//     }
// 
//     @Override
//     public boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) {
//         return true;
//     }
// }


import baubles.api.BaublesApi;
import baubles.api.cap.IBaublesItemHandler;
import com.corwinjv.mobtotems.items.baubles.BaubleItem;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;
package com.corwinjv.mobtotems.network;


/**
 * Created by CorwinJV on 2/1/2016.
 */
public class ActivateBaubleMessage extends Message<ActivateBaubleMessage> {
    @Override
    protected void handleServer(ActivateBaubleMessage message, EntityPlayerMP player) {
        final IBaublesItemHandler baublesItemHandler = BaublesApi.getBaublesHandler(player);

        if (baublesItemHandler == null) {
            return;
        }

        for (int i = 0; i < baublesItemHandler.getSlots(); i++) {
            final ItemStack baubleStack = baublesItemHandler.getStackInSlot(i);
            if (baubleStack != ItemStack.EMPTY
                    && baubleStack.getItem() instanceof BaubleItem) {
// Path: src/main/java/com/corwinjv/mobtotems/items/baubles/BaubleItem.java
// @Optional.Interface(modid = "baubles", iface = "baubles.api.IBauble")
// public class BaubleItem extends ModItem implements IBauble, IChargeable {
//     protected static final String CHARGE_LEVEL = "CHARGE_LEVEL";
// 
//     public BaubleItem() {
//         super();
//     }
// 
//     @Override
//     public void onCreated(ItemStack stack, World worldIn, EntityPlayer playerIn) {
//         initNbtData(stack);
//     }
// 
//     protected NBTTagCompound initNbtData(ItemStack stack) {
//         NBTTagCompound nbtTagCompound = stack.getTagCompound();
//         if (nbtTagCompound == null) {
//             nbtTagCompound = new NBTTagCompound();
//         }
//         nbtTagCompound.setInteger(CHARGE_LEVEL, 0);
// 
//         stack.setTagCompound(nbtTagCompound);
//         return nbtTagCompound;
//     }
// 
//     @SuppressWarnings("all")
//     @Override
//     public int getChargeLevel(ItemStack stack) {
//         NBTTagCompound tagCompound = stack.getTagCompound();
//         if (tagCompound == null) {
//             tagCompound = initNbtData(stack);
//         }
//         return tagCompound.getInteger(CHARGE_LEVEL);
//     }
// 
//     @Override
//     public void setChargeLevel(ItemStack stack, int chargeLevel) {
//         NBTTagCompound tagCompound = stack.getTagCompound();
//         if (tagCompound == null) {
//             tagCompound = initNbtData(stack);
//         }
//         tagCompound.setInteger(CHARGE_LEVEL, chargeLevel);
//     }
// 
//     @Override
//     public void decrementChargeLevel(ItemStack stack, int amount) {
//         int chargeLevel = getChargeLevel(stack);
//         chargeLevel -= amount;
//         if (chargeLevel < 0) {
//             chargeLevel = 0;
//         }
// 
//         setChargeLevel(stack, chargeLevel);
//     }
// 
//     @Override
//     public void incrementChargeLevel(ItemStack stack, int amount) {
//         int chargeLevel = getChargeLevel(stack);
//         chargeLevel += amount;
//         if (chargeLevel > getMaxChargeLevel()) {
//             chargeLevel = getMaxChargeLevel();
//         }
//         setChargeLevel(stack, chargeLevel);
//     }
// 
//     @Override
//     public int getMaxChargeLevel() {
//         return 16;
//     }
// 
//     public void onBaubleActivated(ItemStack stack, EntityPlayer player) {
//     }
// 
//     @Override
//     @SideOnly(Side.CLIENT)
//     public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) {
//         super.addInformation(stack, worldIn, tooltip, flagIn);
//     }
// 
//     @Override
//     public BaubleType getBaubleType(ItemStack itemstack) {
//         return BaubleType.TRINKET;
//     }
// 
//     @Override
//     public boolean canEquip(ItemStack itemstack, EntityLivingBase player) {
//         return true;
//     }
// 
//     @Override
//     public boolean canUnequip(ItemStack itemstack, EntityLivingBase player) {
//         return true;
//     }
// 
//     @Override
//     public boolean willAutoSync(ItemStack itemstack, EntityLivingBase player) {
//         return true;
//     }
// }


// Path: src/main/java/com/corwinjv/mobtotems/network/ActivateBaubleMessage.java
import baubles.api.BaublesApi;
import baubles.api.cap.IBaublesItemHandler;
import com.corwinjv.mobtotems.items.baubles.BaubleItem;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.item.ItemStack;

package com.corwinjv.mobtotems.network;


/**
 * Created by CorwinJV on 2/1/2016.
 */
public class ActivateBaubleMessage extends Message<ActivateBaubleMessage> {
    @Override
    protected void handleServer(ActivateBaubleMessage message, EntityPlayerMP player) {
        final IBaublesItemHandler baublesItemHandler = BaublesApi.getBaublesHandler(player);

        if (baublesItemHandler == null) {
            return;
        }

        for (int i = 0; i < baublesItemHandler.getSlots(); i++) {
            final ItemStack baubleStack = baublesItemHandler.getStackInSlot(i);
            if (baubleStack != ItemStack.EMPTY
                    && baubleStack.getItem() instanceof BaubleItem) {
                ((BaubleItem) baubleStack.getItem()).onBaubleActivated(baubleStack, player);