Search in sources :

Example 1 with Template

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();
    }
}
Also used : EnumAccess(buildcraft.lib.tile.item.ItemHandlerManager.EnumAccess) Blueprint(buildcraft.builders.snapshot.Blueprint) Arrays(java.util.Arrays) ItemSnapshot(buildcraft.builders.item.ItemSnapshot) Snapshot(buildcraft.builders.snapshot.Snapshot) ItemHandlerSimple(buildcraft.lib.tile.item.ItemHandlerSimple) IPathProvider(buildcraft.api.core.IPathProvider) Side(net.minecraftforge.fml.relauncher.Side) MessageUtil(buildcraft.lib.misc.MessageUtil) Fluid(net.minecraftforge.fluids.Fluid) IItemHandlerModifiable(net.minecraftforge.items.IItemHandlerModifiable) Template(buildcraft.builders.snapshot.Template) TankManager(buildcraft.lib.fluid.TankManager) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) PacketBufferBC(buildcraft.lib.net.PacketBufferBC) EnumSnapshotType(buildcraft.api.enums.EnumSnapshotType) BCBuildersItems(buildcraft.builders.BCBuildersItems) TileBC_Neptune(buildcraft.lib.tile.TileBC_Neptune) EnumOptionalSnapshotType(buildcraft.api.enums.EnumOptionalSnapshotType) Collectors(java.util.stream.Collectors) List(java.util.List) BlockBCBase_Neptune(buildcraft.lib.block.BlockBCBase_Neptune) MessageContext(net.minecraftforge.fml.common.network.simpleimpl.MessageContext) MjBattery(buildcraft.api.mj.MjBattery) Optional(java.util.Optional) NBTUtil(net.minecraft.nbt.NBTUtil) MjAPI(buildcraft.api.mj.MjAPI) EnumPipePart(buildcraft.api.core.EnumPipePart) Box(buildcraft.lib.misc.data.Box) TemplateBuilder(buildcraft.builders.snapshot.TemplateBuilder) PositionUtil(buildcraft.lib.misc.PositionUtil) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) ITileForTemplateBuilder(buildcraft.builders.snapshot.ITileForTemplateBuilder) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) NBTUtilBC(buildcraft.lib.misc.NBTUtilBC) MjBatteryReceiver(buildcraft.lib.mj.MjBatteryReceiver) BoundingBoxUtil(buildcraft.lib.misc.BoundingBoxUtil) ImmutableList(com.google.common.collect.ImmutableList) ITickable(net.minecraft.util.ITickable) CapUtil(buildcraft.lib.misc.CapUtil) MessageManager(buildcraft.lib.net.MessageManager) SideOnly(net.minecraftforge.fml.relauncher.SideOnly) Nonnull(javax.annotation.Nonnull) IdAllocator(buildcraft.lib.misc.data.IdAllocator) World(net.minecraft.world.World) IDebuggable(buildcraft.api.tiles.IDebuggable) EnumFacing(net.minecraft.util.EnumFacing) MjCapabilityHelper(buildcraft.api.mj.MjCapabilityHelper) IOException(java.io.IOException) BlockPos(net.minecraft.util.math.BlockPos) BlueprintBuilder(buildcraft.builders.snapshot.BlueprintBuilder) Tank(buildcraft.lib.fluid.Tank) EntityLivingBase(net.minecraft.entity.EntityLivingBase) GlobalSavedDataSnapshots(buildcraft.builders.snapshot.GlobalSavedDataSnapshots) Rotation(net.minecraft.util.Rotation) ResourceLocation(net.minecraft.util.ResourceLocation) ITileForBlueprintBuilder(buildcraft.builders.snapshot.ITileForBlueprintBuilder) TileEntity(net.minecraft.tileentity.TileEntity) SnapshotBuilder(buildcraft.builders.snapshot.SnapshotBuilder) AdvancementUtil(buildcraft.lib.misc.AdvancementUtil) IItemTransactor(buildcraft.api.inventory.IItemTransactor) SnapshotBuilder(buildcraft.builders.snapshot.SnapshotBuilder) Box(buildcraft.lib.misc.data.Box)

Example 2 with Template

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

Example 3 with Template

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();
}
Also used : BitSet(java.util.BitSet) Template(buildcraft.builders.snapshot.Template) IFilledTemplate(buildcraft.api.filler.IFilledTemplate)

Aggregations

Template (buildcraft.builders.snapshot.Template)3 ItemSnapshot (buildcraft.builders.item.ItemSnapshot)2 Blueprint (buildcraft.builders.snapshot.Blueprint)2 Snapshot (buildcraft.builders.snapshot.Snapshot)2 ItemStack (net.minecraft.item.ItemStack)2 EnumFacing (net.minecraft.util.EnumFacing)2 EnumPipePart (buildcraft.api.core.EnumPipePart)1 IPathProvider (buildcraft.api.core.IPathProvider)1 EnumOptionalSnapshotType (buildcraft.api.enums.EnumOptionalSnapshotType)1 EnumSnapshotType (buildcraft.api.enums.EnumSnapshotType)1 IFilledTemplate (buildcraft.api.filler.IFilledTemplate)1 IItemTransactor (buildcraft.api.inventory.IItemTransactor)1 MjAPI (buildcraft.api.mj.MjAPI)1 MjBattery (buildcraft.api.mj.MjBattery)1 MjCapabilityHelper (buildcraft.api.mj.MjCapabilityHelper)1 IDebuggable (buildcraft.api.tiles.IDebuggable)1 BCBuildersItems (buildcraft.builders.BCBuildersItems)1 BlueprintBuilder (buildcraft.builders.snapshot.BlueprintBuilder)1 GlobalSavedDataSnapshots (buildcraft.builders.snapshot.GlobalSavedDataSnapshots)1 ITileForBlueprintBuilder (buildcraft.builders.snapshot.ITileForBlueprintBuilder)1