package com.jaquadro.minecraft.gardencontainers.block;

import com.jaquadro.minecraft.gardencontainers.block.tile.TileEntityMediumPot;
import com.jaquadro.minecraft.gardencontainers.core.ClientProxy;
import com.jaquadro.minecraft.gardencore.api.plant.PlantItem;
import com.jaquadro.minecraft.gardencore.api.plant.PlantSize;
import com.jaquadro.minecraft.gardencore.api.plant.PlantType;
import com.jaquadro.minecraft.gardencore.block.BlockGardenContainer;
import com.jaquadro.minecraft.gardencore.block.support.BasicConnectionProfile;
import com.jaquadro.minecraft.gardencore.block.support.BasicSlotProfile;
import com.jaquadro.minecraft.gardencore.block.support.Slot2Profile;
import com.jaquadro.minecraft.gardencore.block.support.SlotShare0Profile;
import com.jaquadro.minecraft.gardencore.core.ModCreativeTabs;
import net.minecraft.block.Block;
import net.minecraft.block.material.Material;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;

import java.util.List;

public abstract class BlockMediumPot extends BlockGardenContainer
{
    private class LocalSlotProfile extends Slot2Profile
    {
        public LocalSlotProfile (Slot[] slots) {
            super(slots);
        }

        @Override
        public float getPlantOffsetY (IBlockAccess blockAccess, int x, int y, int z, int slot) {
            return -.0625f * 5;
        }
    }

    public BlockMediumPot (String blockName) {
        super(blockName, Material.rock);

        setCreativeTab(ModCreativeTabs.tabGardenCore);
        setHardness(.5f);
        setResistance(5f);
        setStepSound(Block.soundTypeStone);

        connectionProfile = new BasicConnectionProfile();
        slotShareProfile = new SlotShare0Profile();

        PlantType[] commonType = new PlantType[] { PlantType.GROUND };
        PlantSize[] allSize = new PlantSize[] { PlantSize.MEDIUM, PlantSize.SMALL };

        slotProfile = new LocalSlotProfile(new BasicSlotProfile.Slot[] {
            new BasicSlotProfile.Slot(Slot2Profile.SLOT_CENTER, commonType, allSize),
            new BasicSlotProfile.Slot(Slot2Profile.SLOT_COVER, new PlantType[]{PlantType.GROUND_COVER}, allSize),
        });
    }

    public abstract String[] getSubTypes ();

    @Override
    protected int getSlot (World world, int x, int y, int z, EntityPlayer player, float hitX, float hitY, float hitZ) {
        return Slot2Profile.SLOT_CENTER;
    }

    @Override
    protected int getEmptySlotForPlant (World world, int x, int y, int z, EntityPlayer player, PlantItem plant) {
        if (plant.getPlantTypeClass() == PlantType.GROUND_COVER)
            return Slot2Profile.SLOT_COVER;

        return Slot2Profile.SLOT_CENTER;
    }

    @Override
    public int getRenderType () {
        return ClientProxy.mediumPotRenderID;
    }

    @Override
    public boolean isOpaqueCube () {
        return false;
    }

    @Override
    public boolean renderAsNormalBlock () {
        return false;
    }

    @Override
    public boolean shouldSideBeRendered (IBlockAccess blockAccess, int x, int y, int z, int side) {
        return true;
    }

    @Override
    public TileEntityMediumPot createNewTileEntity (World world, int meta) {
        return new TileEntityMediumPot();
    }

    @Override
    public void addCollisionBoxesToList (World world, int x, int y, int z, AxisAlignedBB mask, List list, Entity colliding) {
        setBlockBounds(.125f, 0, .125f, .875f, .75f, .875f);
        super.addCollisionBoxesToList(world, x, y, z, mask, list, colliding);

        setBlockBounds(.125f, 0, .125f, .875f, .75f, .875f);
    }

    @Override
    public void setBlockBoundsForItemRender () {
        setBlockBounds(.125f, 0, .125f, .875f, .75f, .875f);
    }

    @Override
    public boolean canHarvestBlock (EntityPlayer player, int meta) {
        return true;
    }

    @Override
    public TileEntityMediumPot getTileEntity (IBlockAccess world, int x, int y, int z) {
        TileEntity te = world.getTileEntity(x, y, z);
        return (te != null && te instanceof TileEntityMediumPot) ? (TileEntityMediumPot) te : null;
    }
}

@@ -967,24 +967,93 @@
 tityPlayer;%0A
+import net.minecraft.item.Item;%0Aimport net.minecraft.item.ItemStack;%0A
 import net.m
@@ -1201,16 +1201,44 @@
 World;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -3351,32 +3351,529 @@
 rn true;%0A    %7D%0A%0A
+    @Override%0A    public ArrayList%3CItemStack%3E getDrops (World world, int x, int y, int z, int metadata, int fortune) %7B%0A        ArrayList%3CItemStack%3E items = new ArrayList%3CItemStack%3E();%0A%0A        int count = quantityDropped(metadata, fortune, world.rand);%0A        for (int i = 0; i %3C count; i++) %7B%0A            Item item = getItemDropped(metadata, world.rand, fortune);%0A            if (item != null)%0A                items.add(new ItemStack(item, 1, metadata));%0A        %7D%0A%0A        return items;%0A    %7D%0A%0A
     @Override%0A  

Drop correct colored medium pot