use of mcjty.xnet.logic.ChannelInfo in project XNet by McJty.
the class TileEntityController method readRestorableFromNBT.
@Override
public void readRestorableFromNBT(NBTTagCompound tagCompound) {
super.readRestorableFromNBT(tagCompound);
colors = tagCompound.getInteger("colors");
for (int i = 0; i < MAX_CHANNELS; i++) {
if (tagCompound.hasKey("channel" + i)) {
NBTTagCompound tc = (NBTTagCompound) tagCompound.getTag("channel" + i);
String id = tc.getString("type");
IChannelType type = XNet.xNetApi.findType(id);
if (type == null) {
XNet.logger.warn("Unsupported type " + id + "!");
continue;
}
channels[i] = new ChannelInfo(type);
channels[i].readFromNBT(tc);
} else {
channels[i] = null;
}
}
}
use of mcjty.xnet.logic.ChannelInfo in project XNet by McJty.
the class TileEntityController method createChannel.
private void createChannel(int channel, String typeId) {
IChannelType type = XNet.xNetApi.findType(typeId);
channels[channel] = new ChannelInfo(type);
networkDirty();
markDirtyQuick();
}
use of mcjty.xnet.logic.ChannelInfo in project XNet by McJty.
the class TileEntityRouter method findLocalChannelInfo.
@Nonnull
private List<ControllerChannelClientInfo> findLocalChannelInfo(boolean onlyPublished) {
List<ControllerChannelClientInfo> list = new ArrayList<>();
LogicTools.connectors(getWorld(), getPos()).map(connectorPos -> LogicTools.getControllerForConnector(getWorld(), connectorPos)).filter(Objects::nonNull).forEach(controller -> {
for (int i = 0; i < MAX_CHANNELS; i++) {
ChannelInfo channelInfo = controller.getChannels()[i];
if (channelInfo != null && !channelInfo.getChannelName().isEmpty()) {
LocalChannelId id = new LocalChannelId(controller.getPos(), i);
String publishedName = publishedChannels.get(id);
if (publishedName == null) {
publishedName = "";
}
if ((!onlyPublished) || !publishedName.isEmpty()) {
ControllerChannelClientInfo ci = new ControllerChannelClientInfo(channelInfo.getChannelName(), publishedName, controller.getPos(), channelInfo.getType(), i);
list.add(ci);
}
}
}
});
return list;
}
use of mcjty.xnet.logic.ChannelInfo 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;
}
Aggregations