Search in sources :

Example 26 with CoverBehavior

use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.

the class BlockPipe method getPickBlock.

@Override
public ItemStack getPickBlock(IBlockState state, RayTraceResult target, World world, BlockPos pos, EntityPlayer player) {
    IPipeTile<PipeType, NodeDataType> pipeTile = getPipeTileEntity(world, pos);
    if (pipeTile == null) {
        return ItemStack.EMPTY;
    }
    if (target instanceof CuboidRayTraceResult) {
        CuboidRayTraceResult result = (CuboidRayTraceResult) target;
        if (result.cuboid6.data instanceof CoverSideData) {
            EnumFacing coverSide = ((CoverSideData) result.cuboid6.data).side;
            CoverBehavior coverBehavior = pipeTile.getCoverableImplementation().getCoverAtSide(coverSide);
            return coverBehavior == null ? ItemStack.EMPTY : coverBehavior.getPickItem();
        }
    }
    return getDropItem(pipeTile);
}
Also used : CuboidRayTraceResult(codechicken.lib.raytracer.CuboidRayTraceResult) CoverSideData(gregtech.api.cover.ICoverable.CoverSideData) CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 27 with CoverBehavior

use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.

the class BlockPipe method getActualConnections.

/**
 * Returns bit mask of actual cable connections, including cable-cable and cable-receiver
 * connections. but excluding unaccessible covers on blocked sides
 */
public int getActualConnections(IPipeTile<PipeType, NodeDataType> selfTile, IBlockAccess world) {
    int connectedSidesMask = 0;
    int activeNodeConnections = getActiveVisualConnections(selfTile);
    for (EnumFacing side : EnumFacing.VALUES) {
        CoverBehavior coverBehavior = selfTile.getCoverableImplementation().getCoverAtSide(side);
        if (coverBehavior != null && coverBehavior.shouldRenderConnected()) {
            connectedSidesMask |= 1 << side.getIndex();
        }
        if ((selfTile.getBlockedConnections() & (1 << side.getIndex())) > 0)
            // do not check blocked connection sides
            continue;
        int cableState = isPipeAccessibleAtSide(world, selfTile, side);
        if (cableState >= 2) {
            connectedSidesMask |= 1 << side.getIndex();
            if (cableState >= 3) {
                connectedSidesMask |= 1 << (6 + side.getIndex());
            }
        } else if ((activeNodeConnections & 1 << side.getIndex()) > 0) {
            connectedSidesMask |= 1 << side.getIndex();
            // always render back face for active machine connections
            connectedSidesMask |= 1 << (6 + side.getIndex());
        }
    }
    return connectedSidesMask;
}
Also used : CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 28 with CoverBehavior

use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.

the class PipeCoverableImplementation method removeCover.

public final boolean removeCover(EnumFacing side) {
    Preconditions.checkNotNull(side, "side");
    CoverBehavior coverBehavior = getCoverAtSide(side);
    if (coverBehavior == null) {
        return false;
    }
    List<ItemStack> drops = coverBehavior.getDrops();
    coverBehavior.onRemoved();
    this.coverBehaviors[side.getIndex()] = null;
    for (ItemStack dropStack : drops) {
        Block.spawnAsEntity(getWorld(), getPos(), dropStack);
    }
    writeCustomData(2, buffer -> buffer.writeByte(side.getIndex()));
    holder.setConnectionBlocked(AttachmentType.COVER, side, false);
    holder.notifyBlockUpdate();
    holder.markAsDirty();
    return true;
}
Also used : ItemStack(net.minecraft.item.ItemStack) CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 29 with CoverBehavior

use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.

the class PipeCoverableImplementation method writeInitialSyncData.

public void writeInitialSyncData(PacketBuffer buf) {
    for (EnumFacing coverSide : EnumFacing.VALUES) {
        CoverBehavior coverBehavior = getCoverAtSide(coverSide);
        if (coverBehavior != null) {
            int coverId = CoverDefinition.getNetworkIdForCover(coverBehavior.getCoverDefinition());
            buf.writeVarInt(coverId);
            coverBehavior.writeInitialSyncData(buf);
        } else {
            buf.writeVarInt(-1);
        }
    }
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) CoverBehavior(gregtech.api.cover.CoverBehavior)

Example 30 with CoverBehavior

use of gregtech.api.cover.CoverBehavior in project GregTech by GregTechCE.

the class PipeCoverableImplementation method getHighestOutputRedstoneSignal.

public int getHighestOutputRedstoneSignal() {
    int highestSignal = 0;
    for (EnumFacing side : EnumFacing.VALUES) {
        CoverBehavior behavior = getCoverAtSide(side);
        highestSignal = Math.max(highestSignal, behavior.getRedstoneSignalOutput());
    }
    return highestSignal;
}
Also used : EnumFacing(net.minecraft.util.EnumFacing) CoverBehavior(gregtech.api.cover.CoverBehavior)

Aggregations

CoverBehavior (gregtech.api.cover.CoverBehavior)32 EnumFacing (net.minecraft.util.EnumFacing)10 ItemStack (net.minecraft.item.ItemStack)6 CoverDefinition (gregtech.api.cover.CoverDefinition)5 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)5 NBTTagList (net.minecraft.nbt.NBTTagList)4 CuboidRayTraceResult (codechicken.lib.raytracer.CuboidRayTraceResult)2 CoverSideData (gregtech.api.cover.ICoverable.CoverSideData)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 NBT (net.minecraftforge.common.util.Constants.NBT)2 IndexedCuboid6 (codechicken.lib.raytracer.IndexedCuboid6)1 IScrewdriverItem (gregtech.api.capability.tool.IScrewdriverItem)1 IWrenchItem (gregtech.api.capability.tool.IWrenchItem)1 Nullable (javax.annotation.Nullable)1 ITickable (net.minecraft.util.ITickable)1