Search in sources :

Example 1 with ControllerChannelClientInfo

use of mcjty.xnet.clientinfo.ControllerChannelClientInfo 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;
}
Also used : ControllerChannelClientInfo(mcjty.xnet.clientinfo.ControllerChannelClientInfo) ChannelInfo(mcjty.xnet.logic.ChannelInfo) Nonnull(javax.annotation.Nonnull)

Example 2 with ControllerChannelClientInfo

use of mcjty.xnet.clientinfo.ControllerChannelClientInfo in project XNet by McJty.

the class GuiRouter method populateList.

private void populateList() {
    if (!listsReady()) {
        return;
    }
    if (!needsRefresh) {
        return;
    }
    needsRefresh = false;
    localChannelList.removeChildren();
    localChannelList.setRowheight(40);
    int sel = localChannelList.getSelected();
    for (ControllerChannelClientInfo channel : fromServer_localChannels) {
        localChannelList.addChild(makeChannelLine(channel, true));
    }
    localChannelList.setSelected(sel);
    remoteChannelList.removeChildren();
    remoteChannelList.setRowheight(40);
    sel = remoteChannelList.getSelected();
    for (ControllerChannelClientInfo channel : fromServer_remoteChannels) {
        remoteChannelList.addChild(makeChannelLine(channel, false));
    }
    remoteChannelList.setSelected(sel);
}
Also used : ControllerChannelClientInfo(mcjty.xnet.clientinfo.ControllerChannelClientInfo)

Example 3 with ControllerChannelClientInfo

use of mcjty.xnet.clientinfo.ControllerChannelClientInfo in project XNet by McJty.

the class TileEntityRouter method findRemoteChannelInfo.

@Nonnull
private List<ControllerChannelClientInfo> findRemoteChannelInfo() {
    List<ControllerChannelClientInfo> list = new ArrayList<>();
    NetworkId networkId = findRoutingNetwork();
    if (networkId != null) {
        LogicTools.consumers(getWorld(), networkId).forEach(consumerPos -> LogicTools.routers(getWorld(), consumerPos).filter(r -> r != this).forEach(router -> list.addAll(router.findLocalChannelInfo(true))));
    }
    return list;
}
Also used : ControllerChannelClientInfo(mcjty.xnet.clientinfo.ControllerChannelClientInfo) GeneralConfiguration(mcjty.xnet.config.GeneralConfiguration) java.util(java.util) SPacketUpdateTileEntity(net.minecraft.network.play.server.SPacketUpdateTileEntity) IConnectorSettings(mcjty.xnet.api.channels.IConnectorSettings) Constants(net.minecraftforge.common.util.Constants) SidedConsumer(mcjty.xnet.api.keys.SidedConsumer) ChannelInfo(mcjty.xnet.logic.ChannelInfo) NetworkManager(net.minecraft.network.NetworkManager) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) BlockPosTools(mcjty.lib.varia.BlockPosTools) NBTTagList(net.minecraft.nbt.NBTTagList) Type(mcjty.typed.Type) ControllerChannelClientInfo(mcjty.xnet.clientinfo.ControllerChannelClientInfo) GenericTileEntity(mcjty.lib.entity.GenericTileEntity) XNetBlobData(mcjty.xnet.multiblock.XNetBlobData) WorldBlob(mcjty.xnet.multiblock.WorldBlob) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) LogicTools(mcjty.xnet.logic.LogicTools) EnumFacing(net.minecraft.util.EnumFacing) BlockPos(net.minecraft.util.math.BlockPos) Argument(mcjty.lib.network.Argument) MAX_CHANNELS(mcjty.xnet.logic.ChannelInfo.MAX_CHANNELS) IChannelType(mcjty.xnet.api.channels.IChannelType) NetworkId(mcjty.xnet.api.keys.NetworkId) NetworkId(mcjty.xnet.api.keys.NetworkId) Nonnull(javax.annotation.Nonnull)

Aggregations

ControllerChannelClientInfo (mcjty.xnet.clientinfo.ControllerChannelClientInfo)3 Nonnull (javax.annotation.Nonnull)2 ChannelInfo (mcjty.xnet.logic.ChannelInfo)2 java.util (java.util)1 Nullable (javax.annotation.Nullable)1 GenericTileEntity (mcjty.lib.entity.GenericTileEntity)1 Argument (mcjty.lib.network.Argument)1 BlockPosTools (mcjty.lib.varia.BlockPosTools)1 Type (mcjty.typed.Type)1 IChannelType (mcjty.xnet.api.channels.IChannelType)1 IConnectorSettings (mcjty.xnet.api.channels.IConnectorSettings)1 NetworkId (mcjty.xnet.api.keys.NetworkId)1 SidedConsumer (mcjty.xnet.api.keys.SidedConsumer)1 GeneralConfiguration (mcjty.xnet.config.GeneralConfiguration)1 MAX_CHANNELS (mcjty.xnet.logic.ChannelInfo.MAX_CHANNELS)1 LogicTools (mcjty.xnet.logic.LogicTools)1 WorldBlob (mcjty.xnet.multiblock.WorldBlob)1 XNetBlobData (mcjty.xnet.multiblock.XNetBlobData)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1