Search in sources :

Example 11 with LogisticsModule

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

the class PipeLogisticsChassi method fullFill.

@Override
public LogisticsOrder fullFill(LogisticsPromise promise, IRequestItems destination, IAdditionalTargetInformation info) {
    if (!isEnabled()) {
        return null;
    }
    for (int i = 0; i < getChassiSize(); i++) {
        LogisticsModule x = _module.getSubModule(i);
        if (x instanceof ILegacyActiveModule) {
            ILegacyActiveModule y = (ILegacyActiveModule) x;
            LogisticsOrder result = y.fullFill(promise, destination, info);
            if (result != null) {
                spawnParticle(Particles.WhiteParticle, 2);
                return result;
            }
        }
    }
    return null;
}
Also used : ILegacyActiveModule(logisticspipes.interfaces.ILegacyActiveModule) LogisticsOrder(logisticspipes.routing.order.LogisticsOrder) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule)

Example 12 with LogisticsModule

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

the class PipeLogisticsChassi method itemLost.

@Override
public void itemLost(ItemIdentifierStack item, IAdditionalTargetInformation info) {
    if (MainProxy.isServer(getWorld())) {
        if (info instanceof ChassiTargetInformation) {
            ChassiTargetInformation target = (ChassiTargetInformation) info;
            LogisticsModule module = _module.getSubModule(target.moduleSlot);
            if (module instanceof IRequireReliableTransport) {
                ((IRequireReliableTransport) module).itemLost(item, info);
            }
        } else {
            if (LPConstants.DEBUG) {
                System.out.println(item);
                new RuntimeException("[ItemLost] Information weren't ment for a chassi pipe").printStackTrace();
            }
        }
    }
}
Also used : LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) IRequireReliableTransport(logisticspipes.interfaces.routing.IRequireReliableTransport)

Example 13 with LogisticsModule

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

the class PipeLogisticsChassi method addToBuffer.

@Override
public int addToBuffer(ItemIdentifierStack item, IAdditionalTargetInformation info) {
    if (MainProxy.isServer(getWorld())) {
        if (info instanceof ChassiTargetInformation) {
            ChassiTargetInformation target = (ChassiTargetInformation) info;
            LogisticsModule module = _module.getSubModule(target.moduleSlot);
            if (module instanceof IBufferItems) {
                return ((IBufferItems) module).addToBuffer(item, info);
            }
        } else {
            if (LPConstants.DEBUG) {
                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.abstractmodules.LogisticsModule)

Example 14 with LogisticsModule

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

the class Recipes method loadRecipes.

@Override
public void loadRecipes() {
    String[] dyes = { "dyeBlack", "dyeRed", "dyeGreen", "dyeBrown", "dyeBlue", "dyePurple", "dyeCyan", "dyeLightGray", "dyeGray", "dyePink", "dyeLime", "dyeYellow", "dyeLightBlue", "dyeMagenta", "dyeOrange", "dyeWhite" };
    for (int i = 0; i < 1000; i++) {
        LogisticsModule module = LogisticsPipes.ModuleItem.getModuleForItem(new ItemStack(LogisticsPipes.ModuleItem, 1, i), null, null, null);
        if (module != null) {
            NBTTagCompound nbt = new NBTTagCompound();
            boolean force = false;
            try {
                module.writeToNBT(nbt);
            } catch (Exception e) {
                force = true;
            }
            if (!nbt.equals(new NBTTagCompound()) || force) {
                RecipeManager.craftingManager.addShapelessResetRecipe(LogisticsPipes.ModuleItem, i);
            }
        }
    }
    for (int i = 1; i < 17; i++) {
        RecipeManager.craftingManager.addOrdererRecipe(new ItemStack(LogisticsPipes.LogisticsRemoteOrderer, 1, i), dyes[i - 1], new ItemStack(LogisticsPipes.LogisticsRemoteOrderer, 1, -1));
        RecipeManager.craftingManager.addShapelessResetRecipe(LogisticsPipes.LogisticsRemoteOrderer, i);
    }
    RecipeManager.craftingManager.addShapelessResetRecipe(LogisticsPipes.LogisticsRemoteOrderer, 0);
    ItemStack logisticsBlockFrame = new ItemStack(LogisticsPipes.LogisticsSolidBlock, 1, LogisticsSolidBlock.LOGISTICS_BLOCK_FRAME);
    RecipeManager.craftingManager.addRecipe(logisticsBlockFrame, CraftingDependency.Basic, new RecipeManager.RecipeLayout("iri", "   ", "w w"), new RecipeManager.RecipeIndex('i', "ingotIron"), new RecipeManager.RecipeIndex('r', "dustRedstone"), new RecipeManager.RecipeIndex('w', "plankWood"));
    RecipeManager.craftingManager.addRecipe(new ItemStack(LogisticsPipes.LogisticsSolidBlock, 1, LogisticsSolidBlock.SOLDERING_STATION), CraftingDependency.Basic, new RecipeManager.RecipeLayout(" c ", "ifi", "ibi"), new RecipeManager.RecipeIndex('c', Blocks.crafting_table), new RecipeManager.RecipeIndex('i', "ingotIron"), new RecipeManager.RecipeIndex('f', logisticsBlockFrame), new RecipeManager.RecipeIndex('b', Items.blaze_powder));
    RecipeManager.craftingManager.addRecipe(new ItemStack(LogisticsPipes.LogisticsSolidBlock, 1, LogisticsSolidBlock.LOGISTICS_AUTOCRAFTING_TABLE), CraftingDependency.Basic, new RecipeManager.RecipeLayout(" c ", "wfw", " p "), new RecipeManager.RecipeIndex('c', Blocks.crafting_table), new RecipeManager.RecipeIndex('w', "plankWood"), new RecipeManager.RecipeIndex('f', logisticsBlockFrame), new RecipeManager.RecipeIndex('p', Blocks.piston));
    RecipeManager.craftingManager.addRecipe(new ItemStack(LogisticsPipes.BasicTransportPipe, 8), CraftingDependency.Basic, new RecipeManager.RecipeLayout("iri", "g g", "iri"), new RecipeManager.RecipeIndex('i', "ingotIron"), new RecipeManager.RecipeIndex('r', "dustRedstone"), new RecipeManager.RecipeIndex('g', "blockGlass"));
}
Also used : LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) NBTTagCompound(net.minecraft.nbt.NBTTagCompound) ItemStack(net.minecraft.item.ItemStack)

Example 15 with LogisticsModule

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

the class ItemModule method getModuleForItem.

public LogisticsModule getModuleForItem(ItemStack itemStack, LogisticsModule currentModule, IWorldProvider world, IPipeServiceProvider service) {
    if (itemStack == null) {
        return null;
    }
    if (itemStack.getItem() != this) {
        return null;
    }
    for (Module module : modules) {
        if (itemStack.getItemDamage() == module.getId()) {
            if (module.getILogisticsModuleClass() == null) {
                return null;
            }
            if (currentModule != null) {
                if (module.getILogisticsModuleClass().equals(currentModule.getClass())) {
                    return currentModule;
                }
            }
            LogisticsModule newmodule = module.getILogisticsModule();
            if (newmodule == null) {
                return null;
            }
            newmodule.registerHandler(world, service);
            return newmodule;
        }
    }
    return null;
}
Also used : LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) LogisticsModule(logisticspipes.modules.abstractmodules.LogisticsModule) LogisticsGuiModule(logisticspipes.modules.abstractmodules.LogisticsGuiModule)

Aggregations

LogisticsModule (logisticspipes.modules.abstractmodules.LogisticsModule)16 ILegacyActiveModule (logisticspipes.interfaces.ILegacyActiveModule)4 ItemStack (net.minecraft.item.ItemStack)4 SinkReply (logisticspipes.utils.SinkReply)3 IInventoryUtil (logisticspipes.interfaces.IInventoryUtil)2 IRequireReliableTransport (logisticspipes.interfaces.routing.IRequireReliableTransport)2 TreeSet (java.util.TreeSet)1 GuiChassiPipe (logisticspipes.gui.GuiChassiPipe)1 IBufferItems (logisticspipes.interfaces.IBufferItems)1 IFilter (logisticspipes.interfaces.routing.IFilter)1 ItemModule (logisticspipes.items.ItemModule)1 LogisticsGuiModule (logisticspipes.modules.abstractmodules.LogisticsGuiModule)1 ModernPacket (logisticspipes.network.abstractpackets.ModernPacket)1 ChassiePipeModuleContent (logisticspipes.network.packets.pipe.ChassiePipeModuleContent)1 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)1 LogisticsOrder (logisticspipes.routing.order.LogisticsOrder)1 DummyWorldProvider (logisticspipes.utils.DummyWorldProvider)1 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)1 ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)1 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)1