Search in sources :

Example 1 with Header

use of buildcraft.builders.snapshot.Snapshot.Header in project BuildCraft by BuildCraft.

the class TileReplacer method update.

@Override
public void update() {
    if (world.isRemote) {
        return;
    }
    if (!invSnapshot.getStackInSlot(0).isEmpty() && !invSchematicFrom.getStackInSlot(0).isEmpty() && !invSchematicTo.getStackInSlot(0).isEmpty()) {
        Header header = BCBuildersItems.snapshot.getHeader(invSnapshot.getStackInSlot(0));
        if (header != null) {
            Snapshot snapshot = GlobalSavedDataSnapshots.get(world).getSnapshot(header.key);
            if (snapshot instanceof Blueprint) {
                Blueprint blueprint = (Blueprint) snapshot;
                try {
                    ISchematicBlock from = SchematicBlockManager.readFromNBT(NBTUtilBC.getItemData(invSchematicFrom.getStackInSlot(0)).getCompoundTag(ItemSchematicSingle.NBT_KEY));
                    ISchematicBlock to = SchematicBlockManager.readFromNBT(NBTUtilBC.getItemData(invSchematicTo.getStackInSlot(0)).getCompoundTag(ItemSchematicSingle.NBT_KEY));
                    Blueprint newBlueprint = blueprint.copy();
                    newBlueprint.replace(from, to);
                    newBlueprint.computeKey();
                    GlobalSavedDataSnapshots.get(world).addSnapshot(newBlueprint);
                    invSnapshot.setStackInSlot(0, BCBuildersItems.snapshot.getUsed(EnumSnapshotType.BLUEPRINT, new Header(blueprint.key, getOwner().getId(), new Date(), header.name)));
                    invSchematicFrom.setStackInSlot(0, ItemStack.EMPTY);
                    invSchematicTo.setStackInSlot(0, ItemStack.EMPTY);
                } catch (InvalidInputDataException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
Also used : ISchematicBlock(buildcraft.api.schematics.ISchematicBlock) ItemSnapshot(buildcraft.builders.item.ItemSnapshot) Snapshot(buildcraft.builders.snapshot.Snapshot) InvalidInputDataException(buildcraft.api.core.InvalidInputDataException) Header(buildcraft.builders.snapshot.Snapshot.Header) Blueprint(buildcraft.builders.snapshot.Blueprint) Date(java.util.Date)

Example 2 with Header

use of buildcraft.builders.snapshot.Snapshot.Header in project BuildCraft by BuildCraft.

the class GuiElectronicLibrary method drawBackgroundLayer.

@Override
protected void drawBackgroundLayer(float partialTicks) {
    ICON_GUI.drawAt(mainGui.rootElement);
    drawProgress(RECT_PROGRESS_DOWN, ICON_PROGRESS_DOWN, -container.tile.deltaProgressDown.getDynamic(partialTicks), 1);
    drawProgress(RECT_PROGRESS_UP, ICON_PROGRESS_UP, container.tile.deltaProgressUp.getDynamic(partialTicks), 1);
    iterateSnapshots((i, rect, key) -> {
        boolean isSelected = key.equals(container.tile.selected);
        if (isSelected) {
            drawGradientRect(rect, 0xFF_55_55_55, 0xFF_55_55_55);
        }
        int colour = isSelected ? 0xffffa0 : 0xe0e0e0;
        Header header = key.header;
        String text = header == null ? key.toString() : header.name;
        drawString(fontRenderer, text, rect.x, rect.y, colour);
    });
    delButton.enabled = getSnapshots().getSnapshot(container.tile.selected) != null;
}
Also used : Header(buildcraft.builders.snapshot.Snapshot.Header)

Example 3 with Header

use of buildcraft.builders.snapshot.Snapshot.Header in project BuildCraft by BuildCraft.

the class ItemSnapshot method addInformation.

@SideOnly(Side.CLIENT)
@Override
public void addInformation(ItemStack stack, World world, List<String> tooltip, ITooltipFlag flag) {
    Snapshot.Header header = getHeader(stack);
    if (header == null) {
        tooltip.add(LocaleUtil.localize("item.blueprint.blank"));
    } else {
        tooltip.add(header.name);
        EntityPlayer owner = header.getOwnerPlayer(world);
        if (owner != null) {
            tooltip.add(LocaleUtil.localize("item.blueprint.author") + " " + owner.getName());
        }
        if (flag.isAdvanced()) {
            tooltip.add("Hash: " + HashUtil.convertHashToString(header.key.hash));
            tooltip.add("Date: " + header.created);
            tooltip.add("Owner UUID: " + header.owner);
        }
    }
}
Also used : Snapshot(buildcraft.builders.snapshot.Snapshot) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Header(buildcraft.builders.snapshot.Snapshot.Header) SideOnly(net.minecraftforge.fml.relauncher.SideOnly)

Example 4 with Header

use of buildcraft.builders.snapshot.Snapshot.Header in project BuildCraft by BuildCraft.

the class TileArchitectTable method finishScanning.

private void finishScanning() {
    IBlockState thisState = getCurrentStateForBlock(BCBuildersBlocks.architect);
    if (thisState == null) {
        return;
    }
    EnumFacing facing = thisState.getValue(BlockArchitectTable.PROP_FACING);
    Snapshot snapshot = Snapshot.create(snapshotType);
    snapshot.size = box.size();
    snapshot.facing = facing;
    snapshot.offset = box.min().subtract(pos.offset(facing.getOpposite()));
    if (snapshot instanceof Template) {
        ((Template) snapshot).data = templateScannedBlocks;
    }
    if (snapshot instanceof Blueprint) {
        ((Blueprint) snapshot).palette.addAll(blueprintScannedPalette);
        ((Blueprint) snapshot).data = blueprintScannedData;
        ((Blueprint) snapshot).entities.addAll(blueprintScannedEntities);
    }
    snapshot.computeKey();
    GlobalSavedDataSnapshots.get(world).addSnapshot(snapshot);
    ItemStack stackIn = invSnapshotIn.getStackInSlot(0);
    stackIn.setCount(stackIn.getCount() - 1);
    if (stackIn.getCount() == 0) {
        stackIn = ItemStack.EMPTY;
    }
    invSnapshotIn.setStackInSlot(0, stackIn);
    invSnapshotOut.setStackInSlot(0, BCBuildersItems.snapshot.getUsed(snapshotType, new Header(snapshot.key, getOwner().getId(), new Date(), name)));
    templateScannedBlocks = null;
    blueprintScannedData = null;
    blueprintScannedEntities.clear();
    boxIterator = null;
    sendNetworkUpdate(NET_RENDER_DATA);
    AdvancementUtil.unlockAdvancement(getOwner().getId(), ADVANCEMENT);
}
Also used : ItemSnapshot(buildcraft.builders.item.ItemSnapshot) Snapshot(buildcraft.builders.snapshot.Snapshot) IBlockState(net.minecraft.block.state.IBlockState) Header(buildcraft.builders.snapshot.Snapshot.Header) Blueprint(buildcraft.builders.snapshot.Blueprint) EnumFacing(net.minecraft.util.EnumFacing) ItemStack(net.minecraft.item.ItemStack) Date(java.util.Date) Template(buildcraft.builders.snapshot.Template)

Aggregations

Header (buildcraft.builders.snapshot.Snapshot.Header)4 Snapshot (buildcraft.builders.snapshot.Snapshot)3 ItemSnapshot (buildcraft.builders.item.ItemSnapshot)2 Blueprint (buildcraft.builders.snapshot.Blueprint)2 Date (java.util.Date)2 InvalidInputDataException (buildcraft.api.core.InvalidInputDataException)1 ISchematicBlock (buildcraft.api.schematics.ISchematicBlock)1 Template (buildcraft.builders.snapshot.Template)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 ItemStack (net.minecraft.item.ItemStack)1 EnumFacing (net.minecraft.util.EnumFacing)1 SideOnly (net.minecraftforge.fml.relauncher.SideOnly)1