// Path: src/main/java/com/wynprice/secretroomsmod/blocks/SecretChest.java
// public class SecretChest extends BaseFakeBlock
// {
// 
// 	public SecretChest(String name) {
// 		super(name, Material.WOOD);
// 	}
// 	
// 	@Override
// 	public TileEntity createNewTileEntity(World worldIn, int meta) {
// 		return new TileEntitySecretChest();
// 	}
// 	
// 	@Override
// 	public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// 		for(int i = 0; i < ((TileEntitySecretChest)worldIn.getTileEntity(pos)).getHandler().getSlots(); i++)
// 			InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), ((TileEntitySecretChest)worldIn.getTileEntity(pos)).getHandler().getStackInSlot(i));
// 	}
// 	
// 	public static final HashMap<Boolean, HashMap<BlockPos, Integer>> PLAYERS_USING_MAP = new HashMap<>();
// 	
// 	static
// 	{
// 		PLAYERS_USING_MAP.put(true, new HashMap<>());
// 		PLAYERS_USING_MAP.put(false, new HashMap<>());
// 	}
// 	
// 	@Override
// 	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
// 			EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) 
// 	{
// 		HashMap<BlockPos, Integer> playerMap = PLAYERS_USING_MAP.get(worldIn.isRemote);
// 		if(!playerMap.containsKey(pos))
// 			playerMap.put(pos, 0);
// 		playerMap.put(pos, playerMap.get(pos) + 1);
// 		if(!worldIn.isRemote)
// 			playerIn.openGui(SecretRooms5.instance, GuiHandler.SECRET_CHEST, worldIn, pos.getX(), pos.getY(), pos.getZ());
// 		worldIn.notifyNeighborsOfStateChange(pos, this, false);
// 		return true;
// 	}
// 
// }


import com.wynprice.secretroomsmod.blocks.SecretChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;
package com.wynprice.secretroomsmod.render;



/**
 * The container for the SecretRoomsMod chest and trapped chest
 * @author Wyn Price
 *
 */
public class ContainerSecretChest extends Container
{
	
	private final IItemHandler handler;	
	private final BlockPos pos;
	
	public ContainerSecretChest(BlockPos pos, IItemHandler handler, EntityPlayer player) 
	{
		this.handler = handler;
		this.pos = pos;
		for (int j = 0; j < 3; ++j)
            for (int k = 0; k < 9; ++k)
                this.addSlotToContainer(new SlotItemHandler(handler, k + j * 9, 8 + k * 18, 18 + j * 18));
		for(int y = 0; y < 3; ++y)
			for(int x = 0; x < 9; ++x)
				this.addSlotToContainer(new Slot(player.inventory, x + y * 9 + 9, 8 + x * 18, 85 + y * 18));
		for(int x = 0; x < 9; ++x) 
			this.addSlotToContainer(new Slot(player.inventory, x, 8 + x * 18, 85 + 58));
	}
	
	@Override
	public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
	    ItemStack previous = ItemStack.EMPTY;
	    Slot slot = (Slot) this.inventorySlots.get(fromSlot);

	    if (slot != null && slot.getHasStack()) {
	        ItemStack current = slot.getStack();
	        previous = current.copy();
	        if (fromSlot < handler.getSlots()) {
	            if (!this.mergeItemStack(current, handler.getSlots(), 63, true))
	                return ItemStack.EMPTY;
	        } else {
// Path: src/main/java/com/wynprice/secretroomsmod/blocks/SecretChest.java
// public class SecretChest extends BaseFakeBlock
// {
// 
// 	public SecretChest(String name) {
// 		super(name, Material.WOOD);
// 	}
// 	
// 	@Override
// 	public TileEntity createNewTileEntity(World worldIn, int meta) {
// 		return new TileEntitySecretChest();
// 	}
// 	
// 	@Override
// 	public void breakBlock(World worldIn, BlockPos pos, IBlockState state) {
// 		for(int i = 0; i < ((TileEntitySecretChest)worldIn.getTileEntity(pos)).getHandler().getSlots(); i++)
// 			InventoryHelper.spawnItemStack(worldIn, pos.getX(), pos.getY(), pos.getZ(), ((TileEntitySecretChest)worldIn.getTileEntity(pos)).getHandler().getStackInSlot(i));
// 	}
// 	
// 	public static final HashMap<Boolean, HashMap<BlockPos, Integer>> PLAYERS_USING_MAP = new HashMap<>();
// 	
// 	static
// 	{
// 		PLAYERS_USING_MAP.put(true, new HashMap<>());
// 		PLAYERS_USING_MAP.put(false, new HashMap<>());
// 	}
// 	
// 	@Override
// 	public boolean onBlockActivated(World worldIn, BlockPos pos, IBlockState state, EntityPlayer playerIn,
// 			EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) 
// 	{
// 		HashMap<BlockPos, Integer> playerMap = PLAYERS_USING_MAP.get(worldIn.isRemote);
// 		if(!playerMap.containsKey(pos))
// 			playerMap.put(pos, 0);
// 		playerMap.put(pos, playerMap.get(pos) + 1);
// 		if(!worldIn.isRemote)
// 			playerIn.openGui(SecretRooms5.instance, GuiHandler.SECRET_CHEST, worldIn, pos.getX(), pos.getY(), pos.getZ());
// 		worldIn.notifyNeighborsOfStateChange(pos, this, false);
// 		return true;
// 	}
// 
// }


// Path: src/main/java/com/wynprice/secretroomsmod/render/ContainerSecretChest.java
import com.wynprice.secretroomsmod.blocks.SecretChest;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.SlotItemHandler;

package com.wynprice.secretroomsmod.render;



/**
 * The container for the SecretRoomsMod chest and trapped chest
 * @author Wyn Price
 *
 */
public class ContainerSecretChest extends Container
{
	
	private final IItemHandler handler;	
	private final BlockPos pos;
	
	public ContainerSecretChest(BlockPos pos, IItemHandler handler, EntityPlayer player) 
	{
		this.handler = handler;
		this.pos = pos;
		for (int j = 0; j < 3; ++j)
            for (int k = 0; k < 9; ++k)
                this.addSlotToContainer(new SlotItemHandler(handler, k + j * 9, 8 + k * 18, 18 + j * 18));
		for(int y = 0; y < 3; ++y)
			for(int x = 0; x < 9; ++x)
				this.addSlotToContainer(new Slot(player.inventory, x + y * 9 + 9, 8 + x * 18, 85 + y * 18));
		for(int x = 0; x < 9; ++x) 
			this.addSlotToContainer(new Slot(player.inventory, x, 8 + x * 18, 85 + 58));
	}
	
	@Override
	public ItemStack transferStackInSlot(EntityPlayer playerIn, int fromSlot) {
	    ItemStack previous = ItemStack.EMPTY;
	    Slot slot = (Slot) this.inventorySlots.get(fromSlot);

	    if (slot != null && slot.getHasStack()) {
	        ItemStack current = slot.getStack();
	        previous = current.copy();
	        if (fromSlot < handler.getSlots()) {
	            if (!this.mergeItemStack(current, handler.getSlots(), 63, true))
	                return ItemStack.EMPTY;
	        } else {
	            if (!this.mergeItemStack(current, 0, handler.getSlots(), false))