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