Search in sources :

Example 1 with BlockLongDistPipe

use of gregtech.blocks.tool.BlockLongDistPipe in project gregtech6 by GregTech6.

the class MultiTileEntityLongDistancePipelineItem method scanPipes.

private void scanPipes() {
    if (mSender != null && !mSender.isDead() && mSender.mTarget == this)
        return;
    mIgnoreUnloadedChunks = F;
    mTargetPos = getCoords();
    mTarget = this;
    mSender = null;
    Block aBlock = getBlockAtSide(OPOS[mFacing]);
    byte aMetaData = getMetaDataAtSide(OPOS[mFacing]);
    if (aBlock instanceof BlockLongDistPipe) {
        if (((BlockLongDistPipe) aBlock).mTemperatures[aMetaData] >= 0)
            return;
        HashSetNoNulls<ChunkCoordinates> tNewChecks = new HashSetNoNulls<>(), tOldChecks = new HashSetNoNulls<>(F, getCoords()), tToCheck = new HashSetNoNulls<>(F, getOffsetN(mFacing, 1)), tWires = new HashSetNoNulls<>();
        while (!tToCheck.isEmpty()) {
            for (ChunkCoordinates aCoords : tToCheck) {
                if (getBlock(aCoords) == aBlock && getMetaData(aCoords) == aMetaData) {
                    tWires.add(aCoords);
                    ChunkCoordinates tCoords;
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX - 1, aCoords.posY, aCoords.posZ)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY + 1, aCoords.posZ)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY - 1, aCoords.posZ)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ + 1)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ - 1)))
                        tNewChecks.add(tCoords);
                } else {
                    TileEntity tTileEntity = getTileEntity(aCoords);
                    if (tTileEntity != this && tTileEntity instanceof MultiTileEntityLongDistancePipelineItem) {
                        if (tWires.contains(((MultiTileEntityLongDistancePipelineItem) tTileEntity).getOffset(((MultiTileEntityLongDistancePipelineItem) tTileEntity).mFacing, 1))) {
                            mTarget = (MultiTileEntityLongDistancePipelineItem) tTileEntity;
                            mTargetPos = mTarget.getCoords();
                            mIgnoreUnloadedChunks = T;
                            return;
                        }
                        tOldChecks.remove(aCoords);
                    }
                }
            }
            tToCheck.clear();
            tToCheck.addAll(tNewChecks);
            tNewChecks.clear();
        }
    }
    mIgnoreUnloadedChunks = T;
}
Also used : DelegatorTileEntity(gregapi.tileentity.delegate.DelegatorTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) HashSetNoNulls(gregapi.code.HashSetNoNulls) Block(net.minecraft.block.Block) ChunkCoordinates(net.minecraft.util.ChunkCoordinates) BlockLongDistPipe(gregtech.blocks.tool.BlockLongDistPipe)

Example 2 with BlockLongDistPipe

use of gregtech.blocks.tool.BlockLongDistPipe in project gregtech6 by GregTech6.

the class MultiTileEntityLongDistancePipelineFluid method scanPipes.

private void scanPipes() {
    if (mSender != null && !mSender.isDead() && mSender.mTarget == this)
        return;
    mIgnoreUnloadedChunks = F;
    mTargetPos = getCoords();
    mTarget = this;
    mSender = null;
    mTemperature = 0;
    Block aBlock = getBlockAtSide(OPOS[mFacing]);
    byte aMetaData = getMetaDataAtSide(OPOS[mFacing]);
    if (aBlock instanceof BlockLongDistPipe) {
        mTemperature = ((BlockLongDistPipe) aBlock).mTemperatures[aMetaData];
        if (mTemperature <= 0)
            return;
        HashSetNoNulls<ChunkCoordinates> tNewChecks = new HashSetNoNulls<>(), tOldChecks = new HashSetNoNulls<>(F, getCoords()), tToCheck = new HashSetNoNulls<>(F, getOffsetN(mFacing, 1)), tWires = new HashSetNoNulls<>();
        while (!tToCheck.isEmpty()) {
            for (ChunkCoordinates aCoords : tToCheck) {
                if (getBlock(aCoords) == aBlock && getMetaData(aCoords) == aMetaData) {
                    tWires.add(aCoords);
                    ChunkCoordinates tCoords;
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX + 1, aCoords.posY, aCoords.posZ)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX - 1, aCoords.posY, aCoords.posZ)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY + 1, aCoords.posZ)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY - 1, aCoords.posZ)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ + 1)))
                        tNewChecks.add(tCoords);
                    if (tOldChecks.add(tCoords = new ChunkCoordinates(aCoords.posX, aCoords.posY, aCoords.posZ - 1)))
                        tNewChecks.add(tCoords);
                } else {
                    TileEntity tTileEntity = getTileEntity(aCoords);
                    if (tTileEntity != this && tTileEntity instanceof MultiTileEntityLongDistancePipelineFluid) {
                        if (tWires.contains(((MultiTileEntityLongDistancePipelineFluid) tTileEntity).getOffset(((MultiTileEntityLongDistancePipelineFluid) tTileEntity).mFacing, 1))) {
                            mTarget = (MultiTileEntityLongDistancePipelineFluid) tTileEntity;
                            mTargetPos = mTarget.getCoords();
                            mIgnoreUnloadedChunks = T;
                            return;
                        }
                        tOldChecks.remove(aCoords);
                    }
                }
            }
            tToCheck.clear();
            tToCheck.addAll(tNewChecks);
            tNewChecks.clear();
        }
    }
    mIgnoreUnloadedChunks = T;
}
Also used : DelegatorTileEntity(gregapi.tileentity.delegate.DelegatorTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) HashSetNoNulls(gregapi.code.HashSetNoNulls) Block(net.minecraft.block.Block) ChunkCoordinates(net.minecraft.util.ChunkCoordinates) BlockLongDistPipe(gregtech.blocks.tool.BlockLongDistPipe)

Aggregations

HashSetNoNulls (gregapi.code.HashSetNoNulls)2 DelegatorTileEntity (gregapi.tileentity.delegate.DelegatorTileEntity)2 BlockLongDistPipe (gregtech.blocks.tool.BlockLongDistPipe)2 Block (net.minecraft.block.Block)2 TileEntity (net.minecraft.tileentity.TileEntity)2 ChunkCoordinates (net.minecraft.util.ChunkCoordinates)2