use of com.bluepowermod.api.wire.redstone.IRedstoneDevice in project BluePower by Qmunity.
the class BundledPropagator method propagate.
@Override
public void propagate() {
if ((device instanceof IPart && ((IPart) device).getParent() == null) || device.getWorld() == null)
return;
for (MinecraftColor c : MinecraftColor.VALID_COLORS) {
IRedstoneDevice dev;
if (device instanceof IInsulatedRedwire) {
dev = (IRedstoneDevice) device;
} else {
dev = BundledDeviceWrapper.wrap(device, c);
}
if (dev == null)
continue;
RedstoneApi.getInstance().getRedstonePropagator(dev, side).propagate();
}
}
use of com.bluepowermod.api.wire.redstone.IRedstoneDevice in project BluePower by Qmunity.
the class RedstoneConnectionCache method recalculateConnections.
@SuppressWarnings("unchecked")
@Override
public void recalculateConnections() {
if (dev.getWorld().isRemote)
return;
IRedstoneDevice self = getSelf();
for (ForgeDirection d : ForgeDirection.VALID_DIRECTIONS) {
boolean wasConnected = connections[d.ordinal()] != null;
RedstoneConnection con = RedConnectionHelper.getNeighbor(self, d);
if (con != null) {
if (!wasConnected || connections[d.ordinal()].getB() != con.getB() || connections[d.ordinal()].getSideB() != con.getSideB() || connections[d.ordinal()].getType() != con.getType()) {
onConnect(con.getSideA(), con.getB(), con.getSideB(), con.getType());
((IConnectionCache<IRedstoneDevice>) con.getB().getRedstoneConnectionCache()).onConnect(con.getSideB(), con.getA(), con.getSideA(), con.getType());
IConnection<IRedstoneDevice> con2 = (IConnection<IRedstoneDevice>) con.getB().getRedstoneConnectionCache().getConnectionOnSide(con.getSideB());
con = connections[d.ordinal()];
if (con == null)
return;
con.setComplementaryConnection(con2);
con2.setComplementaryConnection(con);
}
} else if (wasConnected) {
con = connections[d.ordinal()];
if (con != null) {
onDisconnect(con.getSideA());
con.getB().getRedstoneConnectionCache().onDisconnect(con.getSideB());
}
}
}
}
Aggregations