Search in sources :

Example 6 with XNetBlobData

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

the class GenericCableBlock method unlinkBlock.

public void unlinkBlock(World world, BlockPos pos) {
    if (!world.isRemote) {
        XNetBlobData blobData = XNetBlobData.getBlobData(world);
        WorldBlob worldBlob = blobData.getWorldBlob(world);
        worldBlob.removeCableSegment(pos);
        blobData.save(world);
    }
}
Also used : XNetBlobData(mcjty.xnet.multiblock.XNetBlobData) WorldBlob(mcjty.xnet.multiblock.WorldBlob)

Example 7 with XNetBlobData

use of mcjty.xnet.multiblock.XNetBlobData 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 8 with XNetBlobData

use of mcjty.xnet.multiblock.XNetBlobData 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 9 with XNetBlobData

use of mcjty.xnet.multiblock.XNetBlobData 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 10 with XNetBlobData

use of mcjty.xnet.multiblock.XNetBlobData 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

XNetBlobData (mcjty.xnet.multiblock.XNetBlobData)14 WorldBlob (mcjty.xnet.multiblock.WorldBlob)10 ColorId (mcjty.xnet.multiblock.ColorId)5 NetworkId (mcjty.xnet.api.keys.NetworkId)3 TileEntity (net.minecraft.tileentity.TileEntity)3 ConsumerId (mcjty.xnet.api.keys.ConsumerId)2 ConnectorBlock (mcjty.xnet.blocks.cables.ConnectorBlock)2 CableColor (mcjty.xnet.blocks.generic.CableColor)2 EnumFacing (net.minecraft.util.EnumFacing)2 ConnectorTileEntity (mcjty.xnet.blocks.cables.ConnectorTileEntity)1 GenericCableBlock (mcjty.xnet.blocks.generic.GenericCableBlock)1 BlobId (mcjty.xnet.multiblock.BlobId)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1 BlockPos (net.minecraft.util.math.BlockPos)1 TextComponentString (net.minecraft.util.text.TextComponentString)1 World (net.minecraft.world.World)1