Search in sources :

Example 61 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class LogisticsNewPipeWorldRenderer method renderWorldBlock.

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    Tessellator tess = Tessellator.instance;
    TileEntity tile = world.getTileEntity(x, y, z);
    LogisticsTileGenericPipe pipeTile = (LogisticsTileGenericPipe) tile;
    PipeRenderState renderState = pipeTile.renderState;
    if (pipeTile.pipe instanceof PipeBlockRequestTable) {
        if (LogisticsPipeWorldRenderer.renderPass != 0) {
            return false;
        }
        IIconProvider icons = pipeTile.getPipeIcons();
        if (icons == null) {
            return false;
        }
        if (requestBlock == null || true) {
            requestBlock = new HashMap<>();
            for (BlockRotation rot : BlockRotation.values()) {
                requestBlock.put(rot, LogisticsNewSolidBlockWorldRenderer.block.get(rot).copy().apply(new LPScale(0.999)).apply(new LPTranslation(0.0005, 0.0005, 0.0005)));
            }
        }
        SimpleServiceLocator.cclProxy.getRenderState().reset();
        SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
        SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
        BlockRotation rotation = BlockRotation.getRotation(((PipeBlockRequestTable) pipeTile.pipe).getRotation());
        int brightness = new DoubleCoordinates(x, y, z).getBlock(world).getMixedBrightnessForBlock(world, x, y, z);
        tess.setColorOpaque_F(1F, 1F, 1F);
        tess.setBrightness(brightness);
        IIconTransformation icon = SimpleServiceLocator.cclProxy.createIconTransformer(Textures.LOGISTICS_REQUEST_TABLE_NEW);
        requestBlock.get(rotation).render(new LPTranslation(x, y, z), icon);
        for (CoverSides side : CoverSides.values()) {
            if (!pipeTile.renderState.pipeConnectionMatrix.isConnected(side.getDir(rotation))) {
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Outer.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
                LogisticsNewSolidBlockWorldRenderer.texturePlate_Inner.get(side).get(rotation).render(new LPTranslation(x, y, z), icon);
            }
        }
        return true;
    }
    boolean hasRendered = false;
    tess.addTranslation(0.00002F, 0.00002F, 0.00002F);
    renderer.setRenderBounds(0.0F, 0.0F, 0.0F, 1.0F, 1.0F, 1.0F);
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if (pipeTile.tilePart.hasPipePluggable(dir)) {
            IBCPipePluggable p = pipeTile.tilePart.getBCPipePluggable(dir);
            p.renderPluggable(renderer, dir, LogisticsPipeWorldRenderer.renderPass, x, y, z);
            hasRendered = true;
        }
    }
    tess.addTranslation(-0.00002F, -0.00002F, -0.00002F);
    boolean[] solidSides = new boolean[6];
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        DoubleCoordinates pos = CoordinateUtils.add(new DoubleCoordinates((TileEntity) pipeTile), dir);
        Block blockSide = pos.getBlock(pipeTile.getWorldObj());
        if (blockSide != null && blockSide.isSideSolid(pipeTile.getWorldObj(), pos.getXInt(), pos.getYInt(), pos.getZInt(), dir.getOpposite()) && !renderState.pipeConnectionMatrix.isConnected(dir)) {
            solidSides[dir.ordinal()] = true;
        }
    }
    if (!Arrays.equals(solidSides, renderState.solidSidesCache)) {
        renderState.solidSidesCache = solidSides.clone();
        renderState.cachedRenderer = null;
    }
    if (hasRendered) {
        block.setBlockBounds(0, 0, 0, 0, 0, 0);
        renderer.setRenderBoundsFromBlock(block);
        renderer.renderStandardBlock(block, x, y, z);
        block.setBlockBounds(0, 0, 0, 1, 1, 1);
    }
    return hasRendered;
}
Also used : PipeRenderState(logisticspipes.renderer.state.PipeRenderState) Tessellator(net.minecraft.client.renderer.Tessellator) PipeBlockRequestTable(logisticspipes.pipes.PipeBlockRequestTable) IIconProvider(logisticspipes.renderer.IIconProvider) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) TileEntity(net.minecraft.tileentity.TileEntity) LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) CoverSides(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.CoverSides) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) IBCPipePluggable(logisticspipes.proxy.buildcraft.subproxies.IBCPipePluggable) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) Block(net.minecraft.block.Block) LPScale(logisticspipes.proxy.object3d.operation.LPScale) BlockRotation(logisticspipes.renderer.newpipe.LogisticsNewSolidBlockWorldRenderer.BlockRotation)

Example 62 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class PathFinder method messureDistanceToNextRoutedPipe.

public static int messureDistanceToNextRoutedPipe(DoubleCoordinates lpPosition, ForgeDirection exitOrientation, World world) {
    int dis = 1;
    TileEntity tile = lpPosition.getTileEntity(world);
    if (tile instanceof LogisticsTileGenericPipe) {
        tile = ((LogisticsTileGenericPipe) tile).getNextConnectedTile(exitOrientation);
    }
    if (tile == null) {
        return 0;
    }
    IPipeInformationProvider info = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(tile);
    while (info != null && !info.isRoutingPipe()) {
        tile = info.getNextConnectedTile(exitOrientation);
        if (tile == null) {
            info = null;
            continue;
        }
        info = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(tile);
        dis++;
    }
    return dis;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 63 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class LogisticsPipeWorldRenderer method renderWorldBlock.

@Override
public boolean renderWorldBlock(IBlockAccess world, int x, int y, int z, Block block, int modelId, RenderBlocks renderer) {
    TileEntity tile = world.getTileEntity(x, y, z);
    if (tile instanceof LogisticsTileGenericPipe) {
        LogisticsTileGenericPipe pipeTile = (LogisticsTileGenericPipe) tile;
        SimpleServiceLocator.thermalDynamicsProxy.renderPipeConnections(pipeTile, renderer);
        if (config.isUseNewRenderer() && !pipeTile.renderState.forceRenderOldPipe) {
            return newRenderer.renderWorldBlock(world, x, y, z, block, modelId, renderer);
        }
        return LogisticsPipeWorldRenderer.renderPipe(renderer, world, (LogisticsBlockGenericPipe) block, pipeTile, x, y, z);
    } else if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        renderer.setRenderBounds(0, 0, 0, 0, 0, 0);
        renderer.renderStandardBlock(Blocks.stone, x, y, z);
        renderer.setRenderBoundsFromBlock(block);
        return true;
    } else {
        return false;
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe)

Example 64 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class LogisticsRenderPipe method renderTileEntityAt.

@Override
public void renderTileEntityAt(TileEntity tileentity, double x, double y, double z, float partialTickTime) {
    double distance = Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosX - tileentity.xCoord, 2) + Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosY - tileentity.yCoord, 2) + Math.pow(Minecraft.getMinecraft().thePlayer.lastTickPosZ - tileentity.zCoord, 2);
    if (tileentity instanceof LogisticsTileGenericPipe) {
        LogisticsTileGenericPipe pipe = ((LogisticsTileGenericPipe) tileentity);
        if (pipe.pipe == null) {
            return;
        }
        if (pipe.pipe instanceof CoreRoutedPipe) {
            renderPipeSigns((CoreRoutedPipe) pipe.pipe, x, y, z, partialTickTime);
        }
        if (LogisticsRenderPipe.config.isUseNewRenderer()) {
            LogisticsRenderPipe.secondRenderer.renderTileEntityAt((LogisticsTileGenericPipe) tileentity, x, y, z, partialTickTime, distance);
        }
        if (LogisticsRenderPipe.config.getRenderPipeContentDistance() * LogisticsRenderPipe.config.getRenderPipeContentDistance() < distance) {
            return;
        }
        bcRenderer.renderWires(pipe, x, y, z);
        // dynamically render pluggables (like gates)
        bcRenderer.dynamicRenderPluggables(pipe, x, y, z);
        if (!pipe.isOpaque()) {
            if (pipe.pipe.transport instanceof PipeFluidTransportLogistics) {
                renderFluids(pipe.pipe, x, y, z);
            }
            if (pipe.pipe.transport instanceof PipeTransportLogistics) {
                renderSolids(pipe.pipe, x, y, z, partialTickTime);
            }
        }
    }
}
Also used : PipeFluidTransportLogistics(logisticspipes.transport.PipeFluidTransportLogistics) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) PipeTransportLogistics(logisticspipes.transport.PipeTransportLogistics)

Example 65 with LogisticsTileGenericPipe

use of logisticspipes.pipes.basic.LogisticsTileGenericPipe in project LogisticsPipes by RS485.

the class PipeMultiBlockTransportLogistics method handleTileReachedClient.

@Override
protected void handleTileReachedClient(LPTravelingItemClient arrivingItem, TileEntity tile, ForgeDirection dir) {
    if (tile instanceof LogisticsTileGenericPipe && ((LogisticsTileGenericPipe) tile).pipe instanceof CoreMultiBlockPipe) {
        passToNextPipe(arrivingItem, tile);
        return;
    } else if (tile instanceof LogisticsTileGenericSubMultiBlock) {
        List<LogisticsTileGenericPipe> masterTile = ((LogisticsTileGenericSubMultiBlock) tile).getMainPipe();
        if (!masterTile.isEmpty()) {
            if (masterTile.size() > 1) {
                throw new UnsupportedOperationException();
            }
            passToNextPipe(arrivingItem, masterTile.get(0));
            return;
        }
    }
    Explosion explosion = new Explosion(this.getWorld(), null, this.getPipe().getX(), this.getPipe().getY(), this.getPipe().getZ(), 4.0F);
    explosion.isFlaming = false;
    explosion.isSmoking = true;
    explosion.doExplosionB(true);
}
Also used : Explosion(net.minecraft.world.Explosion) CoreMultiBlockPipe(logisticspipes.pipes.basic.CoreMultiBlockPipe) LogisticsTileGenericSubMultiBlock(logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) List(java.util.List)

Aggregations

LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)115 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)47 TileEntity (net.minecraft.tileentity.TileEntity)45 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)21 EnumFacing (net.minecraft.util.EnumFacing)15 ArrayList (java.util.ArrayList)14 List (java.util.List)12 EntityPlayer (net.minecraft.entity.player.EntityPlayer)10 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)10 BlockPos (net.minecraft.util.math.BlockPos)10 World (net.minecraft.world.World)9 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)9 HashMap (java.util.HashMap)8 LinkedList (java.util.LinkedList)8 PipeBlockRequestTable (logisticspipes.pipes.PipeBlockRequestTable)8 LogisticsPowerJunctionTileEntity (logisticspipes.blocks.powertile.LogisticsPowerJunctionTileEntity)7 MainProxy (logisticspipes.proxy.MainProxy)7 ExitRoute (logisticspipes.routing.ExitRoute)7 PipeLogisticsChassi (logisticspipes.pipes.PipeLogisticsChassi)6 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)6