Search in sources :

Example 1 with BuildingSlotIterator

use of buildcraft.core.builders.BuildingSlotIterator in project BuildCraft by BuildCraft.

the class BptBuilderTemplate method internalInit.

@Override
protected void internalInit() {
    BlockPos worldOffset = pos.subtract(blueprint.anchor);
    BlockPos bptMin = BlockPos.ORIGIN;
    if (worldOffset.getY() < 0)
        bptMin = VecUtil.replaceValue(bptMin, Axis.Y, -worldOffset.getY());
    BlockPos bptMax = blueprint.size.subtract(Utils.POS_ONE);
    if (worldOffset.add(bptMax).getY() >= context.world().getHeight()) {
        bptMax = VecUtil.replaceValue(bptMax, Axis.Y, context.world().getHeight() - worldOffset.getY());
    }
    /* Check to make sure the max is bigger than the min- if its not it means that the size was 0 for one of the
         * axis */
    if (Utils.min(bptMin, bptMax).equals(bptMin) && Utils.max(bptMin, bptMax).equals(bptMax)) {
        if (blueprint.excavate) {
            for (BlockPos bptOffset : BlockPos.getAllInBox(bptMin, bptMax)) {
                BlockPos pointWorldOffset = worldOffset.add(bptOffset);
                SchematicBlockBase slot = blueprint.get(bptOffset);
                if (slot == null && !isLocationUsed(pointWorldOffset)) {
                    BuildingSlotBlock b = new BuildingSlotBlock();
                    b.schematic = null;
                    b.pos = pointWorldOffset;
                    b.mode = Mode.ClearIfInvalid;
                    b.buildStage = 0;
                    clearList.add(b);
                }
            }
        }
        for (BlockPos bptOffset : BlockPos.getAllInBox(bptMin, bptMax)) {
            BlockPos pointWorldOffset = worldOffset.add(bptOffset);
            SchematicBlockBase slot = blueprint.get(bptOffset);
            if (slot != null && !isLocationUsed(pointWorldOffset)) {
                BuildingSlotBlock b = new BuildingSlotBlock();
                b.schematic = slot;
                b.pos = pointWorldOffset;
                b.mode = Mode.Build;
                b.buildStage = 1;
                buildList.add(b);
            }
        }
    }
    iteratorBuild = new BuildingSlotIterator(buildList);
    iteratorClear = new BuildingSlotIterator(clearList);
}
Also used : SchematicBlockBase(buildcraft.api.blueprints.SchematicBlockBase) BuildingSlotBlock(buildcraft.core.builders.BuildingSlotBlock) BuildingSlotIterator(buildcraft.core.builders.BuildingSlotIterator) BlockPos(net.minecraft.util.math.BlockPos)

Aggregations

SchematicBlockBase (buildcraft.api.blueprints.SchematicBlockBase)1 BuildingSlotBlock (buildcraft.core.builders.BuildingSlotBlock)1 BuildingSlotIterator (buildcraft.core.builders.BuildingSlotIterator)1 BlockPos (net.minecraft.util.math.BlockPos)1