package ncrashed.warp.cores.actions;

import ncrashed.warp.ModHelper;
import ncrashed.warp.api.ICoreAction;
import ncrashed.warp.api.IWarpCore;
import net.minecraft.tileentity.TileEntity;

public class GetCoreZ implements ICoreAction {

	@Override
	public int getRequiredEnergy(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		return 10000;
	}

	@Override
	public boolean performAction(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		int coord = core.getCoreZ();
		boolean negative = coord < 0;
		
		if(negative)
		{
			coord = ~(-coord)+1;
		} 
		
		core.getCoreStructure().setExpander(core.getCoreWorld(), core.getCoreX(), core.getCoreY(), core.getCoreZ(), 0, coord & 65535);
		core.getCoreStructure().setExpander(core.getCoreWorld(), core.getCoreX(), core.getCoreY(), core.getCoreZ(), 1, coord >> 16);
		core.getCoreStructure().setExpander(core.getCoreWorld(), core.getCoreX(), core.getCoreY(), core.getCoreZ(), 1, 15, negative);
		
		core.restartCheckingTickers();
		return true;
	}

	@Override
	public int getLowMultCounter() 
	{
		return 27;
	}

	@Override
	public int getHighMultCounter() 
	{
		return 27;
	}

	@Override
	public int getSuccessCooldown(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		return 1;
	}

	@Override
	public int getFailCooldown(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		return 1;
	}

	@Override
	public int getMinimumCooldown(IWarpCore core, int multCounter, int north,
			int south, int west, int east, int up, int down) 
	{
		return 0;
	}

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

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