Search in sources :

Example 11 with WorldBlob

use of mcjty.xnet.multiblock.WorldBlob in project XNet by McJty.

the class GenericCableBlock method addProbeInfo.

@Override
@Optional.Method(modid = "theoneprobe")
public void addProbeInfo(ProbeMode mode, IProbeInfo probeInfo, EntityPlayer player, World world, IBlockState blockState, IProbeHitData data) {
    WorldBlob worldBlob = XNetBlobData.getBlobData(world).getWorldBlob(world);
    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());
        }
    }
    Set<NetworkId> networks = worldBlob.getNetworksAt(data.getPos());
    for (NetworkId network : networks) {
        if (mode == ProbeMode.DEBUG) {
            probeInfo.text(TextStyleClass.LABEL + "Network: " + TextStyleClass.INFO + network.getId() + ", V: " + worldBlob.getNetworkVersion(network));
        } else {
            probeInfo.text(TextStyleClass.LABEL + "Network: " + TextStyleClass.INFO + network.getId());
        }
    }
    ConsumerId consumerId = worldBlob.getConsumerAt(data.getPos());
    if (consumerId != null) {
        probeInfo.text(TextStyleClass.LABEL + "Consumer: " + TextStyleClass.INFO + consumerId.getId());
    }
}
Also used : ConsumerId(mcjty.xnet.api.keys.ConsumerId) WorldBlob(mcjty.xnet.multiblock.WorldBlob) NetworkId(mcjty.xnet.api.keys.NetworkId) BlobId(mcjty.xnet.multiblock.BlobId) ColorId(mcjty.xnet.multiblock.ColorId)

Example 12 with WorldBlob

use of mcjty.xnet.multiblock.WorldBlob 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());
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) XNetBlobData(mcjty.xnet.multiblock.XNetBlobData) WorldBlob(mcjty.xnet.multiblock.WorldBlob) NetworkId(mcjty.xnet.api.keys.NetworkId) BlobId(mcjty.xnet.multiblock.BlobId) ColorId(mcjty.xnet.multiblock.ColorId)

Example 13 with WorldBlob

use of mcjty.xnet.multiblock.WorldBlob 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);
    }
}
Also used : XNetBlobData(mcjty.xnet.multiblock.XNetBlobData) WorldBlob(mcjty.xnet.multiblock.WorldBlob) NetworkId(mcjty.xnet.api.keys.NetworkId) ColorId(mcjty.xnet.multiblock.ColorId)

Example 14 with WorldBlob

use of mcjty.xnet.multiblock.WorldBlob in project XNet by McJty.

the class ConnectorBlock method createCableSegment.

public void createCableSegment(World world, BlockPos pos, ConsumerId consumer) {
    XNetBlobData blobData = XNetBlobData.getBlobData(world);
    WorldBlob worldBlob = blobData.getWorldBlob(world);
    CableColor color = world.getBlockState(pos).getValue(COLOR);
    worldBlob.createNetworkConsumer(pos, new ColorId(color.ordinal() + 1), consumer);
    blobData.save(world);
}
Also used : XNetBlobData(mcjty.xnet.multiblock.XNetBlobData) WorldBlob(mcjty.xnet.multiblock.WorldBlob) CableColor(mcjty.xnet.blocks.generic.CableColor) ColorId(mcjty.xnet.multiblock.ColorId)

Example 15 with WorldBlob

use of mcjty.xnet.multiblock.WorldBlob in project XNet by McJty.

the class ConnectorBlock method createCableSegment.

@Override
public void createCableSegment(World world, BlockPos pos, ItemStack stack) {
    ConsumerId consumer;
    if (!stack.isEmpty() && stack.hasTagCompound() && stack.getTagCompound().hasKey("consumerId")) {
        consumer = new ConsumerId(stack.getTagCompound().getInteger("consumerId"));
    } else {
        XNetBlobData blobData = XNetBlobData.getBlobData(world);
        WorldBlob worldBlob = blobData.getWorldBlob(world);
        consumer = worldBlob.newConsumer();
    }
    createCableSegment(world, pos, consumer);
}
Also used : XNetBlobData(mcjty.xnet.multiblock.XNetBlobData) ConsumerId(mcjty.xnet.api.keys.ConsumerId) WorldBlob(mcjty.xnet.multiblock.WorldBlob)

Aggregations

WorldBlob (mcjty.xnet.multiblock.WorldBlob)25 XNetBlobData (mcjty.xnet.multiblock.XNetBlobData)11 ConsumerId (mcjty.xnet.api.keys.ConsumerId)8 NetworkId (mcjty.xnet.api.keys.NetworkId)8 ColorId (mcjty.xnet.multiblock.ColorId)7 TileEntity (net.minecraft.tileentity.TileEntity)7 SidedConsumer (mcjty.xnet.api.keys.SidedConsumer)6 EnumFacing (net.minecraft.util.EnumFacing)6 BlockPos (net.minecraft.util.math.BlockPos)6 ConnectorInfo (mcjty.xnet.clientinfo.ConnectorInfo)5 Nonnull (javax.annotation.Nonnull)4 SidedPos (mcjty.xnet.api.keys.SidedPos)4 ConnectorTileEntity (mcjty.xnet.blocks.cables.ConnectorTileEntity)4 GenericEnergyReceiverTileEntity (mcjty.lib.entity.GenericEnergyReceiverTileEntity)3 ConnectorBlock (mcjty.xnet.blocks.cables.ConnectorBlock)3 ConnectedBlockClientInfo (mcjty.xnet.clientinfo.ConnectedBlockClientInfo)3 BlobId (mcjty.xnet.multiblock.BlobId)3 IBlockState (net.minecraft.block.state.IBlockState)3 SPacketUpdateTileEntity (net.minecraft.network.play.server.SPacketUpdateTileEntity)3 Nullable (javax.annotation.Nullable)2