Search in sources :

Example 21 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class BCPipeInformationProvider method getDistanceTo.

@Override
public double getDistanceTo(int destinationint, ForgeDirection ignore, ItemIdentifier ident, boolean isActive, double traveled, double max, List<DoubleCoordinates> visited) {
    if (traveled >= max) {
        return Integer.MAX_VALUE;
    }
    for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS) {
        if (ignore == dir) {
            continue;
        }
        IPipeInformationProvider information = SimpleServiceLocator.pipeInformationManager.getInformationProviderFor(getNextConnectedTile(dir));
        if (information != null) {
            DoubleCoordinates pos = new DoubleCoordinates(information);
            if (visited.contains(pos)) {
                continue;
            }
            visited.add(pos);
            double result = information.getDistanceTo(destinationint, dir.getOpposite(), ident, isActive, traveled + getDistance(), max, visited);
            visited.remove(pos);
            if (result == Integer.MAX_VALUE) {
                return result;
            }
            return result + (int) getDistance();
        }
    }
    return Integer.MAX_VALUE;
}
Also used : IPipeInformationProvider(logisticspipes.routing.pathfinder.IPipeInformationProvider) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 22 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class EnderIOTransceiverConnection method getConnections.

@Override
public Collection<TileEntity> getConnections(TileEntity tile) {
    boolean onlyOnePipe = false;
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(tile), direction);
        TileEntity candidate = p.getTileEntity(tile.getWorldObj());
        if (candidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(tile, candidate, direction)) {
            if (onlyOnePipe) {
                onlyOnePipe = false;
                break;
            } else {
                onlyOnePipe = true;
            }
        }
    }
    if (!onlyOnePipe || !SimpleServiceLocator.enderIOProxy.isSendAndReceive(tile)) {
        return new ArrayList<>(0);
    }
    List<? extends TileEntity> connections = SimpleServiceLocator.enderIOProxy.getConnectedTransceivers(tile);
    Set<TileEntity> set = new HashSet<>();
    for (TileEntity connected : connections) {
        if (!SimpleServiceLocator.enderIOProxy.isSendAndReceive(connected)) {
            continue;
        }
        LogisticsTileGenericPipe pipe = null;
        for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
            DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(connected), direction);
            TileEntity candidate = p.getTileEntity(tile.getWorldObj());
            if (candidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(connected, candidate, direction)) {
                if (pipe != null) {
                    pipe = null;
                    break;
                } else {
                    pipe = (LogisticsTileGenericPipe) candidate;
                }
            }
        }
        if (pipe != null && pipe.pipe instanceof CoreRoutedPipe) {
            set.add(pipe);
        }
    }
    if (set.size() == 1) {
        return set;
    } else {
        return new ArrayList<>(0);
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) ArrayList(java.util.ArrayList) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) HashSet(java.util.HashSet)

Example 23 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class ClientViewController method updateList.

public void updateList(RoutingUpdateDebugCanidateList routingUpdateDebugCanidateList) {
    debugWindow.clear();
    ExitRoute[] e = routingUpdateDebugCanidateList.getMsg();
    int i = 0;
    for (ExitRoute exit : e) {
        i++;
        Color color = Color.BLACK;
        if (exit.debug.isNewlyAddedCanidate) {
            color = Color.BLUE;
        }
        debugWindow.showInfo(exit.destination.toString(), color);
        debugWindow.showInfo("\n", color);
        for (int j = 0; j < 2; j++) {
            debugWindow.showInfo("\t", color);
        }
        debugWindow.showInfo(exit.debug.toStringNetwork, color);
        debugWindow.showInfo("\n", color);
        DoubleCoordinates pos = exit.destination.getLPPosition();
        getDebugInformation(pos).routes.add(exit);
        getDebugInformation(pos).positions.add(i);
    }
    listHUD.addAll(HUDPositions.entrySet().stream().map(entry -> new HUDRoutingTableDebugProvider(new HUDRoutingTableGeneralInfo(entry.getValue()), entry.getKey())).collect(Collectors.toList()));
}
Also used : Color(java.awt.Color) ExitRoute(logisticspipes.routing.ExitRoute) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 24 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsNewRenderPipe method renderList.

private void renderList(TileEntity subTile, double x, double y, double z, GLRenderList renderList, List<RenderEntry> cachedRenderer, boolean recalculateList) {
    if (!renderList.isFilled() || recalculateList) {
        ResourceLocation oldTexture = null;
        renderList.startListCompile();
        SimpleServiceLocator.cclProxy.getRenderState().reset();
        SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
        SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
        int brightness = new DoubleCoordinates(subTile).getBlock(subTile.getWorldObj()).getMixedBrightnessForBlock(subTile.getWorldObj(), subTile.xCoord, subTile.yCoord, subTile.zCoord);
        SimpleServiceLocator.cclProxy.getRenderState().setBrightness(brightness);
        boolean tesselating = false;
        for (RenderEntry model : cachedRenderer) {
            ResourceLocation texture = model.getTexture();
            if (texture == null) {
                throw new NullPointerException();
            }
            if (texture != oldTexture || oldTexture == null) {
                if (tesselating) {
                    SimpleServiceLocator.cclProxy.getRenderState().draw();
                    tesselating = false;
                }
                oldTexture = texture;
                Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
                SimpleServiceLocator.cclProxy.getRenderState().reset();
                SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
                SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
                SimpleServiceLocator.cclProxy.getRenderState().setBrightness(brightness);
                SimpleServiceLocator.cclProxy.getRenderState().startDrawing();
                tesselating = true;
            }
            model.getModel().render(model.getOperations());
        }
        if (tesselating) {
            SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
            SimpleServiceLocator.cclProxy.getRenderState().draw();
        }
        renderList.stopCompile();
    }
    if (renderList != null) {
        GL11.glPushMatrix();
        GL11.glTranslated(x, y, z);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ZERO);
        renderList.render();
        GL11.glDisable(GL11.GL_BLEND);
        GL11.glPopMatrix();
    }
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Example 25 with DoubleCoordinates

use of network.rs485.logisticspipes.world.DoubleCoordinates in project LogisticsPipes by RS485.

the class LogisticsNewSolidBlockWorldRenderer method renderWorldBlock.

public void renderWorldBlock(IBlockAccess world, LogisticsSolidTileEntity blockTile, RenderBlocks renderer, int x, int y, int z) {
    Tessellator tess = Tessellator.instance;
    SimpleServiceLocator.cclProxy.getRenderState().reset();
    SimpleServiceLocator.cclProxy.getRenderState().setUseNormals(true);
    SimpleServiceLocator.cclProxy.getRenderState().setAlphaOverride(0xff);
    BlockRotation rotation = BlockRotation.ZERO;
    int brightness = 0;
    IIconTransformation icon;
    if (blockTile != null) {
        BlockRotation.getRotation(blockTile.getRotation());
        brightness = new DoubleCoordinates(blockTile).getBlock(world).getMixedBrightnessForBlock(world, blockTile.xCoord, blockTile.yCoord, blockTile.zCoord);
        icon = SimpleServiceLocator.cclProxy.createIconTransformer(LogisticsSolidBlock.getNewIcon(world, blockTile.xCoord, blockTile.yCoord, blockTile.zCoord));
    } else {
        brightness = LogisticsPipes.LogisticsSolidBlock.getMixedBrightnessForBlock(world, x, y, z);
        icon = SimpleServiceLocator.cclProxy.createIconTransformer(LogisticsSolidBlock.getNewIcon(world, x, y, z));
    }
    tess.setColorOpaque_F(1F, 1F, 1F);
    tess.setBrightness(brightness);
    //Draw
    LogisticsNewSolidBlockWorldRenderer.block.get(rotation).render(new LPTranslation(x, y, z), icon);
    if (blockTile != null) {
        DoubleCoordinates pos = new DoubleCoordinates(blockTile);
        for (CoverSides side : CoverSides.values()) {
            boolean render = true;
            DoubleCoordinates newPos = CoordinateUtils.sum(pos, side.getDir(rotation));
            TileEntity sideTile = newPos.getTileEntity(blockTile.getWorldObj());
            if (sideTile instanceof LogisticsTileGenericPipe) {
                LogisticsTileGenericPipe tilePipe = (LogisticsTileGenericPipe) sideTile;
                if (tilePipe.renderState.pipeConnectionMatrix.isConnected(side.getDir(rotation).getOpposite())) {
                    render = false;
                }
            }
            if (render) {
                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);
            }
        }
    }
}
Also used : LPTranslation(logisticspipes.proxy.object3d.operation.LPTranslation) LogisticsSolidTileEntity(logisticspipes.blocks.LogisticsSolidTileEntity) TileEntity(net.minecraft.tileentity.TileEntity) Tessellator(net.minecraft.client.renderer.Tessellator) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) IIconTransformation(logisticspipes.proxy.object3d.interfaces.IIconTransformation) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates)

Aggregations

DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)70 TileEntity (net.minecraft.tileentity.TileEntity)44 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)21 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)15 ArrayList (java.util.ArrayList)14 LPPositionSet (logisticspipes.utils.LPPositionSet)10 Block (net.minecraft.block.Block)10 SideOnly (cpw.mods.fml.relauncher.SideOnly)8 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)8 ItemStack (net.minecraft.item.ItemStack)8 World (net.minecraft.world.World)8 LogisticsTileGenericSubMultiBlock (logisticspipes.pipes.basic.LogisticsTileGenericSubMultiBlock)6 AxisAlignedBB (net.minecraft.util.AxisAlignedBB)6 IIcon (net.minecraft.util.IIcon)6 DockingStation (buildcraft.api.robots.DockingStation)5 MovingObjectPosition (net.minecraft.util.MovingObjectPosition)5 DoubleCoordinatesType (network.rs485.logisticspipes.world.DoubleCoordinatesType)5 EntityRobotBase (buildcraft.api.robots.EntityRobotBase)4 PipePluggable (buildcraft.api.transport.pluggable.PipePluggable)4 RobotStationPluggable (buildcraft.robotics.RobotStationPluggable)4