use of buildcraft.builders.snapshot.Template in project BuildCraft by BuildCraft.
the class TileBuilder method updateSnapshot.
private void updateSnapshot(boolean canGetFacing) {
Optional.ofNullable(getBuilder()).ifPresent(SnapshotBuilder::cancel);
if (snapshot != null && getCurrentBasePos() != null) {
snapshotType = snapshot.getType();
if (canGetFacing) {
rotation = Arrays.stream(Rotation.values()).filter(r -> r.rotate(snapshot.facing) == world.getBlockState(pos).getValue(BlockBCBase_Neptune.PROP_FACING)).findFirst().orElse(null);
}
if (snapshot.getType() == EnumSnapshotType.TEMPLATE) {
templateBuildingInfo = ((Template) snapshot).new BuildingInfo(getCurrentBasePos(), rotation);
}
if (snapshot.getType() == EnumSnapshotType.BLUEPRINT) {
blueprintBuildingInfo = ((Blueprint) snapshot).new BuildingInfo(getCurrentBasePos(), rotation);
}
currentBox = Optional.ofNullable(getBuildingInfo()).map(buildingInfo -> buildingInfo.box).orElse(null);
Optional.ofNullable(getBuilder()).ifPresent(SnapshotBuilder::updateSnapshot);
} else {
snapshotType = null;
rotation = null;
templateBuildingInfo = null;
blueprintBuildingInfo = null;
currentBox = null;
}
if (currentBox == null) {
currentBox = new Box();
}
}
use of buildcraft.builders.snapshot.Template 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);
}
use of buildcraft.builders.snapshot.Template in project BuildCraft by BuildCraft.
the class ShapePatternsTester method createFilledTemplate.
private IFilledTemplate createFilledTemplate(BlockPos size) {
Template template = new Template();
template.size = size;
template.offset = BlockPos.ORIGIN;
template.data = new BitSet(Snapshot.getDataSize(size));
return template.getFilledTemplate();
}
Aggregations