package ncrashed.warp.cores;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import ncrashed.warp.ModHelper;
import ncrashed.warp.WarpMod;
import ncrashed.warp.api.BigStructure;
import ncrashed.warp.api.IWarpBeacon;
import ncrashed.warp.api.IBigStructure.BlockInfo;
import ncrashed.warp.api.IBigStructure.IConditionHandler;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;

public class SimpleWarpBeacon extends BigStructure implements IWarpBeacon 
{
	public SimpleWarpBeacon()
	{
		super();
		HashMap<Integer, List<BlockInfo> > blockMapping = new HashMap<Integer, List<BlockInfo> >();
		
		ArrayList<BlockInfo> temp = new ArrayList<BlockInfo>();
		temp.add(new BlockInfo(WarpMod.mConfig.mRPControl, WarpMod.mConfig.mRPCounterMeta));
		blockMapping.put(Integer.valueOf(1), temp);
		
		temp = new ArrayList<BlockInfo>();
		temp.add(new BlockInfo(WarpMod.mConfig.mMarkerBlockID, -1));
		blockMapping.put(Integer.valueOf(2), temp);
		
		addBlockMapping(blockMapping);

		
		addLayer(new int[][]{
			new int[]{-1, -1,  1, -1, -1},
			new int[]{-1, -1, -1, -1, -1},
			new int[]{ 1, -1,  2, -1,  1},
			new int[]{-1, -1, -1, -1, -1},
			new int[]{-1, -1,  1, -1, -1}
		});
	}
	
	@Override
	public int getCounterValue(World world, int x, int y, int z,
			ForgeDirection dir) 
	{
		if(dir.equals(ForgeDirection.NORTH) || dir.equals(ForgeDirection.SOUTH) || dir.equals(ForgeDirection.WEST) || dir.equals(ForgeDirection.EAST))
		{
			return ModHelper.rp2GetCounterValue(world, x+2*dir.offsetX+getMarkerX(), y+getMarkerY(), z+2*dir.offsetZ+getMarkerZ());
		}
		
		return 0;
	}

	@Override
	public int getMarkerX() 
	{
		return 2;
	}

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

	@Override
	public int getMarkerZ() 
	{
		return 2;
	}

	@Override
	public int getPlayerX() 
	{
		return 2;
	}

	@Override
	public int getPlayerY() 
	{
		return 1;
	}

	@Override
	public int getPlayerZ() 
	{
		return 2;
	}

}
