Search in sources :

Example 1 with IRedstoneDevice

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

the class GateTransceiver method propagate.

@Override
public Collection<Entry<IConnection<IRedstoneDevice>, Boolean>> propagate(ForgeDirection fromSide) {
    List<Entry<IConnection<IRedstoneDevice>, Boolean>> l = new ArrayList<Entry<IConnection<IRedstoneDevice>, Boolean>>();
    if (frequency == null)
        return l;
    l.add(new Pair<IConnection<IRedstoneDevice>, Boolean>(getRedstoneConnectionCache().getConnectionOnSide(fromSide), false));
    for (IWirelessDevice d : WirelessManager.COMMON_INSTANCE.getDevices()) {
        if (d != this && d.getFrequency() != null && d.getFrequency().equals(getFrequency())) {
            if (d instanceof GateTransceiver) {
                IConnection<IRedstoneDevice> c = ((GateTransceiver) d).getRedstoneConnectionCache().getConnectionOnSide(((GateTransceiver) d).front().getForgeDirection());
                if (c != null)
                    l.add(new Pair<IConnection<IRedstoneDevice>, Boolean>(c, false));
            }
        }
    }
    return l;
}
Also used : Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) IConnection(com.bluepowermod.api.connect.IConnection) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice) IWirelessDevice(com.bluepowermod.api.wireless.IWirelessDevice) Pair(uk.co.qmunity.lib.misc.Pair)

Example 2 with IRedstoneDevice

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

the class PneumaticTube method onRedstoneUpdate.

@Override
public void onRedstoneUpdate() {
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        IConnection<IRedstoneDevice> c = redConnections.getConnectionOnSide(dir);
        IRedstoneDevice dev = null;
        if (c != null)
            dev = c.getB();
        if (dev == null || dev instanceof DummyRedstoneDevice)
            RedstoneHelper.notifyRedstoneUpdate(getWorld(), getX(), getY(), getZ(), dir, false);
    }
    sendUpdatePacket();
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice) DummyRedstoneDevice(com.bluepowermod.redstone.DummyRedstoneDevice)

Example 3 with IRedstoneDevice

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

the class PartLamp method recalculatePower.

private void recalculatePower() {
    if (getWorld().isRemote)
        return;
    int old = power;
    int pow = 0;
    for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
        IConnection<IRedstoneDevice> con = connections.getConnectionOnSide(d);
        if (con != null) {
            pow = Math.max(pow, input[d.ordinal()] & 0xFF);
        } else {
            pow = Math.max(pow, MathHelper.map(RedstoneHelper.getInput(getWorld(), getX(), getY(), getZ(), d), 0, 15, 0, 255));
        }
    }
    power = (byte) pow;
    if (old != power)
        sendUpdatePacket();
}
Also used : ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice)

Example 4 with IRedstoneDevice

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

the class GateIntegratedCircuit method getDeviceOnSide.

@Override
public IRedstoneDevice getDeviceOnSide(ForgeDirection side) {
    side = new Vec3d(0, 0, 0).add(side).rotate(0, 90 * -getRotation(), 0).toForgeDirection();
    IPart p = getCircuitPartOnSide(side);
    if (p == null)
        return null;
    if (p instanceof IRedstoneDevice)
        return (IRedstoneDevice) p;
    return null;
}
Also used : IPart(uk.co.qmunity.lib.part.IPart) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice) Vec3d(uk.co.qmunity.lib.vec.Vec3d)

Example 5 with IRedstoneDevice

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

the class GateNullCell method writeUpdateData.

@Override
public void writeUpdateData(DataOutput buffer, int channel) throws IOException {
    super.writeUpdateData(buffer, channel);
    if (channel == -1) {
        buffer.writeBoolean(typeA != null);
        if (typeA != null) {
            buffer.writeInt(typeA.ordinal());
            buffer.writeBoolean(bundledA);
        }
        buffer.writeBoolean(typeB != null);
        if (typeB != null) {
            buffer.writeInt(typeB.ordinal());
            buffer.writeBoolean(bundledB);
        }
    }
    if (channel == 1 || channel == -1) {
        buffer.writeByte(powerA);
    }
    if (channel == 2 || channel == -1) {
        buffer.writeByte(powerB);
    }
    if (channel == 3 || channel == -1) {
        for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
            IConnection<IRedstoneDevice> c = redstoneConnections.getConnectionOnSide(d);
            buffer.writeBoolean(c != null && c.getB() instanceof GateNullCell && (getType(d) == 1 || ((BPPartFaceRotate) c.getB()).getRotation() % 2 == getRotation() % 2));
        }
    }
}
Also used : BPPartFaceRotate(com.bluepowermod.part.BPPartFaceRotate) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IRedstoneDevice(com.bluepowermod.api.wire.redstone.IRedstoneDevice)

Aggregations

IRedstoneDevice (com.bluepowermod.api.wire.redstone.IRedstoneDevice)7 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 IConnection (com.bluepowermod.api.connect.IConnection)2 IPart (uk.co.qmunity.lib.part.IPart)2 IConnectionCache (com.bluepowermod.api.connect.IConnectionCache)1 MinecraftColor (com.bluepowermod.api.misc.MinecraftColor)1 IInsulatedRedwire (com.bluepowermod.api.wire.redstone.IRedwire.IInsulatedRedwire)1 IWirelessDevice (com.bluepowermod.api.wireless.IWirelessDevice)1 BPPartFaceRotate (com.bluepowermod.part.BPPartFaceRotate)1 DummyRedstoneDevice (com.bluepowermod.redstone.DummyRedstoneDevice)1 ArrayList (java.util.ArrayList)1 Entry (java.util.Map.Entry)1 Pair (uk.co.qmunity.lib.misc.Pair)1 Vec3d (uk.co.qmunity.lib.vec.Vec3d)1