Search in sources :

Example 61 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class CoreRoutedPipe method doDebugStuff.

private void doDebugStuff(EntityPlayer entityplayer) {
    //entityplayer.worldObj.setWorldTime(4951);
    IRouter r = getRouter();
    if (!(r instanceof ServerRouter)) {
        return;
    }
    System.out.println("***");
    System.out.println("---------Interests---------------");
    for (Entry<ItemIdentifier, Set<IRouter>> i : ServerRouter.getInterestedInSpecifics().entrySet()) {
        System.out.print(i.getKey().getFriendlyName() + ":");
        for (IRouter j : i.getValue()) {
            System.out.print(j.getSimpleID() + ",");
        }
        System.out.println();
    }
    System.out.print("ALL ITEMS:");
    for (IRouter j : ServerRouter.getInterestedInGeneral()) {
        System.out.print(j.getSimpleID() + ",");
    }
    System.out.println();
    ServerRouter sr = (ServerRouter) r;
    System.out.println(r.toString());
    System.out.println("---------CONNECTED TO---------------");
    for (CoreRoutedPipe adj : sr._adjacent.keySet()) {
        System.out.println(adj.getRouter().getSimpleID());
    }
    System.out.println();
    System.out.println("========DISTANCE TABLE==============");
    for (ExitRoute n : r.getIRoutersByCost()) {
        System.out.println(n.destination.getSimpleID() + " @ " + n.distanceToDestination + " -> " + n.connectionDetails + "(" + n.destination.getId() + ")");
    }
    System.out.println();
    System.out.println("*******EXIT ROUTE TABLE*************");
    List<List<ExitRoute>> table = r.getRouteTable();
    for (int i = 0; i < table.size(); i++) {
        if (table.get(i) != null) {
            if (table.get(i).size() > 0) {
                System.out.println(i + " -> " + table.get(i).get(0).destination.getSimpleID());
                for (ExitRoute route : table.get(i)) {
                    System.out.println("\t\t via " + route.exitOrientation + "(" + route.distanceToDestination + " distance)");
                }
            }
        }
    }
    System.out.println();
    System.out.println("++++++++++CONNECTIONS+++++++++++++++");
    System.out.println(Arrays.toString(ForgeDirection.VALID_DIRECTIONS));
    System.out.println(Arrays.toString(sr.sideDisconnected));
    System.out.println(Arrays.toString(container.pipeConnectionsBuffer));
    System.out.println();
    System.out.println("~~~~~~~~~~~~~~~POWER~~~~~~~~~~~~~~~~");
    System.out.println(r.getPowerProvider());
    System.out.println();
    System.out.println("~~~~~~~~~~~SUBSYSTEMPOWER~~~~~~~~~~~");
    System.out.println(r.getSubSystemPowerProvider());
    System.out.println();
    if (_orderItemManager != null) {
        System.out.println("################ORDERDUMP#################");
        _orderItemManager.dump();
    }
    System.out.println("################END#################");
    refreshConnectionAndRender(true);
    System.out.print("");
    sr.CreateRouteTable(Integer.MAX_VALUE);
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Set(java.util.Set) BitSet(java.util.BitSet) IRouter(logisticspipes.routing.IRouter) ArrayList(java.util.ArrayList) PlayerCollectionList(logisticspipes.utils.PlayerCollectionList) NBTTagList(net.minecraft.nbt.NBTTagList) List(java.util.List) LinkedList(java.util.LinkedList) ServerRouter(logisticspipes.routing.ServerRouter) ExitRoute(logisticspipes.routing.ExitRoute)

Example 62 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class TDDuctInformationProvider method acceptItem.

@Override
public boolean acceptItem(LPTravelingItem item, TileEntity from) {
    if (item instanceof LPTravelingItemServer) {
        LPTravelingItemServer serverItem = (LPTravelingItemServer) item;
        int id = serverItem.getInfo().destinationint;
        if (id == -1) {
            id = SimpleServiceLocator.routerManager.getIDforUUID(serverItem.getInfo().destinationUUID);
        }
        IRouter destination = SimpleServiceLocator.routerManager.getRouter(id);
        if (destination == null) {
            return false;
        }
        RouteCache routes = duct.getCache(true);
        Iterable<Route> paramIterable = routes.outputRoutes;
        Route route = null;
        Object cache = null;
        Triplet<Integer, ItemIdentifier, Boolean> key = new Triplet<>(id, item.getItemIdentifierStack().getItem(), serverItem.getInfo()._transportMode == TransportMode.Active);
        if (duct instanceof ILPTEInformation && ((ILPTEInformation) duct).getObject() != null) {
            cache = ((ILPTEInformation) duct).getObject().getCacheHolder().getCacheFor(CacheTypes.Routing, key);
        }
        if (cache instanceof Route) {
            route = (Route) cache;
            if (!routes.outputRoutes.contains(route)) {
                route = null;
            }
        }
        if (route == null) {
            Pair<Double, Route> closesedConnection = null;
            List<DoubleCoordinates> visited = new ArrayList<>();
            visited.add(new DoubleCoordinates(from));
            for (Route localRoute1 : paramIterable) {
                if (localRoute1.endPoint instanceof LPItemDuct) {
                    LPItemDuct lpDuct = (LPItemDuct) localRoute1.endPoint;
                    double max = Integer.MAX_VALUE;
                    if (closesedConnection != null) {
                        max = closesedConnection.getValue1();
                    }
                    DoubleCoordinates pos = new DoubleCoordinates((TileEntity) lpDuct.pipe);
                    if (visited.contains(pos)) {
                        continue;
                    }
                    visited.add(pos);
                    double distance = lpDuct.pipe.getDistanceTo(id, ForgeDirection.getOrientation(localRoute1.pathDirections.get(localRoute1.pathDirections.size() - 1)).getOpposite(), item.getItemIdentifierStack().getItem(), serverItem.getInfo()._transportMode == TransportMode.Active, localRoute1.pathWeight, max, visited);
                    visited.remove(pos);
                    if (distance != Integer.MAX_VALUE && (closesedConnection == null || distance + localRoute1.pathDirections.size() < closesedConnection.getValue1())) {
                        closesedConnection = new Pair<>(distance + localRoute1.pathWeight, localRoute1);
                    }
                }
            }
            if (closesedConnection != null) {
                route = closesedConnection.getValue2();
            }
        }
        if (route != null) {
            if (duct instanceof ILPTEInformation && ((ILPTEInformation) duct).getObject() != null) {
                ((ILPTEInformation) duct).getObject().getCacheHolder().setCache(CacheTypes.Routing, key, route);
            }
            TravelingItem travelItem = new TravelingItem(item.getItemIdentifierStack().makeNormalStack(), duct, route.copy(), (byte) serverItem.output.ordinal(), (byte) 1);
            travelItem.lpRoutingInformation = serverItem.getInfo();
            duct.insertNewItem(travelItem);
            return true;
        }
    } else {
        return true;
    }
    return false;
}
Also used : ILPTEInformation(logisticspipes.asm.te.ILPTEInformation) Triplet(logisticspipes.utils.tuples.Triplet) ArrayList(java.util.ArrayList) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IRouter(logisticspipes.routing.IRouter) TravelingItem(cofh.thermaldynamics.duct.item.TravelingItem) LPTravelingItem(logisticspipes.transport.LPTravelingItem) RouteCache(cofh.thermaldynamics.multiblock.RouteCache) Route(cofh.thermaldynamics.multiblock.Route) LPTravelingItemServer(logisticspipes.transport.LPTravelingItem.LPTravelingItemServer)

Example 63 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class CrateInventoryHandler method decrStackSize.

@Override
public ItemStack decrStackSize(int i, int j) {
    if (cached == null) {
        initCache();
    }
    Entry<ItemIdentifier, Integer> entry = cached.get(i);
    ItemStack stack = entry.getKey().makeNormalStack(j);
    ItemStack extracted = null;
    int count = _tile.getItemCount(stack);
    if (count <= (_hideOnePerStack ? 1 : 0)) {
        return null;
    }
    extracted = _tile.extractItems(stack, 1);
    entry.setValue(entry.getValue() - j);
    return extracted;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ItemStack(net.minecraft.item.ItemStack)

Example 64 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class DSUInventoryHandler method getItems.

@Override
public Set<ItemIdentifier> getItems() {
    Set<ItemIdentifier> result = new TreeSet<>();
    ItemStack items = _tile.getStoredItemType();
    if (items != null && items.stackSize > 0) {
        result.add(ItemIdentifier.get(items));
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TreeSet(java.util.TreeSet) ItemStack(net.minecraft.item.ItemStack)

Example 65 with ItemIdentifier

use of logisticspipes.utils.item.ItemIdentifier in project LogisticsPipes by RS485.

the class RequestHandler method refresh.

public static void refresh(EntityPlayer player, CoreRoutedPipe pipe, DisplayOptions option) {
    Map<ItemIdentifier, Integer> _availableItems;
    LinkedList<ItemIdentifier> _craftableItems;
    if (option == DisplayOptions.SupplyOnly || option == DisplayOptions.Both) {
        _availableItems = SimpleServiceLocator.logisticsManager.getAvailableItems(pipe.getRouter().getIRoutersByCost());
    } else {
        _availableItems = new HashMap<>();
    }
    if (option == DisplayOptions.CraftOnly || option == DisplayOptions.Both) {
        _craftableItems = SimpleServiceLocator.logisticsManager.getCraftableItems(pipe.getRouter().getIRoutersByCost());
    } else {
        _craftableItems = new LinkedList<>();
    }
    TreeSet<ItemIdentifierStack> _allItems = new TreeSet<>();
    for (Entry<ItemIdentifier, Integer> item : _availableItems.entrySet()) {
        ItemIdentifierStack newStack = item.getKey().makeStack(item.getValue());
        _allItems.add(newStack);
    }
    for (ItemIdentifier item : _craftableItems) {
        if (_availableItems.containsKey(item)) {
            continue;
        }
        _allItems.add(item.makeStack(0));
    }
    MainProxy.sendPacketToPlayer(PacketHandler.getPacket(OrdererContent.class).setIdentSet(_allItems), player);
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TreeSet(java.util.TreeSet) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Aggregations

ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)69 ItemStack (net.minecraft.item.ItemStack)37 ArrayList (java.util.ArrayList)23 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)23 HashMap (java.util.HashMap)14 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)13 TreeSet (java.util.TreeSet)12 IFilter (logisticspipes.interfaces.routing.IFilter)11 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)11 LinkedList (java.util.LinkedList)10 List (java.util.List)10 Map (java.util.Map)10 SinkReply (logisticspipes.utils.SinkReply)10 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)9 IRouter (logisticspipes.routing.IRouter)9 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)9 BitSet (java.util.BitSet)8 Entry (java.util.Map.Entry)7 LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)7 SimpleServiceLocator (logisticspipes.proxy.SimpleServiceLocator)7