package com.corwinjv.mobtotems.blocks.tiles;

import com.corwinjv.mobtotems.Reference;
import com.corwinjv.mobtotems.blocks.ModBlocks;
import com.corwinjv.mobtotems.blocks.tiles.base.ModMultiblockInventoryTileEntity;
import com.corwinjv.mobtotems.gui.OfferingBoxContainer;
import com.corwinjv.mobtotems.interfaces.IChargeable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;

/**
 * Created by CorwinJV on 1/21/2017.
 */
public class OfferingBoxTileEntity extends ModMultiblockInventoryTileEntity implements IChargeable
{
    public static int INVENTORY_SIZE = 9;

    private static final String CHARGE_LEVEL = "CHARGE_LEVEL";

    public OfferingBoxTileEntity() {
        super();
    }

    @Override
    public void update() {
        // Get cost for current multiblock

        // Look for items that match the cost in inventory

        // Remove items that match the cost in inventory
        // Add charge

        // Check charge level

        // Perform charge effect
    }

    @Override
    public Container createContainer(InventoryPlayer playerInventory, EntityPlayer playerIn) {
        return new OfferingBoxContainer(playerInventory, this);
    }

    @Override
    public String getGuiID() {
        return Reference.RESOURCE_PREFIX + ModBlocks.OFFERING_BOX_NAME;
    }

    @Override
    public int getSizeInventory() {
        return INVENTORY_SIZE;
    }

    @Override
    public int getInventoryStackLimit() {
        return 64;
    }

    @Override
    public String getName() {
        return "container." + ModBlocks.OFFERING_BOX_NAME;
    }

    @Override
    protected int getUsableDistance() {
        return 3;
    }

    // Charge fun
    @Override
    public int getChargeLevel(ItemStack stack) {
        return 0;
    }

    @Override
    public void setChargeLevel(ItemStack stack, int chargeLevel) {

    }

    @Override
    public void decrementChargeLevel(ItemStack stack, int amount) {

    }

    @Override
    public void incrementChargeLevel(ItemStack stack, int amount) {

    }

    @Override
    public int getMaxChargeLevel() {
        return 0;
    }
}

@@ -270,62 +270,8 @@
 er;%0A
-import com.corwinjv.mobtotems.interfaces.IChargeable;%0A
 impo
@@ -434,22 +434,60 @@
 aft.
-item.ItemStack
+nbt.NBTTagCompound;%0A%0Aimport javax.annotation.Nonnull
 ;%0A%0A/
@@ -609,31 +609,8 @@
 tity
- implements IChargeable
 %0A%7B%0A 
@@ -651,16 +651,63 @@
 E = 9;%0A%0A
+    private static final int MAX_CHARGE = 100;%0A
     priv
@@ -762,16 +762,50 @@
 EVEL%22;%0A%0A
+    private int chargeLevel = 0;%0A%0A
     publ
@@ -894,24 +894,61 @@
  update() %7B%0A
+        // Verify multiblock status%0A%0A
         // G
@@ -1182,32 +1182,45 @@
 e effect%0A    %7D%0A%0A
+    @Nonnull%0A
     @Override%0A  
@@ -1232,34 +1232,774 @@
 lic 
-Container createContainer(
+NBTTagCompound writeToNBT(NBTTagCompound nbt) %7B%0A        nbt = super.writeToNBT(nbt);%0A        nbt.setInteger(CHARGE_LEVEL, chargeLevel);%0A        return nbt;%0A    %7D%0A%0A    @Override%0A    public void readFromNBT(NBTTagCompound nbt) %7B%0A        super.readFromNBT(nbt);%0A        chargeLevel = nbt.getInteger(CHARGE_LEVEL);%0A    %7D%0A%0A%0A    private int incrementChargeLevel(int amount)%0A    %7B%0A        chargeLevel += amount;%0A        if(chargeLevel %3E MAX_CHARGE)%0A            chargeLevel = MAX_CHARGE;%0A        return chargeLevel;%0A    %7D%0A%0A    private int decrementChargeLevel(int amount)%0A    %7B%0A        chargeLevel -= amount;%0A        if(chargeLevel %3C 0)%0A            chargeLevel = 0;%0A        return chargeLevel;%0A    %7D%0A%0A    @Nonnull%0A    @Override%0A    public Container createContainer(@Nonnull 
 Inve
@@ -2026,16 +2026,25 @@
 ventory,
+ @Nonnull
  EntityP
@@ -2124,32 +2124,45 @@
 , this);%0A    %7D%0A%0A
+    @Nonnull%0A
     @Override%0A  
@@ -2431,32 +2431,45 @@
 turn 64;%0A    %7D%0A%0A
+    @Nonnull%0A
     @Override%0A  
@@ -2643,458 +2643,7 @@
    %7D
-%0A%0A    // Charge fun%0A    @Override%0A    public int getChargeLevel(ItemStack stack) %7B%0A        return 0;%0A    %7D%0A%0A    @Override%0A    public void setChargeLevel(ItemStack stack, int chargeLevel) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void decrementChargeLevel(ItemStack stack, int amount) %7B%0A%0A    %7D%0A%0A    @Override%0A    public void incrementChargeLevel(ItemStack stack, int amount) %7B%0A%0A    %7D%0A%0A    @Override%0A    public int getMaxChargeLevel() %7B%0A        return 0;%0A    %7D
 %0A%7D%0A

Add chargeLevel to OfferingBoxTileEntity