use of mcjty.xnet.api.channels.IChannelType 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.api.channels.IChannelType 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.api.channels.IChannelType in project XNet by McJty.
the class GuiRouter method makeChannelLine.
private Panel makeChannelLine(ControllerChannelClientInfo channel, boolean local) {
String name = channel.getChannelName();
String publishedName = channel.getPublishedName();
BlockPos controllerPos = channel.getPos();
IChannelType type = channel.getChannelType();
int index = channel.getIndex();
Panel panel = new Panel(mc, this).setLayout(new PositionalLayout()).setDesiredHeight(30);
Panel panel1 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 0, 160, 13));
panel1.addChild(new Label<>(mc, this).setText("Ch").setColor(0xff2244aa));
panel1.addChild(new Label<>(mc, this).setText(name));
panel1.addChild(new Label<>(mc, this).setText(">").setColor(0xff2244aa));
if (local) {
TextField pubName = new TextField(mc, this).setText(publishedName).setDesiredWidth(50).setDesiredHeight(13).addTextEvent((parent, newText) -> updatePublish(controllerPos, index, newText));
panel1.addChild(pubName);
} else {
panel1.addChild(new Label<>(mc, this).setText(publishedName).setColor(0xff33ff00));
}
Panel panel2 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 13, 160, 13));
panel2.addChild(new Label<>(mc, this).setText("Pos").setColor(0xff2244aa));
panel2.addChild(new Label<>(mc, this).setText(BlockPosTools.toString(controllerPos)));
Panel panel3 = new Panel(mc, this).setLayout(new HorizontalLayout().setHorizontalMargin(0).setSpacing(0)).setLayoutHint(new PositionalLayout.PositionalHint(0, 26, 160, 13));
panel3.addChild(new Label<>(mc, this).setText("Index").setColor(0xff2244aa));
panel3.addChild(new Label<>(mc, this).setText(index + " (" + type.getName() + ")"));
panel.addChild(panel1).addChild(panel2).addChild(panel3);
return panel;
}
use of mcjty.xnet.api.channels.IChannelType in project XNet by McJty.
the class TileEntityRouter method addRoutedConnectors.
public void addRoutedConnectors(Map<SidedConsumer, IConnectorSettings> connectors, @Nonnull BlockPos controllerPos, int channel, IChannelType type) {
if (inError()) {
// We are in error. Don't do anything
return;
}
LocalChannelId id = new LocalChannelId(controllerPos, channel);
String publishedName = publishedChannels.get(id);
if (publishedName != null && !publishedName.isEmpty()) {
NetworkId networkId = findRoutingNetwork();
if (networkId != null) {
LogicTools.consumers(getWorld(), networkId).forEach(consumerPos -> LogicTools.routers(getWorld(), consumerPos).forEach(router -> router.addConnectorsFromConnectedNetworks(connectors, publishedName, type)));
} else {
// If there is no routing network that means we have a local network only
addConnectorsFromConnectedNetworks(connectors, publishedName, type);
}
}
}
use of mcjty.xnet.api.channels.IChannelType in project XNet by McJty.
the class ChannelInfo method readFromNBT.
public void readFromNBT(NBTTagCompound tag) {
channelSettings.readFromNBT(tag);
enabled = tag.getBoolean("enabled");
if (tag.hasKey("name")) {
channelName = tag.getString("name");
} else {
channelName = null;
}
NBTTagList conlist = tag.getTagList("connectors", Constants.NBT.TAG_COMPOUND);
for (int i = 0; i < conlist.tagCount(); i++) {
NBTTagCompound tc = conlist.getCompoundTagAt(i);
String id = tc.getString("type");
IChannelType type = XNet.xNetApi.findType(id);
if (type == null) {
XNet.logger.warn("Unsupported type " + id + "!");
continue;
}
if (!getType().equals(type)) {
XNet.logger.warn("Trying to load a connector with non-matching type " + type + "!");
continue;
}
ConsumerId consumerId = new ConsumerId(tc.getInteger("consumerId"));
EnumFacing side = EnumFacing.VALUES[tc.getInteger("side")];
SidedConsumer key = new SidedConsumer(consumerId, side);
boolean advanced = tc.getBoolean("advanced");
ConnectorInfo connectorInfo = new ConnectorInfo(type, key, advanced);
connectorInfo.readFromNBT(tc);
connectors.put(key, connectorInfo);
}
}
Aggregations