use of mcjty.xnet.clientinfo.ConnectorInfo in project XNet by McJty.
the class TileEntityController method findChannelInfo.
@Nonnull
private List<ChannelClientInfo> findChannelInfo() {
WorldBlob worldBlob = XNetBlobData.getBlobData(getWorld()).getWorldBlob(getWorld());
List<ChannelClientInfo> chanList = new ArrayList<>();
for (ChannelInfo channel : channels) {
if (channel != null) {
ChannelClientInfo clientInfo = new ChannelClientInfo(channel.getChannelName(), channel.getType(), channel.getChannelSettings(), channel.isEnabled());
for (Map.Entry<SidedConsumer, ConnectorInfo> entry : channel.getConnectors().entrySet()) {
SidedConsumer sidedConsumer = entry.getKey();
ConnectorInfo info = entry.getValue();
if (info.getConnectorSettings() != null) {
BlockPos consumerPos = findConsumerPosition(worldBlob, sidedConsumer.getConsumerId());
if (consumerPos != null) {
SidedPos pos = new SidedPos(consumerPos.offset(sidedConsumer.getSide()), sidedConsumer.getSide().getOpposite());
boolean advanced = getWorld().getBlockState(consumerPos).getBlock() == NetCableSetup.advancedConnectorBlock;
ConnectorClientInfo ci = new ConnectorClientInfo(pos, sidedConsumer.getConsumerId(), channel.getType(), info.getConnectorSettings());
clientInfo.getConnectors().put(sidedConsumer, ci);
} else {
// Consumer was possibly removed. We might want to remove the entry from our list here?
// @todo
}
}
}
chanList.add(clientInfo);
} else {
chanList.add(null);
}
}
return chanList;
}
use of mcjty.xnet.clientinfo.ConnectorInfo in project XNet by McJty.
the class TileEntityController method updateConnector.
private void updateConnector(int channel, SidedPos pos, Map<String, Argument> args) {
WorldBlob worldBlob = XNetBlobData.getBlobData(getWorld()).getWorldBlob(getWorld());
ConsumerId consumerId = worldBlob.getConsumerAt(pos.getPos().offset(pos.getSide()));
for (Map.Entry<SidedConsumer, ConnectorInfo> entry : channels[channel].getConnectors().entrySet()) {
SidedConsumer key = entry.getKey();
if (key.getConsumerId().equals(consumerId) && key.getSide().getOpposite().equals(pos.getSide())) {
Map<String, Object> data = new HashMap<>();
for (Map.Entry<String, Argument> e : args.entrySet()) {
data.put(e.getKey(), e.getValue().getValue());
}
channels[channel].getConnectors().get(key).getConnectorSettings().update(data);
networkDirty();
markDirtyQuick();
return;
}
}
}
Aggregations