Search in sources :

Example 26 with ItemIdentifierStack

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

the class CraftingPipeSign method render.

@Override
@SideOnly(Side.CLIENT)
public void render(CoreRoutedPipe pipe, LogisticsRenderPipe renderer) {
    PipeItemsCraftingLogistics cpipe = (PipeItemsCraftingLogistics) pipe;
    FontRenderer var17 = renderer.func_147498_b();
    if (cpipe != null) {
        List<ItemIdentifierStack> craftables = cpipe.getCraftedItems();
        String name = "";
        if (craftables != null && craftables.size() > 0) {
            ItemStack itemstack = craftables.get(0).unsafeMakeNormalStack();
            renderer.renderItemStackOnSign(itemstack);
            Item item = itemstack.getItem();
            GL11.glDepthMask(false);
            GL11.glRotatef(-180.0F, 1.0F, 0.0F, 0.0F);
            GL11.glTranslatef(0.5F, +0.08F, 0.0F);
            GL11.glScalef(1.0F / 90.0F, 1.0F / 90.0F, 1.0F / 90.0F);
            try {
                name = item.getItemStackDisplayName(itemstack);
            } catch (Exception e) {
                try {
                    name = item.getUnlocalizedName();
                } catch (Exception e1) {
                }
            }
            var17.drawString("ID: " + String.valueOf(Item.getIdFromItem(item)), -var17.getStringWidth("ID: " + String.valueOf(Item.getIdFromItem(item))) / 2, 0 * 10 - 4 * 5, 0);
            ModuleCrafter logisticsMod = cpipe.getLogisticsModule();
            if (logisticsMod.satelliteId != 0) {
                var17.drawString("Sat ID: " + String.valueOf(logisticsMod.satelliteId), -var17.getStringWidth("Sat ID: " + String.valueOf(logisticsMod.satelliteId)) / 2, 1 * 10 - 4 * 5, 0);
            }
        } else {
            GL11.glRotatef(-180.0F, 1.0F, 0.0F, 0.0F);
            GL11.glTranslatef(0.5F, +0.08F, 0.0F);
            GL11.glScalef(1.0F / 90.0F, 1.0F / 90.0F, 1.0F / 90.0F);
            name = "Empty";
        }
        name = renderer.cut(name, var17);
        var17.drawString(name, -var17.getStringWidth(name) / 2 - 15, 3 * 10 - 4 * 5, 0);
        GL11.glDepthMask(true);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    }
}
Also used : PipeItemsCraftingLogistics(logisticspipes.pipes.PipeItemsCraftingLogistics) Item(net.minecraft.item.Item) FontRenderer(net.minecraft.client.gui.FontRenderer) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemStack(net.minecraft.item.ItemStack) ModuleCrafter(logisticspipes.modules.ModuleCrafter) SideOnly(cpw.mods.fml.relauncher.SideOnly)

Example 27 with ItemIdentifierStack

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

the class AssemblyAdvancedWorkbench method importRecipe.

@Override
public boolean importRecipe(TileEntity tile, ItemIdentifierInventory inventory) {
    if (!(tile instanceof TileAdvancedCraftingTable)) {
        return false;
    }
    TileAdvancedCraftingTable bench = (TileAdvancedCraftingTable) tile;
    ItemStack result = bench.getOutputSlot().getStackInSlot(0);
    if (result == null) {
        return false;
    }
    inventory.setInventorySlotContents(9, result);
    // Import
    for (int i = 0; i < bench.getCraftingSlots().getSizeInventory(); i++) {
        if (i >= inventory.getSizeInventory() - 2) {
            break;
        }
        final ItemStack newStack = bench.getCraftingSlots().getStackInSlot(i) == null ? null : bench.getCraftingSlots().getStackInSlot(i).copy();
        inventory.setInventorySlotContents(i, newStack);
    }
    // Compact
    for (int i = 0; i < inventory.getSizeInventory() - 2; i++) {
        final ItemIdentifierStack stackInSlot = inventory.getIDStackInSlot(i);
        if (stackInSlot == null) {
            continue;
        }
        final ItemIdentifier itemInSlot = stackInSlot.getItem();
        for (int j = i + 1; j < inventory.getSizeInventory() - 2; j++) {
            final ItemIdentifierStack stackInOtherSlot = inventory.getIDStackInSlot(j);
            if (stackInOtherSlot == null) {
                continue;
            }
            if (itemInSlot.equals(stackInOtherSlot.getItem())) {
                stackInSlot.setStackSize(stackInSlot.getStackSize() + stackInOtherSlot.getStackSize());
                inventory.setInventorySlotContents(i, stackInSlot);
                inventory.clearInventorySlotContents(j);
            }
        }
    }
    for (int i = 0; i < inventory.getSizeInventory() - 2; i++) {
        if (inventory.getStackInSlot(i) != null) {
            continue;
        }
        for (int j = i + 1; j < inventory.getSizeInventory() - 2; j++) {
            if (inventory.getStackInSlot(j) == null) {
                continue;
            }
            inventory.setInventorySlotContents(i, inventory.getIDStackInSlot(j));
            inventory.clearInventorySlotContents(j);
            break;
        }
    }
    return true;
}
Also used : ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) TileAdvancedCraftingTable(buildcraft.silicon.TileAdvancedCraftingTable) ItemStack(net.minecraft.item.ItemStack) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Example 28 with ItemIdentifierStack

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

the class LogisticsRenderPipe method renderSolids.

private void renderSolids(CoreUnroutedPipe pipe, double x, double y, double z, float partialTickTime) {
    GL11.glPushMatrix();
    float light = pipe.container.getWorldObj().getLightBrightness(pipe.container.xCoord, pipe.container.yCoord, pipe.container.zCoord);
    int count = 0;
    for (LPTravelingItem item : pipe.transport.items) {
        CoreUnroutedPipe lPipe = pipe;
        double lX = x;
        double lY = y;
        double lZ = z;
        float lItemYaw = item.getYaw();
        if (count >= LogisticsRenderPipe.MAX_ITEMS_TO_RENDER) {
            break;
        }
        if (item.getItemIdentifierStack() == null) {
            continue;
        }
        if (item.getContainer().xCoord != lPipe.container.xCoord || item.getContainer().yCoord != lPipe.container.yCoord || item.getContainer().zCoord != lPipe.container.zCoord) {
            continue;
        }
        if (item.getPosition() > lPipe.transport.getPipeLength() || item.getPosition() < 0) {
            continue;
        }
        float fPos = item.getPosition() + item.getSpeed() * partialTickTime;
        if (fPos > lPipe.transport.getPipeLength() && item.output != ForgeDirection.UNKNOWN) {
            CoreUnroutedPipe nPipe = lPipe.transport.getNextPipe(item.output);
            if (nPipe != null) {
                fPos -= lPipe.transport.getPipeLength();
                lX -= lPipe.getX() - nPipe.getX();
                lY -= lPipe.getY() - nPipe.getY();
                lZ -= lPipe.getZ() - nPipe.getZ();
                lItemYaw += lPipe.transport.getYawDiff(item);
                lPipe = nPipe;
                item = item.renderCopy();
                item.input = item.output;
                item.output = ForgeDirection.UNKNOWN;
            } else {
                continue;
            }
        }
        DoubleCoordinates pos = lPipe.getItemRenderPos(fPos, item);
        if (pos == null) {
            continue;
        }
        double boxScale = lPipe.getBoxRenderScale(fPos, item);
        double itemYaw = (lPipe.getItemRenderYaw(fPos, item) - lPipe.getItemRenderYaw(0, item) + lItemYaw) % 360;
        double itemPitch = lPipe.getItemRenderPitch(fPos, item);
        double itemYawForPitch = lPipe.getItemRenderYaw(fPos, item);
        ItemStack itemstack = item.getItemIdentifierStack().makeNormalStack();
        doRenderItem(itemstack, pipe.container.getWorldObj(), lX + pos.getXCoord(), lY + pos.getYCoord(), lZ + pos.getZCoord(), light, 0.75F, boxScale, itemYaw, itemPitch, itemYawForPitch, partialTickTime);
        count++;
    }
    count = 0;
    double dist = 0.135;
    DoubleCoordinates pos = new DoubleCoordinates(0.5, 0.5, 0.5);
    CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist);
    CoordinateUtils.add(pos, ForgeDirection.EAST, dist);
    CoordinateUtils.add(pos, ForgeDirection.UP, dist);
    for (Pair<ItemIdentifierStack, Pair<Integer, Integer>> item : pipe.transport._itemBuffer) {
        if (item == null || item.getValue1() == null) {
            continue;
        }
        ItemStack itemstack = item.getValue1().makeNormalStack();
        doRenderItem(itemstack, pipe.container.getWorldObj(), x + pos.getXCoord(), y + pos.getYCoord(), z + pos.getZCoord(), light, 0.25F, 0, 0, 0, 0, partialTickTime);
        count++;
        if (count >= 27) {
            break;
        } else if (count % 9 == 0) {
            CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist * 2.0);
            CoordinateUtils.add(pos, ForgeDirection.EAST, dist * 2.0);
            CoordinateUtils.add(pos, ForgeDirection.DOWN, dist);
        } else if (count % 3 == 0) {
            CoordinateUtils.add(pos, ForgeDirection.SOUTH, dist * 2.0);
            CoordinateUtils.add(pos, ForgeDirection.WEST, dist);
        } else {
            CoordinateUtils.add(pos, ForgeDirection.NORTH, dist);
        }
    }
    GL11.glPopMatrix();
}
Also used : CoreUnroutedPipe(logisticspipes.pipes.basic.CoreUnroutedPipe) LPTravelingItem(logisticspipes.transport.LPTravelingItem) DoubleCoordinates(network.rs485.logisticspipes.world.DoubleCoordinates) ItemStack(net.minecraft.item.ItemStack) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) Pair(logisticspipes.utils.tuples.Pair)

Example 29 with ItemIdentifierStack

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

the class RequestTree method request.

public static boolean request(List<ItemIdentifierStack> items, IRequestItems requester, RequestLog log, EnumSet<ActiveRequestType> requestFlags, IAdditionalTargetInformation info) {
    Map<IResource, Integer> messages = new HashMap<>();
    RequestTree tree = new RequestTree(new ItemResource(new ItemIdentifierStack(ItemIdentifier.get(Item.getItemFromBlock(Blocks.stone), 0, null), 0), requester), null, requestFlags, info);
    boolean isDone = true;
    for (ItemIdentifierStack stack : items) {
        ItemIdentifier item = stack.getItem();
        Integer count = messages.get(item);
        if (count == null) {
            count = 0;
        }
        count += stack.getStackSize();
        ItemResource req = new ItemResource(stack, requester);
        messages.put(req, count);
        RequestTree node = new RequestTree(req, tree, requestFlags, info);
        isDone = isDone && node.isDone();
    }
    if (isDone) {
        LinkedLogisticsOrderList list = tree.fullFillAll();
        if (log != null) {
            log.handleSucessfullRequestOfList(RequestTreeNode.shrinkToList(messages), list);
        }
        return true;
    } else {
        if (log != null) {
            tree.logFailedRequestTree(log);
        }
        return false;
    }
}
Also used : LinkedLogisticsOrderList(logisticspipes.routing.order.LinkedLogisticsOrderList) ItemIdentifier(logisticspipes.utils.item.ItemIdentifier) HashMap(java.util.HashMap) ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack) ItemResource(logisticspipes.request.resources.ItemResource) IResource(logisticspipes.request.resources.IResource)

Example 30 with ItemIdentifierStack

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

the class ItemResource method clone.

@Override
public IResource clone(int multiplier) {
    ItemIdentifierStack stack = this.stack.clone();
    stack.setStackSize(stack.getStackSize() * multiplier);
    return new ItemResource(stack, requester);
}
Also used : ItemIdentifierStack(logisticspipes.utils.item.ItemIdentifierStack)

Aggregations

ItemIdentifierStack (logisticspipes.utils.item.ItemIdentifierStack)58 ItemStack (net.minecraft.item.ItemStack)21 ItemIdentifier (logisticspipes.utils.item.ItemIdentifier)18 ArrayList (java.util.ArrayList)9 Pair (logisticspipes.utils.tuples.Pair)8 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)7 LinkedList (java.util.LinkedList)5 NBTTagList (net.minecraft.nbt.NBTTagList)5 List (java.util.List)4 IRoutedItem (logisticspipes.logisticspipes.IRoutedItem)4 CoreRoutedPipe (logisticspipes.pipes.basic.CoreRoutedPipe)4 DictResource (logisticspipes.request.resources.DictResource)4 IResource (logisticspipes.request.resources.IResource)4 ForgeDirection (net.minecraftforge.common.util.ForgeDirection)4 HashMap (java.util.HashMap)3 TreeSet (java.util.TreeSet)3 LogisticsCraftingTableTileEntity (logisticspipes.blocks.crafting.LogisticsCraftingTableTileEntity)3 IAdditionalTargetInformation (logisticspipes.interfaces.routing.IAdditionalTargetInformation)3 ItemResource (logisticspipes.request.resources.ItemResource)3 IRouter (logisticspipes.routing.IRouter)3