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();
}
}
}
}
}
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;
}
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);
}
}
}
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);
}
Aggregations