use of crazypants.enderio.base.conduit.redstone.signals.SignalSource in project EnderIO by SleepyTrousers.
the class RedstoneConduitNetwork method afterChunkUnload.
/**
* This is a bit of a hack...avoids the network searching for inputs from unloaded chunks by only filtering out the invalid signals from the unloaded chunk.
*
* @param conduits
* @param oldSignals
*/
public void afterChunkUnload(@Nonnull List<IRedstoneConduit> conduits, @Nonnull Multimap<SignalSource, Signal> oldSignals) {
World world = null;
for (IRedstoneConduit c : conduits) {
if (world == null) {
world = c.getBundle().getBundleworld();
}
BlockPos pos = c.getBundle().getLocation();
if (world.isBlockLoaded(pos)) {
this.getConduits().add(c);
c.setNetwork(this);
}
}
signals.clear();
boolean signalsChanged = false;
for (Entry<SignalSource, Signal> s : oldSignals.entries()) {
if (world != null && world.isBlockLoaded(s.getKey().getSource())) {
signals.put(s.getKey(), s.getValue());
} else {
signalsChanged = true;
}
}
if (signalsChanged) {
// broadcast out a change
notifyNeigborsOfSignalUpdate();
}
}
use of crazypants.enderio.base.conduit.redstone.signals.SignalSource in project EnderIO by SleepyTrousers.
the class RedstoneConduitNetwork method updateInputsFromConduit.
public void updateInputsFromConduit(@Nonnull IRedstoneConduit con, boolean delayUpdate) {
BlockPos pos = con.getBundle().getLocation();
// Make my neighbors update as if we have no signals
updatingNetwork = true;
notifyConduitNeighbours(con);
updatingNetwork = false;
// Then ask them what inputs they have now
Set<EnumFacing> externalConnections = con.getExternalConnections();
for (EnumFacing side : EnumFacing.values()) {
if (externalConnections.contains(side)) {
updateInputsForSource(con, new SignalSource(pos, side));
} else {
signals.removeAll(new SignalSource(pos, side));
}
}
if (!delayUpdate) {
// then tell the whole network about the change
notifyNeigborsOfSignalUpdate();
}
if (ConduitConfig.showState.get()) {
updateActiveState();
}
}
Aggregations