Search in sources :

Example 1 with BlueprintBase

use of buildcraft.core.blueprints.BlueprintBase in project BuildCraft by BuildCraft.

the class ItemBlueprint method loadBlueprint.

public static BlueprintBase loadBlueprint(ItemStack stack) {
    if (stack == null || stack.getItem() == null || !(stack.getItem() instanceof IBlueprintItem)) {
        return null;
    }
    LibraryId id = getId(stack);
    if (id == null) {
        return null;
    }
    NBTTagCompound nbt = BuildCraftBuilders.serverDB.load(id);
    BlueprintBase base;
    if (((IBlueprintItem) stack.getItem()).getType(stack) == EnumBlueprintType.TEMPLATE) {
        base = new Template();
    } else {
        base = new Blueprint();
    }
    base.readFromNBT(nbt);
    base.id = id;
    return base;
}
Also used : BlueprintBase(buildcraft.core.blueprints.BlueprintBase) LibraryId(buildcraft.core.blueprints.LibraryId) Blueprint(buildcraft.core.blueprints.Blueprint) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) IBlueprintItem(buildcraft.api.items.IBlueprintItem) Template(buildcraft.core.blueprints.Template)

Example 2 with BlueprintBase

use of buildcraft.core.blueprints.BlueprintBase in project BuildCraft by BuildCraft.

the class LibraryBlueprintTypeHandler method load.

@Override
public ItemStack load(ItemStack stack, NBTTagCompound compound) {
    BlueprintBase blueprint = BlueprintBase.loadBluePrint((NBTTagCompound) compound.copy());
    blueprint.id.name = compound.getString("__filename");
    blueprint.id.extension = getOutputExtension();
    BuildCraftBuilders.serverDB.add(blueprint.id, compound);
    return blueprint.getStack();
}
Also used : BlueprintBase(buildcraft.core.blueprints.BlueprintBase)

Example 3 with BlueprintBase

use of buildcraft.core.blueprints.BlueprintBase in project BuildCraft by BuildCraft.

the class RecursiveBlueprintReader method iterate.

public void iterate() {
    if (done) {
        return;
    } else if (currentSubReader == null && subIndex < architect.subBlueprints.size()) {
        BlockPos subBlock = architect.subBlueprints.get(subIndex);
        TileEntity subTile = architect.getWorld().getTileEntity(subBlock);
        if (subTile instanceof TileArchitect) {
            TileArchitect subArchitect = (TileArchitect) subTile;
            currentSubReader = new RecursiveBlueprintReader(subArchitect, writingBlueprint);
        } else if (subTile instanceof TileConstructionMarker || subTile instanceof TileBuilder) {
            BlueprintBase blueprint = null;
            EnumFacing orientation = EnumFacing.EAST;
            if (subTile instanceof TileConstructionMarker) {
                TileConstructionMarker marker = (TileConstructionMarker) subTile;
                blueprint = ItemBlueprint.loadBlueprint(marker.itemBlueprint);
                orientation = marker.direction;
            } else if (subTile instanceof TileBuilder) {
                TileBuilder builder = (TileBuilder) subTile;
                blueprint = ItemBlueprint.loadBlueprint(builder.getStackInSlot(0));
                orientation = architect.getWorld().getBlockState(subBlock).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
            }
            if (blueprint != null) {
                BlockPos nPos = subTile.getPos().subtract(architect.getBox().min());
                writingBlueprint.addSubBlueprint(blueprint, nPos, orientation);
            }
            subIndex++;
        } else {
            subIndex++;
        }
    } else if (currentSubReader != null) {
        currentSubReader.iterate();
        World world = currentSubReader.architect.getWorld();
        EnumFacing facing = world.getBlockState(currentSubReader.architect.getPos()).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
        BlockPos pos = currentSubReader.architect.getPos().subtract(architect.getBox().min());
        if (currentSubReader.isDone()) {
            writingBlueprint.addSubBlueprint(currentSubReader.getBlueprint(), pos, facing);
            currentSubReader = null;
            subIndex++;
        }
    } else if (blockScanner != null && blockScanner.blocksLeft() != 0) {
        for (BlockPos index : blockScanner) {
            writingBlueprint.readFromWorld(writingContext, architect, index);
        }
        computingTime = 1 - (float) blockScanner.blocksLeft() / (float) blockScanner.totalBlocks();
        if (blockScanner.blocksLeft() == 0) {
            writingBlueprint.readEntitiesFromWorld(writingContext, architect);
            Vec3d transform = Utils.VEC_ZERO.subtract(Utils.convert(writingContext.surroundingBox().min()));
            writingBlueprint.translateToBlueprint(transform);
            EnumFacing o = architect.getWorld().getBlockState(architect.getPos()).getValue(BuildCraftProperties.BLOCK_FACING).getOpposite();
            writingBlueprint.rotate = architect.readConfiguration.rotate;
            writingBlueprint.excavate = architect.readConfiguration.excavate;
            if (writingBlueprint.rotate) {
                if (o == EnumFacing.EAST) {
                // Do nothing
                } else if (o == EnumFacing.SOUTH) {
                    writingBlueprint.rotateLeft(writingContext);
                    writingBlueprint.rotateLeft(writingContext);
                    writingBlueprint.rotateLeft(writingContext);
                } else if (o == EnumFacing.WEST) {
                    writingBlueprint.rotateLeft(writingContext);
                    writingBlueprint.rotateLeft(writingContext);
                } else if (o == EnumFacing.NORTH) {
                    writingBlueprint.rotateLeft(writingContext);
                }
            }
        }
    } else if (blockScanner != null) {
        createBlueprint();
        done = true;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BlueprintBase(buildcraft.core.blueprints.BlueprintBase) TileBuilder(buildcraft.builders.TileBuilder) TileArchitect(buildcraft.builders.TileArchitect) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) World(net.minecraft.world.World) TileConstructionMarker(buildcraft.builders.TileConstructionMarker) Vec3d(net.minecraft.util.math.Vec3d)

Example 4 with BlueprintBase

use of buildcraft.core.blueprints.BlueprintBase in project BuildCraft by BuildCraft.

the class TileConstructionMarker method update.

@Override
public void update() {
    super.update();
    BuildingItem toRemove = null;
    for (BuildingItem i : buildersInAction) {
        i.update();
        if (i.isDone) {
            toRemove = i;
        }
    }
    if (toRemove != null) {
        buildersInAction.remove(toRemove);
    }
    if (worldObj.isRemote) {
        return;
    }
    if (itemBlueprint != null && ItemBlueprint.getId(itemBlueprint) != null && bluePrintBuilder == null) {
        BlueprintBase bpt = ItemBlueprint.loadBlueprint(itemBlueprint);
        if (bpt != null && bpt instanceof Blueprint) {
            bpt = bpt.adjustToWorld(worldObj, pos, direction);
            if (bpt != null) {
                bluePrintBuilder = new BptBuilderBlueprint((Blueprint) bpt, worldObj, pos);
                bptContext = bluePrintBuilder.getContext();
                box.initialize(bluePrintBuilder);
                sendNetworkUpdate();
            }
        } else {
            return;
        }
    }
    if (laser == null && direction != null) {
        Vec3d point5 = new Vec3d(0.5, 0.5, 0.5);
        laser = new LaserData();
        laser.head = Utils.convert(pos).add(point5);
        laser.tail = laser.head.add(Utils.convert(direction, 0.5));
        laser.isVisible = true;
        sendNetworkUpdate();
    }
    if (initNBT != null) {
        if (bluePrintBuilder != null) {
            bluePrintBuilder.loadBuildStateToNBT(initNBT.getCompoundTag("builderState"), this);
        }
        initNBT = null;
    }
}
Also used : BuildingItem(buildcraft.core.builders.BuildingItem) BlueprintBase(buildcraft.core.blueprints.BlueprintBase) Blueprint(buildcraft.core.blueprints.Blueprint) BptBuilderBlueprint(buildcraft.core.blueprints.BptBuilderBlueprint) LaserData(buildcraft.core.LaserData) BptBuilderBlueprint(buildcraft.core.blueprints.BptBuilderBlueprint) Vec3d(net.minecraft.util.math.Vec3d)

Example 5 with BlueprintBase

use of buildcraft.core.blueprints.BlueprintBase in project BuildCraft by BuildCraft.

the class TileBuilder method instanciateBluePrintBuilder.

@Deprecated
public BptBuilderBase instanciateBluePrintBuilder(BlockPos pos, EnumFacing o) {
    BlueprintBase bpt = instanciateBlueprint();
    if (bpt == null) {
        return null;
    }
    bpt = bpt.adjustToWorld(worldObj, pos, o);
    if (bpt != null) {
        if (getStackInSlot(0).getItem() instanceof ItemBlueprintStandard) {
            return new BptBuilderBlueprint((Blueprint) bpt, worldObj, pos);
        } else if (getStackInSlot(0).getItem() instanceof ItemBlueprintTemplate) {
            return new BptBuilderTemplate(bpt, worldObj, pos);
        }
    }
    return null;
}
Also used : BlueprintBase(buildcraft.core.blueprints.BlueprintBase) BptBuilderBlueprint(buildcraft.core.blueprints.BptBuilderBlueprint) BptBuilderTemplate(buildcraft.core.blueprints.BptBuilderTemplate)

Aggregations

BlueprintBase (buildcraft.core.blueprints.BlueprintBase)7 Blueprint (buildcraft.core.blueprints.Blueprint)4 BptBuilderBlueprint (buildcraft.core.blueprints.BptBuilderBlueprint)4 EnumFacing (net.minecraft.util.EnumFacing)3 BlockPos (net.minecraft.util.math.BlockPos)3 BptBuilderTemplate (buildcraft.core.blueprints.BptBuilderTemplate)2 Template (buildcraft.core.blueprints.Template)2 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)2 Vec3d (net.minecraft.util.math.Vec3d)2 IBlueprintItem (buildcraft.api.items.IBlueprintItem)1 TileArchitect (buildcraft.builders.TileArchitect)1 TileBuilder (buildcraft.builders.TileBuilder)1 TileConstructionMarker (buildcraft.builders.TileConstructionMarker)1 RecursiveBlueprintBuilder (buildcraft.builders.blueprints.RecursiveBlueprintBuilder)1 LaserData (buildcraft.core.LaserData)1 BptBuilderBase (buildcraft.core.blueprints.BptBuilderBase)1 LibraryId (buildcraft.core.blueprints.LibraryId)1 BuildingItem (buildcraft.core.builders.BuildingItem)1 TileEntity (net.minecraft.tileentity.TileEntity)1 World (net.minecraft.world.World)1