Search in sources :

Example 1 with IGridNetwork

use of micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork in project Galacticraft by micdoodle8.

the class TileEntityFluidTransmitter method setNetwork.

@Override
public void setNetwork(IGridNetwork network) {
    if (this.network == network) {
        return;
    }
    if (this.worldObj.isRemote && this.network != null) {
        FluidNetwork fluidNetwork = (FluidNetwork) this.network;
        fluidNetwork.removeTransmitter(this);
        if (fluidNetwork.getTransmitters().isEmpty()) {
            fluidNetwork.unregister();
        }
    }
    this.network = network;
    if (this.worldObj.isRemote && this.network != null) {
        ((FluidNetwork) this.network).pipes.add(this);
    }
}
Also used : FluidNetwork(micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)

Example 2 with IGridNetwork

use of micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork in project Galacticraft by micdoodle8.

the class TileEntityAluminumWireSwitch method refresh.

@Override
public void refresh() {
    boolean newDisableConnections = this.disableConnections();
    if (newDisableConnections && !this.disableConnections) {
        this.disableConnections = newDisableConnections;
        if (!this.worldObj.isRemote) {
            this.disConnect();
        }
    } else if (!newDisableConnections && this.disableConnections) {
        this.disableConnections = newDisableConnections;
        if (!this.worldObj.isRemote) {
            // Force a full network refresh of this and conductors either side
            this.setNetwork(null);
        }
    }
    if (!this.worldObj.isRemote) {
        this.adjacentConnections = null;
        if (!this.disableConnections) {
            this.getNetwork().refresh();
            BlockVec3 thisVec = new BlockVec3(this);
            for (EnumFacing side : EnumFacing.VALUES) {
                if (this.canConnect(side, NetworkType.POWER)) {
                    TileEntity tileEntity = thisVec.getTileEntityOnSide(this.worldObj, side);
                    if (tileEntity instanceof TileBaseConductor && ((TileBaseConductor) tileEntity).canConnect(side.getOpposite(), NetworkType.POWER)) {
                        IGridNetwork otherNet = ((INetworkProvider) tileEntity).getNetwork();
                        if (!this.getNetwork().equals(otherNet)) {
                            if (!otherNet.getTransmitters().isEmpty()) {
                                otherNet.merge(this.getNetwork());
                            }
                        }
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileBaseConductor(micdoodle8.mods.galacticraft.core.energy.tile.TileBaseConductor) IGridNetwork(micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork) EnumFacing(net.minecraft.util.EnumFacing) INetworkProvider(micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 3 with IGridNetwork

use of micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork in project Galacticraft by micdoodle8.

the class TileBaseConductor method refresh.

@Override
public void refresh() {
    if (!this.worldObj.isRemote) {
        this.adjacentConnections = null;
        this.getNetwork().refresh();
        BlockVec3 thisVec = new BlockVec3(this);
        for (EnumFacing side : EnumFacing.VALUES) {
            TileEntity tileEntity = thisVec.getTileEntityOnSide(this.worldObj, side);
            if (tileEntity instanceof TileBaseConductor && ((TileBaseConductor) tileEntity).canConnect(side.getOpposite(), NetworkType.POWER)) {
                IGridNetwork otherNet = ((INetworkProvider) tileEntity).getNetwork();
                if (!this.getNetwork().equals(otherNet)) {
                    if (!otherNet.getTransmitters().isEmpty()) {
                        otherNet.merge(this.getNetwork());
                    }
                }
            }
        }
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) IGridNetwork(micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork) EnumFacing(net.minecraft.util.EnumFacing) INetworkProvider(micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider) BlockVec3(micdoodle8.mods.galacticraft.api.vector.BlockVec3)

Example 4 with IGridNetwork

use of micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork in project Galacticraft by micdoodle8.

the class TileEntityFluidTransmitter method refresh.

@Override
public void refresh() {
    if (!this.worldObj.isRemote) {
        this.adjacentConnections = null;
        BlockVec3 thisVec = new BlockVec3(this);
        for (EnumFacing side : EnumFacing.VALUES) {
            TileEntity tileEntity = thisVec.getTileEntityOnSide(this.worldObj, 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

IGridNetwork (micdoodle8.mods.galacticraft.api.transmission.grid.IGridNetwork)3 INetworkProvider (micdoodle8.mods.galacticraft.api.transmission.tile.INetworkProvider)3 BlockVec3 (micdoodle8.mods.galacticraft.api.vector.BlockVec3)3 TileEntity (net.minecraft.tileentity.TileEntity)3 EnumFacing (net.minecraft.util.EnumFacing)3 FluidNetwork (micdoodle8.mods.galacticraft.core.fluid.FluidNetwork)2 ITransmitter (micdoodle8.mods.galacticraft.api.transmission.tile.ITransmitter)1 TileBaseConductor (micdoodle8.mods.galacticraft.core.energy.tile.TileBaseConductor)1