Search in sources :

Example 1 with IRedwire

use of com.bluepowermod.api.wire.redstone.IRedwire in project BluePower by Qmunity.

the class GateNullCell method canConnect.

@Override
public boolean canConnect(ForgeDirection side, IRedstoneDevice device, ConnectionType type) {
    if (type == ConnectionType.OPEN_CORNER && device instanceof IGate<?, ?, ?, ?, ?, ?>)
        return false;
    if (type == ConnectionType.STRAIGHT)
        if ((side == getFace().getOpposite() || side == ForgeDirection.UNKNOWN) && device instanceof DummyRedstoneDevice)
            return false;
    if (type == ConnectionType.CLOSED_CORNER) {
        if (side == getFace())
            return false;
        if (side == getFace().getOpposite())
            return false;
        if (side == ForgeDirection.UNKNOWN)
            return false;
    }
    if (device instanceof IRedwire) {
        RedwireType rwt = getRedwireType(side);
        if (rwt == null)
            return false;
        RedwireType rwt_ = ((IRedwire) device).getRedwireType(type == ConnectionType.STRAIGHT ? side.getOpposite() : (type == ConnectionType.CLOSED_CORNER ? getFace() : getFace().getOpposite()));
        if (rwt_ == null)
            return false;
        return rwt.canConnectTo(rwt_);
    }
    return true;
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) IRedwire(com.bluepowermod.api.wire.redstone.IRedwire) DummyRedstoneDevice(com.bluepowermod.redstone.DummyRedstoneDevice)

Example 2 with IRedwire

use of com.bluepowermod.api.wire.redstone.IRedwire in project BluePower by Qmunity.

the class PneumaticTube method canConnect.

@Override
public boolean canConnect(ForgeDirection side, IRedstoneDevice device, ConnectionType type) {
    if (type == ConnectionType.STRAIGHT) {
        if (getRedwireType(side) == null)
            return false;
        if (device instanceof IRedwire) {
            RedwireType rwt = getRedwireType(side);
            if (type == null)
                return false;
            RedwireType rwt_ = ((IRedwire) device).getRedwireType(type == ConnectionType.STRAIGHT ? side.getOpposite() : side.getOpposite());
            if (rwt_ == null)
                return false;
            if (!rwt.canConnectTo(rwt_))
                return false;
        }
        if (device instanceof IFace)
            return ((IFace) device).getFace() == side.getOpposite();
        if (!OcclusionHelper.microblockOcclusionTest(new Vec3i(this), MicroblockShape.FACE_HOLLOW, 8, side))
            return false;
        if (device instanceof PneumaticTube)
            if (device instanceof MagTube != this instanceof MagTube)
                return false;
        return true;
    }
    return false;
}
Also used : RedwireType(com.bluepowermod.api.wire.redstone.RedwireType) Vec3i(uk.co.qmunity.lib.vec.Vec3i) IFace(com.bluepowermod.api.misc.IFace) IRedwire(com.bluepowermod.api.wire.redstone.IRedwire)

Aggregations

IRedwire (com.bluepowermod.api.wire.redstone.IRedwire)2 RedwireType (com.bluepowermod.api.wire.redstone.RedwireType)2 IFace (com.bluepowermod.api.misc.IFace)1 DummyRedstoneDevice (com.bluepowermod.redstone.DummyRedstoneDevice)1 Vec3i (uk.co.qmunity.lib.vec.Vec3i)1