Search in sources :

Example 21 with LogisticsModule

use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.

the class PipeLogisticsChassis method collectSpecificInterests.

@Override
public void collectSpecificInterests(@Nonnull Collection<ItemIdentifier> itemidCollection) {
    // if we don't have a pointed inventory we can't be interested in anything
    if (getPointedAdjacentOrNoAdjacent().inventories().isEmpty()) {
        return;
    }
    for (int moduleIndex = 0; moduleIndex < getChassisSize(); moduleIndex++) {
        LogisticsModule module = getSubModule(moduleIndex);
        if (module != null && module.interestedInAttachedInventory()) {
            final ISlotUpgradeManager upgradeManager = getUpgradeManager(module.getSlot(), module.getPositionInt());
            IInventoryUtil inv = PipeServiceProviderUtilKt.availableSneakyInventories(this, upgradeManager).stream().findFirst().orElse(null);
            if (inv == null) {
                continue;
            }
            Set<ItemIdentifier> items = inv.getItems();
            itemidCollection.addAll(items);
            // also add tag-less variants ... we should probably add a module.interestedIgnoringNBT at some point
            items.stream().map(ItemIdentifier::getIgnoringNBT).forEach(itemidCollection::add);
            boolean modulesInterestedInUndamged = false;
            for (int i = 0; i < getChassisSize(); i++) {
                if (getSubModule(moduleIndex).interestedInUndamagedID()) {
                    modulesInterestedInUndamged = true;
                    break;
                }
            }
            if (modulesInterestedInUndamged) {
                items.stream().map(ItemIdentifier::getUndamaged).forEach(itemidCollection::add);
            }
            // no need to check other modules for interest in the inventory, when we know that 1 already is.
            break;
        }
    }
    for (int i = 0; i < getChassisSize(); i++) {
        LogisticsModule module = getSubModule(i);
        if (module != null) {
            module.collectSpecificInterests(itemidCollection);
        }
    }
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) LogisticsModule(logisticspipes.modules.LogisticsModule) IInventoryUtil(logisticspipes.interfaces.IInventoryUtil) ISlotUpgradeManager(logisticspipes.interfaces.ISlotUpgradeManager)

Example 22 with LogisticsModule

use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.

the class PipeLogisticsChassis method addToBuffer.

@Override
public int addToBuffer(ItemIdentifierStack item, IAdditionalTargetInformation info) {
    if (MainProxy.isServer(getWorld())) {
        if (info instanceof ChassiTargetInformation) {
            ChassiTargetInformation target = (ChassiTargetInformation) info;
            LogisticsModule module = getSubModule(target.moduleSlot);
            if (module instanceof IBufferItems) {
                return ((IBufferItems) module).addToBuffer(item, info);
            }
        } else {
            if (LogisticsPipes.isDEBUG()) {
                System.out.println(item);
                new RuntimeException("[AddToBuffer] Information weren't ment for a chassi pipe").printStackTrace();
            }
        }
    }
    return item.getStackSize();
}
Also used : IBufferItems(logisticspipes.interfaces.IBufferItems) LogisticsModule(logisticspipes.modules.LogisticsModule)

Example 23 with LogisticsModule

use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.

the class PipeLogisticsChassis method onAllowedRemoval.

@Override
public void onAllowedRemoval() {
    _moduleInventory.removeListener(this);
    if (MainProxy.isServer(getWorld())) {
        for (int i = 0; i < getChassisSize(); i++) {
            LogisticsModule x = getSubModule(i);
            if (x instanceof ILegacyActiveModule) {
                ILegacyActiveModule y = (ILegacyActiveModule) x;
                y.onBlockRemoval();
            }
        }
        for (int i = 0; i < _moduleInventory.getSizeInventory(); i++) {
            ItemIdentifierStack ms = _moduleInventory.getIDStackInSlot(i);
            if (ms != null) {
                ItemStack stack = ms.makeNormalStack();
                ItemModuleInformationManager.saveInformation(stack, getSubModule(i));
                _moduleInventory.setInventorySlotContents(i, stack);
            }
        }
        _moduleInventory.dropContents(getWorld(), getX(), getY(), getZ());
        for (int i = 0; i < getChassisSize(); i++) {
            getModuleUpgradeManager(i).dropUpgrades();
        }
    }
}
Also used : ILegacyActiveModule(logisticspipes.interfaces.ILegacyActiveModule) LogisticsModule(logisticspipes.modules.LogisticsModule) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack)

Example 24 with LogisticsModule

use of logisticspipes.modules.LogisticsModule in project LogisticsPipes by RS485.

the class CraftingRecipes method registerResetRecipe.

private void registerResetRecipe(String[] dyes) {
    for (ResourceLocation moduleResource : LPItems.modules.values()) {
        final Item item = Item.REGISTRY.getObject(moduleResource);
        if (item instanceof ItemModule) {
            LogisticsModule module = ((ItemModule) item).getModuleForItem(new ItemStack(item), null, null, null);
            if (module == null)
                continue;
            NBTTagCompound tag = new NBTTagCompound();
            module.writeToNBT(tag);
            if (!tag.hasNoTags()) {
                RecipeManager.craftingManager.addShapelessResetRecipe(item, 0);
            }
        }
    }
    for (int i = 1; i < 17; i++) {
        RecipeManager.craftingManager.addOrdererRecipe(new ItemStack(LPItems.remoteOrderer, 1, i), dyes[i - 1], new ItemStack(LPItems.remoteOrderer, 1, -1));
        RecipeManager.craftingManager.addShapelessResetRecipe(LPItems.remoteOrderer, i);
    }
    RecipeManager.craftingManager.addShapelessResetRecipe(LPItems.remoteOrderer, 0);
}
Also used : Item(net.minecraft.item.Item) LogisticsModule(logisticspipes.modules.LogisticsModule) ResourceLocation(net.minecraft.util.ResourceLocation) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack) ItemModule(logisticspipes.items.ItemModule)

Aggregations

LogisticsModule (logisticspipes.modules.LogisticsModule)24 ItemStack (net.minecraft.item.ItemStack)5 ILegacyActiveModule (logisticspipes.interfaces.ILegacyActiveModule)4 PipeLogisticsChassis (logisticspipes.pipes.PipeLogisticsChassis)3 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)3 Gui (network.rs485.logisticspipes.module.Gui)3 Nullable (javax.annotation.Nullable)2 IRequireReliableTransport (logisticspipes.interfaces.routing.IRequireReliableTransport)2 ItemModule (logisticspipes.items.ItemModule)2 LogisticsTileGenericPipe (logisticspipes.pipes.basic.LogisticsTileGenericPipe)2 DummyWorldProvider (logisticspipes.utils.DummyWorldProvider)2 SinkReply (logisticspipes.utils.SinkReply)2 DummyModuleContainer (logisticspipes.utils.gui.DummyModuleContainer)2 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)2 ContainerPlayer (net.minecraft.inventory.ContainerPlayer)2 GuiChassisPipe (logisticspipes.gui.GuiChassisPipe)1 GuiSneakyConfigurator (logisticspipes.gui.modules.GuiSneakyConfigurator)1 GuiStringBasedItemSink (logisticspipes.gui.modules.GuiStringBasedItemSink)1 IBufferItems (logisticspipes.interfaces.IBufferItems)1 IHUDButton (logisticspipes.interfaces.IHUDButton)1