Search in sources :

Example 21 with CoreRoutedPipe

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

the class PipeItemsInvSysConnector method invalidate.

@Override
public void invalidate() {
    if (!stillNeedReplace) {
        CoreRoutedPipe CRP = SimpleServiceLocator.connectionManager.getConnectedPipe(getRouter());
        SimpleServiceLocator.connectionManager.removeDirectConnection(getRouter());
        if (CRP != null) {
            CRP.refreshRender(true);
        }
    }
    init = false;
    super.invalidate();
}
Also used : CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 22 with CoreRoutedPipe

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

the class PipeItemsInvSysConnector method enabledUpdateEntity.

@Override
public void enabledUpdateEntity() {
    super.enabledUpdateEntity();
    if (!init) {
        if (hasConnectionUUID()) {
            if (!SimpleServiceLocator.connectionManager.addDirectConnection(getConnectionUUID(), getRouter())) {
                dropFreqCard();
            }
            CoreRoutedPipe CRP = SimpleServiceLocator.connectionManager.getConnectedPipe(getRouter());
            if (CRP != null) {
                CRP.refreshRender(true);
            }
            getRouter().update(true, this);
            refreshRender(true);
            init = true;
            idbuffer = getConnectionUUID();
        }
    }
    if (init && !hasConnectionUUID()) {
        init = false;
        CoreRoutedPipe CRP = SimpleServiceLocator.connectionManager.getConnectedPipe(getRouter());
        SimpleServiceLocator.connectionManager.removeDirectConnection(getRouter());
        if (CRP != null) {
            CRP.refreshRender(true);
        }
    }
    if (init && idbuffer != null && !idbuffer.equals(getConnectionUUID())) {
        init = false;
        CoreRoutedPipe CRP = SimpleServiceLocator.connectionManager.getConnectedPipe(getRouter());
        SimpleServiceLocator.connectionManager.removeDirectConnection(getRouter());
        if (CRP != null) {
            CRP.refreshRender(true);
        }
    }
    if (itemsOnRoute.size() > 0) {
        checkConnectedInvs();
    }
}
Also used : CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 23 with CoreRoutedPipe

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

the class EnderIOHyperCubeConnection method transmit.

@Override
public void transmit(TileEntity tile, IRoutedItem data) {
    List<TileEntity> list = getConnections(tile);
    if (list.size() < 1) {
        return;
    }
    TileEntity pipe = list.get(0);
    if (pipe instanceof LogisticsTileGenericPipe) {
        ((CoreRoutedPipe) ((LogisticsTileGenericPipe) pipe).pipe).queueUnroutedItemInformation(data.getItemIdentifierStack().clone(), data.getInfo());
    } else {
        new RuntimeException("Only LP pipes can be next to Tesseracts to queue item information").printStackTrace();
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 24 with CoreRoutedPipe

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

the class EnderIOHyperCubeConnection method getConnections.

@Override
public List<TileEntity> getConnections(TileEntity tile) {
    boolean onlyOnePipe = false;
    for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) {
        DoubleCoordinates p = CoordinateUtils.add(new DoubleCoordinates(tile), direction);
        TileEntity canidate = p.getTileEntity(tile.getWorldObj());
        if (canidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(tile, canidate, 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.getConnectedHyperCubes(tile);
    List<TileEntity> list = new ArrayList<>();
    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 canidate = p.getTileEntity(tile.getWorldObj());
            if (canidate instanceof LogisticsTileGenericPipe && MainProxy.checkPipesConnections(connected, canidate, direction)) {
                if (pipe != null) {
                    pipe = null;
                    break;
                } else {
                    pipe = (LogisticsTileGenericPipe) canidate;
                }
            }
        }
        if (pipe != null && pipe.pipe instanceof CoreRoutedPipe) {
            list.add(pipe);
        }
    }
    if (list.size() == 1) {
        return list;
    } 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)

Example 25 with CoreRoutedPipe

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

the class ItemAmountPipeSign method spread.

private void spread(Map<ItemIdentifier, Integer> availableItems, BitSet set) {
    // Improve performance by updating a wall of Amount pipe signs all at once
    IRouter router = pipe.getRouter();
    if (set.get(router.getSimpleID()))
        return;
    set.set(router.getSimpleID());
    for (ExitRoute exit : router.getIRoutersByCost()) {
        // Only when the signs are in one wall. To not spread to far.
        if (exit.distanceToDestination > 2)
            break;
        if (!exit.filters.isEmpty())
            continue;
        if (set.get(exit.destination.getSimpleID()))
            continue;
        if (exit.connectionDetails.contains(PipeRoutingConnectionType.canRequestFrom) && exit.connectionDetails.contains(PipeRoutingConnectionType.canRouteTo)) {
            CoreRoutedPipe cachedPipe = exit.destination.getCachedPipe();
            if (cachedPipe != null) {
                List<Pair<ForgeDirection, IPipeSign>> pipeSigns = cachedPipe.getPipeSigns();
                pipeSigns.stream().filter(signPair -> signPair != null && signPair.getValue2() instanceof ItemAmountPipeSign).forEach(signPair -> ((ItemAmountPipeSign) signPair.getValue2()).updateStats(availableItems, set));
            }
        }
    }
}
Also used : IRouter(logisticspipes.routing.IRouter) Item(net.minecraft.item.Item) MainProxy(logisticspipes.proxy.MainProxy) StringUtils(logisticspipes.utils.string.StringUtils) ItemStack(net.minecraft.item.ItemStack) Map(java.util.Map) LogisticsRenderPipe(logisticspipes.renderer.LogisticsRenderPipe) GL11(org.lwjgl.opengl.GL11) ItemAmountSignUpdatePacket(logisticspipes.network.packets.pipe.ItemAmountSignUpdatePacket) ModernPacket(logisticspipes.network.abstractpackets.ModernPacket) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) NewGuiHandler(logisticspipes.network.NewGuiHandler) PipeRoutingConnectionType(logisticspipes.routing.PipeRoutingConnectionType) Side(cpw.mods.fml.relauncher.Side) ItemAmountSignGui(logisticspipes.network.guis.item.ItemAmountSignGui) SideOnly(cpw.mods.fml.relauncher.SideOnly) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ItemIdentifierInventory(logisticspipes.utils.item.ItemIdentifierInventory) PacketHandler(logisticspipes.network.PacketHandler) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) ExitRoute(logisticspipes.routing.ExitRoute) ServerRouter(logisticspipes.routing.ServerRouter) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) ISimpleInventoryEventHandler(logisticspipes.utils.ISimpleInventoryEventHandler) List(java.util.List) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) FontRenderer(net.minecraft.client.gui.FontRenderer) EntityPlayer(net.minecraft.entity.player.EntityPlayer) Pair(logisticspipes.utils.tuples.Pair) IInventory(net.minecraft.inventory.IInventory) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) Data(lombok.Data) BitSet(java.util.BitSet) IRouter(logisticspipes.routing.IRouter) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ExitRoute(logisticspipes.routing.ExitRoute) Pair(logisticspipes.utils.tuples.Pair)

Aggregations

CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)68 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)43 TileEntity (net.minecraft.tileentity.TileEntity)22 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)16 ExitRoute (logisticspipes.routing.ExitRoute)15 ArrayList (java.util.ArrayList)14 LinkedList (java.util.LinkedList)13 IRouter (logisticspipes.routing.IRouter)11 Pair (logisticspipes.utils.tuples.Pair)10 DoubleCoordinates (network.rs485.logisticspipes.world.DoubleCoordinates)10 List (java.util.List)9 HashMap (java.util.HashMap)8 IFilter (logisticspipes.interfaces.routing.IFilter)8 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7 Map (java.util.Map)6 PipeRoutingConnectionType (logisticspipes.routing.PipeRoutingConnectionType)6 World (net.minecraft.world.World)6 BitSet (java.util.BitSet)5 Collections (java.util.Collections)5 EnumSet (java.util.EnumSet)5