Search in sources :

Example 1 with ISlottedPart

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;
    }
}
Also used : Iterator(java.util.Iterator) IMultipart(mcmultipart.multipart.IMultipart) ISlottedPart(mcmultipart.multipart.ISlottedPart)

Example 2 with ISlottedPart

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;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ISidedInventory(net.minecraft.inventory.ISidedInventory) IInventory(net.minecraft.inventory.IInventory) IMicroblock(mcmultipart.microblock.IMicroblock) ISlottedPart(mcmultipart.multipart.ISlottedPart)

Example 3 with ISlottedPart

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;
    }
}
Also used : IMultipartContainer(mcmultipart.multipart.IMultipartContainer) IMicroblock(mcmultipart.microblock.IMicroblock) ISlottedPart(mcmultipart.multipart.ISlottedPart)

Aggregations

ISlottedPart (mcmultipart.multipart.ISlottedPart)3 IMicroblock (mcmultipart.microblock.IMicroblock)2 Iterator (java.util.Iterator)1 IMultipart (mcmultipart.multipart.IMultipart)1 IMultipartContainer (mcmultipart.multipart.IMultipartContainer)1 IInventory (net.minecraft.inventory.IInventory)1 ISidedInventory (net.minecraft.inventory.ISidedInventory)1 TileEntity (net.minecraft.tileentity.TileEntity)1