use of crazypants.enderio.base.conduit.redstone.signals.Signal in project EnderIO by SleepyTrousers.
the class InsulatedRedstoneConduit method isProvidingWeakPower.
@Override
public int isProvidingWeakPower(@Nonnull EnumFacing toDirection) {
toDirection = toDirection.getOpposite();
if (getConnectionMode(toDirection) != ConnectionMode.IN_OUT) {
return 0;
}
if (network == null || !network.isNetworkEnabled()) {
return 0;
}
int result = 0;
for (Signal signal : getNetworkOutputs(toDirection)) {
// don't return signals back to where they came from
if (!signal.getSource().equals(getPos().offset(toDirection))) {
result = Math.max(result, signal.getStrength());
}
}
return result;
}
use of crazypants.enderio.base.conduit.redstone.signals.Signal in project EnderIO by SleepyTrousers.
the class InsulatedRedstoneConduit method getNetworkOutputs.
@Override
@Nonnull
public Collection<Signal> getNetworkOutputs(@Nonnull EnumFacing side) {
if (side == null) {
if (network == null) {
return Collections.emptySet();
}
return network.getSignals().values();
}
ConnectionMode mode = getConnectionMode(side);
if (network == null || mode != ConnectionMode.IN_OUT) {
return Collections.emptySet();
}
Collection<Signal> allSigs = network.getSignals().values();
if (allSigs.isEmpty()) {
return allSigs;
}
DyeColor col = getSignalColor(side);
Set<Signal> result = new HashSet<Signal>();
for (Signal signal : allSigs) {
if (signal.getColor() == col) {
result.add(signal);
}
}
return result;
}
use of crazypants.enderio.base.conduit.redstone.signals.Signal in project EnderIO by SleepyTrousers.
the class InsulatedRedstoneConduit method getNetworkInputs.
@Override
@Nonnull
public Set<Signal> getNetworkInputs(@Nonnull EnumFacing side) {
if (network != null) {
network.setNetworkEnabled(false);
}
HashSet<Signal> signals = new HashSet<Signal>();
if (acceptSignalsForDir(side)) {
int input = getExternalPowerLevel(side);
if (input > 1) {
// need to degrade external signals by one as they
// enter
BlockPos pos = getBundle().getLocation().offset(side);
Signal signal = new Signal(pos, side, input - 1, getSignalColor(side));
signals.add(signal);
}
}
if (network != null) {
network.setNetworkEnabled(true);
}
Map<DyeColor, Signal> res = new HashMap<DyeColor, Signal>();
for (Signal signal : signals) {
if (signal != null && (!res.containsKey(signal.getColor()) || signal.getStrength() > res.get(signal.getColor()).getStrength())) {
res.put(signal.getColor(), signal);
}
}
return new HashSet<Signal>(res.values());
}
use of crazypants.enderio.base.conduit.redstone.signals.Signal 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.Signal in project EnderIO by SleepyTrousers.
the class RedstoneConduitNetwork method signalsString.
String signalsString() {
StringBuilder sb = new StringBuilder();
for (Signal s : signals.values()) {
sb.append("<");
sb.append(s);
sb.append(">");
}
return sb.toString();
}
Aggregations