package net.minecraft.src;

import java.util.List;

import net.lax1dude.eaglercraft.sp.EaglercraftRandom;

public class ComponentNetherBridgeCrossing extends ComponentNetherBridgePiece {
	public ComponentNetherBridgeCrossing(int par1, EaglercraftRandom par2Random, StructureBoundingBox par3StructureBoundingBox,
			int par4) {
		super(par1);
		this.coordBaseMode = par4;
		this.boundingBox = par3StructureBoundingBox;
	}

	/**
	 * Initiates construction of the Structure Component picked, at the current
	 * Location of StructGen
	 */
	public void buildComponent(StructureComponent par1StructureComponent, List par2List, EaglercraftRandom par3Random) {
		this.getNextComponentNormal((ComponentNetherBridgeStartPiece) par1StructureComponent, par2List, par3Random, 2,
				0, false);
		this.getNextComponentX((ComponentNetherBridgeStartPiece) par1StructureComponent, par2List, par3Random, 0, 2,
				false);
		this.getNextComponentZ((ComponentNetherBridgeStartPiece) par1StructureComponent, par2List, par3Random, 0, 2,
				false);
	}

	/**
	 * Creates and returns a new component piece. Or null if it could not find
	 * enough room to place it.
	 */
	public static ComponentNetherBridgeCrossing createValidComponent(List par0List, EaglercraftRandom par1Random, int par2,
			int par3, int par4, int par5, int par6) {
		StructureBoundingBox var7 = StructureBoundingBox.getComponentToAddBoundingBox(par2, par3, par4, -2, 0, 0, 7, 9,
				7, par5);
		return isAboveGround(var7) && StructureComponent.findIntersecting(par0List, var7) == null
				? new ComponentNetherBridgeCrossing(par6, par1Random, var7, par5)
				: null;
	}

	/**
	 * second Part of Structure generating, this for example places Spiderwebs, Mob
	 * Spawners, it closes Mineshafts at the end, it adds Fences...
	 */
	public boolean addComponentParts(World par1World, EaglercraftRandom par2Random,
			StructureBoundingBox par3StructureBoundingBox) {
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 0, 0, 6, 1, 6, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 6, 7, 6, 0, 0, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 1, 6, 0, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 6, 1, 6, 6, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 2, 0, 6, 6, 0, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 5, 2, 6, 6, 6, 6, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 0, 0, 6, 1, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 2, 5, 0, 6, 6, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 2, 0, 6, 6, 1, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 2, 5, 6, 6, 6, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 6, 0, 4, 6, 0, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 0, 4, 5, 0, Block.netherFence.blockID,
				Block.netherFence.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 6, 6, 4, 6, 6, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 2, 5, 6, 4, 5, 6, Block.netherFence.blockID,
				Block.netherFence.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 6, 2, 0, 6, 4, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 0, 5, 2, 0, 5, 4, Block.netherFence.blockID,
				Block.netherFence.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 6, 2, 6, 6, 4, Block.netherBrick.blockID,
				Block.netherBrick.blockID, false);
		this.fillWithBlocks(par1World, par3StructureBoundingBox, 6, 5, 2, 6, 5, 4, Block.netherFence.blockID,
				Block.netherFence.blockID, false);

		for (int var4 = 0; var4 <= 6; ++var4) {
			for (int var5 = 0; var5 <= 6; ++var5) {
				this.fillCurrentPositionBlocksDownwards(par1World, Block.netherBrick.blockID, 0, var4, -1, var5,
						par3StructureBoundingBox);
			}
		}

		return true;
	}
}
