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