use of mcmultipart.multipart.ISlottedPart in project Charset by CharsetMC.
the class MultipartUtils method getInterfaceCenter.
public static <T> T getInterfaceCenter(Class<T> clazz, IMultipartContainer container) {
ISlottedPart part = container.getPartInSlot(PartSlot.CENTER);
if (part != null && clazz.isAssignableFrom(part.getClass())) {
return (T) part;
} else {
Iterator var4 = container.getParts().iterator();
IMultipart p;
do {
do {
if (!var4.hasNext()) {
return null;
}
p = (IMultipart) var4.next();
} while (p instanceof ISlottedPart && !((ISlottedPart) p).getSlotMask().isEmpty());
} while (p == null || !clazz.isAssignableFrom(p.getClass()));
return (T) p;
}
}
use of mcmultipart.multipart.ISlottedPart in project Charset by CharsetMC.
the class PartPipe method internalConnects.
private boolean internalConnects(EnumFacing side) {
ISlottedPart part = getContainer().getPartInSlot(PartSlot.getFaceSlot(side));
if (part instanceof IMicroblock.IFaceMicroblock) {
if (!((IMicroblock.IFaceMicroblock) part).isFaceHollow()) {
return false;
}
}
if (!OcclusionHelper.occlusionTest(getContainer().getParts(), this, BOXES[side.ordinal()])) {
return false;
}
if (PipeUtils.getPipe(getWorld(), getPos().offset(side), side.getOpposite()) != null) {
return true;
}
TileEntity tile = getNeighbourTile(side);
if (tile != null && tile.hasCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, side.getOpposite())) {
return true;
}
if (tile instanceof ISidedInventory || tile instanceof IInventory) {
return true;
}
if (tile != null && tile.hasCapability(ModCharsetPipes.CAP_SHIFTER, side.getOpposite())) {
return tile.getCapability(ModCharsetPipes.CAP_SHIFTER, side.getOpposite()).getMode() == IShifter.Mode.Extract;
}
return false;
}
use of mcmultipart.multipart.ISlottedPart in project Charset by CharsetMC.
the class PipeUtils method getPipe.
public static PartPipe getPipe(World world, BlockPos blockPos, EnumFacing side) {
IMultipartContainer container = MultipartHelper.getPartContainer(world, blockPos);
if (container == null) {
return null;
}
if (side != null) {
ISlottedPart part = container.getPartInSlot(PartSlot.getFaceSlot(side));
if (part instanceof IMicroblock.IFaceMicroblock && !((IMicroblock.IFaceMicroblock) part).isFaceHollow()) {
return null;
}
}
ISlottedPart part = container.getPartInSlot(PartSlot.CENTER);
if (part instanceof PartPipe) {
return (PartPipe) part;
} else {
return null;
}
}
Aggregations