Search in sources :

Example 11 with ITransmitter

use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.

the class NetworkFinderSolar method loopAll.

private void loopAll(int x, int y, int z, int dirIn) {
    BlockVec3 obj = null;
    for (int dir = 0; dir < 6; dir++) {
        if (dir == dirIn) {
            continue;
        }
        switch(dir) {
            case 0:
                obj = new BlockVec3(x, y - 1, z);
                break;
            case 1:
                obj = new BlockVec3(x, y + 1, z);
                break;
            case 2:
                obj = new BlockVec3(x, y, z - 1);
                break;
            case 3:
                obj = new BlockVec3(x, y, z + 1);
                break;
            case 4:
                obj = new BlockVec3(x - 1, y, z);
                break;
            case 5:
                obj = new BlockVec3(x + 1, y, z);
                break;
        }
        if (!iterated.contains(obj)) {
            iterated.add(obj);
            TileEntity tileEntity = worldObj.getTileEntity(new BlockPos(obj.x, obj.y, obj.z));
            if (tileEntity instanceof ITransmitter && ((ITransmitter) tileEntity).getNetworkType() == NetworkType.SOLAR_MODULE) {
                found.add((ITransmitter) tileEntity);
                loopAll(obj.x, obj.y, obj.z, dir ^ 1);
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter) BlockPos(net.minecraft.util.math.BlockPos) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 12 with ITransmitter

use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.

the class SolarModuleNetwork method refreshWithChecks.

/**
 * Refresh validity of each conductor in the network
 */
public void refreshWithChecks() {
    Iterator<ITransmitter> it = this.transmitters.iterator();
    while (it.hasNext()) {
        ITransmitter transmitter = it.next();
        if (transmitter == null) {
            it.remove();
            continue;
        }
        TileEntity tile = (TileEntity) transmitter;
        World world = tile.getWorld();
        // Remove any transmitters in unloaded chunks
        if (tile.isInvalid() || world == null || !world.isBlockLoaded(tile.getPos())) {
            it.remove();
            continue;
        }
        if (transmitter != world.getTileEntity(tile.getPos())) {
            it.remove();
            continue;
        }
        if (transmitter.getNetwork() != this) {
            transmitter.setNetwork(this);
            transmitter.onNetworkChanged();
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter) World(net.minecraft.world.World)

Example 13 with ITransmitter

use of micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter in project Galacticraft by micdoodle8.

the class TileEntityFluidTransmitter method refresh.

@Override
public void refresh() {
    if (!this.world.isRemote) {
        this.adjacentConnections = null;
        BlockVec3 thisVec = new BlockVec3(this);
        for (EnumFacing side : EnumFacing.VALUES) {
            TileEntity tileEntity = thisVec.getTileEntityOnSide(this.world, side);
            if (tileEntity != null) {
                if (tileEntity.getClass() == this.getClass() && tileEntity instanceof INetworkProvider && ((INetworkProvider) tileEntity).hasNetwork()) {
                    if (!(tileEntity instanceof ITransmitter) || (((ITransmitter) tileEntity).canConnect(side.getOpposite(), ((ITransmitter) tileEntity).getNetworkType()))) {
                        if (!this.hasNetwork()) {
                            this.setNetwork(((INetworkProvider) tileEntity).getNetwork());
                            ((FluidNetwork) this.getNetwork()).addTransmitter(this);
                            ((FluidNetwork) this.getNetwork()).onTransmitterAdded(this);
                        } else if (this.hasNetwork() && !this.getNetwork().equals(((INetworkProvider) tileEntity).getNetwork())) {
                            this.setNetwork((IGridNetwork) this.getNetwork().merge(((INetworkProvider) tileEntity).getNetwork()));
                        }
                    }
                }
            }
        }
        this.getNetwork().refresh();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork) IGridNetwork(micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork) EnumFacing(net.minecraft.util.EnumFacing) ITransmitter(micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter) INetworkProvider(micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Aggregations

ITransmitter (micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter)13 TileEntity (net.minecraft.tileentity.TileEntity)13 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)5 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)3 EnumFacing (net.minecraft.util.EnumFacing)3 World (net.minecraft.world.World)3 IGridNetwork (micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork)2 Vector3 (micdoodle8.mods.galacticraft.api.vector.Vector3)2 IBlockState (net.minecraft.block.state.IBlockState)2 IBufferTransmitter (micdoodle8.mods.galacticraft.api.transmission.tile.IBufferTransmitter)1 IGalacticraftWorldProvider (micdoodle8.mods.galacticraft.api.world.IGalacticraftWorldProvider)1 WorldProviderSpaceStation (micdoodle8.mods.galacticraft.core.dimension.WorldProviderSpaceStation)1 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)1 WorldProviderVenus (micdoodle8.mods.galacticraft.planets.venus.dimension.WorldProviderVenus)1 BlockPos (net.minecraft.util.math.BlockPos)1 Vec3i (net.minecraft.util.math.Vec3i)1