Search in sources :

Example 36 with ItemIdentifier

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

the class AEInterfaceInventoryHandler method decrStackSize.

@Override
public ItemStack decrStackSize(int i, int j) {
    if (cached == null) {
        initCache();
    }
    Entry<ItemIdentifier, Integer> entry = cached.get(i);
    ItemStack extracted = getMultipleItems(entry.getKey(), j);
    entry.setValue(entry.getValue() - j);
    return extracted;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) ItemStack(net.minecraft.item.ItemStack) IAEItemStack(appeng.api.storage.data.IAEItemStack)

Example 37 with ItemIdentifier

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

the class AEInterfaceInventoryHandler method getItemsAndCount.

private Map<ItemIdentifier, Integer> getItemsAndCount(boolean linked) {
    Map<ItemIdentifier, Integer> result;
    if (linked) {
        result = new LinkedHashMap<>();
    } else {
        result = new HashMap<>();
    }
    IStorageMonitorable tmp = tile.getMonitorable(dir, source);
    if (tmp == null || tmp.getItemInventory() == null || tmp.getItemInventory().getStorageList() == null) {
        return result;
    }
    for (IAEItemStack items : tmp.getItemInventory().getStorageList()) {
        ItemIdentifier ident = ItemIdentifier.get(items.getItemStack());
        Integer count = result.get(ident);
        if (count != null) {
            result.put(ident, (int) (count + items.getStackSize() - (hideOnePerStack ? 1 : 0)));
        } else {
            result.put(ident, (int) (items.getStackSize() - (hideOnePerStack ? 1 : 0)));
        }
    }
    return result;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) IAEItemStack(appeng.api.storage.data.IAEItemStack) IStorageMonitorable(appeng.api.storage.IStorageMonitorable)

Example 38 with ItemIdentifier

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

the class BarrelInventoryHandler method getItemsAndCount.

@Override
public HashMap<ItemIdentifier, Integer> getItemsAndCount() {
    HashMap<ItemIdentifier, Integer> map = new HashMap<ItemIdentifier, Integer>();
    try {
        ItemStack itemStack = (ItemStack) BarrelInventoryHandler.item.get(_tile);
        if (itemStack != null) {
            int value = (Integer) BarrelInventoryHandler.getItemCount.invoke(_tile, new Object[] {});
            map.put(ItemIdentifier.get(itemStack), value - (_hideOnePerStack ? 1 : 0));
        }
    } catch (IllegalArgumentException e) {
        e.printStackTrace();
    } catch (IllegalAccessException e) {
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        e.printStackTrace();
    }
    return map;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) HashMap(java.util.HashMap) ItemStack(net.minecraft.item.ItemStack) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 39 with ItemIdentifier

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

the class ServerRouter method updateInterests.

@Override
public void updateInterests() {
    if (--ticksUntillNextInventoryCheck > 0) {
        return;
    }
    ticksUntillNextInventoryCheck = ServerRouter.REFRESH_TIME;
    if (ServerRouter.iterated++ % simpleID == 0) {
        // randomly wait 1 extra tick - just so that every router doesn't tick at the same time
        ticksUntillNextInventoryCheck++;
    }
    if (ServerRouter.iterated >= ServerRouter.getBiggestSimpleID()) {
        ServerRouter.iterated = 0;
    }
    CoreRoutedPipe pipe = getPipe();
    if (pipe == null) {
        return;
    }
    if (pipe.hasGenericInterests()) {
        declareGenericInterest();
    } else {
        removeGenericInterest();
    }
    Set<ItemIdentifier> newInterests = pipe.getSpecificInterests();
    if (newInterests == null) {
        newInterests = new TreeSet<>();
    }
    if (!newInterests.equals(_hasInterestIn)) {
        for (ItemIdentifier i : _hasInterestIn) {
            if (!newInterests.contains(i)) {
                removeInterest(i);
            }
        }
        newInterests.stream().filter(i -> !_hasInterestIn.contains(i)).forEach(this::addInterest);
        _hasInterestIn = newInterests;
    }
}
Also used : LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) PriorityQueue(java.util.PriorityQueue) Quartet(logisticspipes.utils.tuples.Quartet) Particles(logisticspipes.pipefxhandlers.Particles) MainProxy(logisticspipes.proxy.MainProxy) ILogisticsPowerProvider(logisticspipes.api.ILogisticsPowerProvider) Configs(logisticspipes.config.Configs) StackTraceUtil(logisticspipes.utils.StackTraceUtil) Map(java.util.Map) ILPTEInformation(logisticspipes.asm.te.ILPTEInformation) EnumSet(java.util.EnumSet) ITileEntityChangeListener(logisticspipes.asm.te.ITileEntityChangeListener) EnumMap(java.util.EnumMap) FluidResource(logisticspipes.request.resources.FluidResource) CacheHolder(logisticspipes.utils.CacheHolder) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) Set(java.util.Set) LPTickHandler(logisticspipes.ticks.LPTickHandler) UUID(java.util.UUID) DictResource(logisticspipes.request.resources.DictResource) ForgeDirection(net.minecraftforge.common.util.ForgeDirection) Collectors(java.util.stream.Collectors) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) Info(logisticspipes.utils.StackTraceUtil.Info) List(java.util.List) SimpleServiceLocator(logisticspipes.proxy.SimpleServiceLocator) IFilter(logisticspipes.interfaces.routing.IFilter) Pair(logisticspipes.utils.tuples.Pair) Entry(java.util.Map.Entry) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe) ItemResource(logisticspipes.request.resources.ItemResource) Setter(lombok.Setter) Getter(lombok.Getter) LogisticsTileGenericPipe(logisticspipes.pipes.basic.LogisticsTileGenericPipe) HashMap(java.util.HashMap) ReentrantReadWriteLock(java.util.concurrent.locks.ReentrantReadWriteLock) TreeSet(java.util.TreeSet) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) ISubSystemPowerProvider(logisticspipes.interfaces.ISubSystemPowerProvider) AccessLevel(lombok.AccessLevel) IRoutingDebugAdapter(logisticspipes.interfaces.IRoutingDebugAdapter) LPTileEntityObject(logisticspipes.asm.te.LPTileEntityObject) PathFinder(logisticspipes.routing.pathfinder.PathFinder) OneList(logisticspipes.utils.OneList) WeakReference(java.lang.ref.WeakReference) LinkedList(java.util.LinkedList) LPConstants(logisticspipes.LPConstants) DimensionManager(net.minecraftforge.common.DimensionManager) RoutingTableUpdateThread(logisticspipes.ticks.RoutingTableUpdateThread) Iterator(java.util.Iterator) World(net.minecraft.world.World) IResource(logisticspipes.request.resources.IResource) Lock(java.util.concurrent.locks.Lock) PipeItemsFirewall(logisticspipes.pipes.PipeItemsFirewall) TileEntity(net.minecraft.tileentity.TileEntity) BitSet(java.util.BitSet) Collections(java.util.Collections) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) CoreRoutedPipe(logisticspipes.pipes.basic.CoreRoutedPipe)

Example 40 with ItemIdentifier

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

the class CrateInventoryHandler method getItemsAndCount.

private Map<ItemIdentifier, Integer> getItemsAndCount(boolean linked) {
    HashMap<ItemIdentifier, Integer> map = new HashMap<>((int) (_tile.getUniqueItems() * 1.5));
    for (ItemStack stack : _tile.getContents()) {
        ItemIdentifier itemId = ItemIdentifier.get(stack);
        int stackSize = stack.stackSize - (_hideOnePerStack ? 1 : 0);
        Integer m = map.get(itemId);
        if (m == null) {
            map.put(itemId, stackSize);
        } else {
            map.put(itemId, m + stackSize);
        }
    }
    return map;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) HashMap(java.util.HashMap) ItemStack(net.minecraft.item.ItemStack)

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