use of mcjty.xnet.api.keys.NetworkId in project XNet by McJty.
the class RouterBlock method addProbeInfo.
@Override
@Optional.Method(modid = "theoneprobe")
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
super.addProbeInfo(mode, probeInfo, player, world, blockState, data);
XNetBlobData blobData = XNetBlobData.getBlobData(world);
WorldBlob worldBlob = blobData.getWorldBlob(world);
Set<NetworkId> networks = worldBlob.getNetworksAt(data.getPos());
for (NetworkId networkId : networks) {
probeInfo.text(TextStyleClass.LABEL + "Network: " + TextStyleClass.INFO + networkId.getId());
if (mode != ProbeMode.EXTENDED) {
break;
}
}
TileEntity te = world.getTileEntity(data.getPos());
if (te instanceof TileEntityRouter) {
TileEntityRouter router = (TileEntityRouter) te;
if (router.inError()) {
probeInfo.text(TextStyleClass.ERROR + "Too many channels on router!");
} else {
probeInfo.text(TextStyleClass.LABEL + "Channels: " + TextStyleClass.INFO + router.getChannelCount());
}
}
if (mode == ProbeMode.DEBUG) {
BlobId blobId = worldBlob.getBlobAt(data.getPos());
if (blobId != null) {
probeInfo.text(TextStyleClass.LABEL + "Blob: " + TextStyleClass.INFO + blobId.getId());
}
ColorId colorId = worldBlob.getColorAt(data.getPos());
if (colorId != null) {
probeInfo.text(TextStyleClass.LABEL + "Color: " + TextStyleClass.INFO + colorId.getId());
}
}
}
use of mcjty.xnet.api.keys.NetworkId in project XNet by McJty.
the class RouterBlock method onBlockPlacedBy.
@Override
public void onBlockPlacedBy(World world, BlockPos pos, IBlockState state, EntityLivingBase placer, ItemStack stack) {
super.onBlockPlacedBy(world, pos, state, placer, stack);
if (!world.isRemote) {
XNetBlobData blobData = XNetBlobData.getBlobData(world);
WorldBlob worldBlob = blobData.getWorldBlob(world);
NetworkId networkId = worldBlob.newNetwork();
worldBlob.createNetworkProvider(pos, new ColorId(CableColor.ROUTING.ordinal() + 1), networkId);
blobData.save(world);
}
}
use of mcjty.xnet.api.keys.NetworkId in project XNet by McJty.
the class TileEntityRouter method updatePublishName.
private void updatePublishName(@Nonnull BlockPos controllerPos, int channel, String name) {
LocalChannelId id = new LocalChannelId(controllerPos, channel);
if (name == null || name.isEmpty()) {
publishedChannels.remove(id);
} else {
publishedChannels.put(id, name);
}
int number = countPublishedChannelsOnNet();
WorldBlob worldBlob = XNetBlobData.getBlobData(getWorld()).getWorldBlob(getWorld());
NetworkId networkId = findRoutingNetwork();
if (networkId != null) {
if (number != channelCount) {
LogicTools.routers(getWorld(), networkId).forEach(router -> router.setChannelCount(number));
}
// Force a recalc of affected networks
worldBlob.incNetworkVersion(networkId);
}
for (NetworkId net : worldBlob.getNetworksAt(pos)) {
worldBlob.incNetworkVersion(net);
}
for (EnumFacing facing : EnumFacing.VALUES) {
for (NetworkId net : worldBlob.getNetworksAt(pos.offset(facing))) {
worldBlob.incNetworkVersion(net);
}
}
markDirtyQuick();
}
use of mcjty.xnet.api.keys.NetworkId in project XNet by McJty.
the class TileEntityRouter method countPublishedChannelsOnNet.
public int countPublishedChannelsOnNet() {
Set<String> channels = new HashSet<>();
NetworkId networkId = findRoutingNetwork();
if (networkId != null) {
LogicTools.routers(getWorld(), networkId).forEach(router -> router.addPublishedChannels(channels));
}
return channels.size();
}
use of mcjty.xnet.api.keys.NetworkId 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;
}
Aggregations