Search in sources :

Example 1 with RecursiveBlueprintBuilder

use of buildcraft.builders.blueprints.RecursiveBlueprintBuilder in project BuildCraft by BuildCraft.

the class TileBuilder method iterateBpt.

public void iterateBpt(boolean forceIterate) {
    if (getStackInSlot(0) == null || !(getStackInSlot(0).getItem() instanceof ItemBlueprint)) {
        if (box.isInitialized()) {
            if (currentBuilder != null) {
                currentBuilder = null;
            }
            if (box.isInitialized()) {
                box.reset();
            }
            if (currentPathIterator != null) {
                currentPathIterator = null;
            }
            scheduleRequirementUpdate();
            sendNetworkUpdate();
            return;
        }
    }
    if (currentBuilder == null || (currentBuilder.isDone(this) || forceIterate)) {
        if (path != null && path.size() > 1) {
            if (currentPathIterator == null) {
                Iterator<BlockPos> it = path.iterator();
                BlockPos start = it.next();
                EnumFacing face = worldObj.getBlockState(pos).getValue(BuildCraftProperties.BLOCK_FACING);
                currentPathIterator = new PathIterator(start, it, face);
            }
            if (currentBuilder != null && currentBuilder.isDone(this)) {
                currentBuilder.postProcessing(worldObj);
            }
            currentBuilder = currentPathIterator.next();
            if (currentBuilder != null) {
                box.reset();
                box.initialize(currentBuilder);
                sendNetworkUpdate();
            }
            if (currentBuilder == null) {
                currentPathIterator = currentPathIterator.iterate();
            }
            if (currentPathIterator == null) {
                done = true;
            } else {
                done = false;
            }
            scheduleRequirementUpdate();
        } else {
            if (currentBuilder != null && currentBuilder.isDone(this)) {
                currentBuilder.postProcessing(worldObj);
                currentBuilder = recursiveBuilder.nextBuilder();
                scheduleRequirementUpdate();
            } else {
                BlueprintBase bpt = instanciateBlueprint();
                if (bpt != null) {
                    EnumFacing face = worldObj.getBlockState(pos).getValue(BuildCraftProperties.BLOCK_FACING);
                    recursiveBuilder = new RecursiveBlueprintBuilder(bpt, worldObj, pos, face.getOpposite());
                    currentBuilder = recursiveBuilder.nextBuilder();
                    scheduleRequirementUpdate();
                }
            }
            if (currentBuilder == null) {
                done = true;
            } else {
                box.initialize(currentBuilder);
                sendNetworkUpdate();
                done = false;
            }
        }
    }
    if (done && getStackInSlot(0) != null) {
        boolean dropBlueprint = true;
        for (int i = 1; i < getSizeInventory(); ++i) {
            if (getStackInSlot(i) == null) {
                setInventorySlotContents(i, getStackInSlot(0));
                dropBlueprint = false;
                break;
            }
        }
        if (dropBlueprint) {
            InvUtils.dropItems(getWorld(), getStackInSlot(0), pos);
        }
        setInventorySlotContents(0, null);
        box.reset();
        sendNetworkUpdate();
    }
}
Also used : BlueprintBase(buildcraft.core.blueprints.BlueprintBase) RecursiveBlueprintBuilder(buildcraft.builders.blueprints.RecursiveBlueprintBuilder) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Blueprint(buildcraft.core.blueprints.Blueprint) BptBuilderBlueprint(buildcraft.core.blueprints.BptBuilderBlueprint)

Aggregations

RecursiveBlueprintBuilder (buildcraft.builders.blueprints.RecursiveBlueprintBuilder)1 Blueprint (buildcraft.core.blueprints.Blueprint)1 BlueprintBase (buildcraft.core.blueprints.BlueprintBase)1 BptBuilderBlueprint (buildcraft.core.blueprints.BptBuilderBlueprint)1 EnumFacing (net.minecraft.util.EnumFacing)1 BlockPos (net.minecraft.util.math.BlockPos)1