Java Code Examples for thaumcraft.api.ThaumcraftApiHelper#getStackInRowAndColumn()

The following examples show how to use thaumcraft.api.ThaumcraftApiHelper#getStackInRowAndColumn() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShapedArcaneRecipe.java    From AdvancedMod with GNU General Public License v3.0 4 votes vote down vote up
private boolean checkMatch(IInventory inv, int startX, int startY, boolean mirror)
{
    for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
    {
        for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
        {
            int subX = x - startX;
            int subY = y - startY;
            Object target = null;

            if (subX >= 0 && subY >= 0 && subX < width && subY < height)
            {
                if (mirror)
                {
                    target = input[width - subX - 1 + subY * width];
                }
                else
                {
                    target = input[subX + subY * width];
                }
            }

            ItemStack slot = ThaumcraftApiHelper.getStackInRowAndColumn(inv, x, y);

            if (target instanceof ItemStack)
            {
                if (!checkItemEquals((ItemStack)target, slot))
                {
                    return false;
                }
            }
            else if (target instanceof ArrayList)
            {
                boolean matched = false;

                for (ItemStack item : (ArrayList<ItemStack>)target)
                {
                    matched = matched || checkItemEquals(item, slot);
                }

                if (!matched)
                {
                    return false;
                }
            }
            else if (target == null && slot != null)
            {
                return false;
            }
        }
    }

    return true;
}
 
Example 2
Source File: ShapedArcaneRecipe.java    From Chisel-2 with GNU General Public License v2.0 4 votes vote down vote up
private boolean checkMatch(IInventory inv, int startX, int startY, boolean mirror)
{
    for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
    {
        for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
        {
            int subX = x - startX;
            int subY = y - startY;
            Object target = null;

            if (subX >= 0 && subY >= 0 && subX < width && subY < height)
            {
                if (mirror)
                {
                    target = input[width - subX - 1 + subY * width];
                }
                else
                {
                    target = input[subX + subY * width];
                }
            }

            ItemStack slot = ThaumcraftApiHelper.getStackInRowAndColumn(inv, x, y);

            if (target instanceof ItemStack)
            {
                if (!checkItemEquals((ItemStack)target, slot))
                {
                    return false;
                }
            }
            else if (target instanceof ArrayList)
            {
                boolean matched = false;

                for (ItemStack item : (ArrayList<ItemStack>)target)
                {
                    matched = matched || checkItemEquals(item, slot);
                }

                if (!matched)
                {
                    return false;
                }
            }
            else if (target == null && slot != null)
            {
                return false;
            }
        }
    }

    return true;
}
 
Example 3
Source File: ShapedArcaneRecipe.java    From GardenCollection with MIT License 4 votes vote down vote up
private boolean checkMatch(IInventory inv, int startX, int startY, boolean mirror)
{
    for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
    {
        for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
        {
            int subX = x - startX;
            int subY = y - startY;
            Object target = null;

            if (subX >= 0 && subY >= 0 && subX < width && subY < height)
            {
                if (mirror)
                {
                    target = input[width - subX - 1 + subY * width];
                }
                else
                {
                    target = input[subX + subY * width];
                }
            }

            ItemStack slot = ThaumcraftApiHelper.getStackInRowAndColumn(inv, x, y);

            if (target instanceof ItemStack)
            {
                if (!checkItemEquals((ItemStack)target, slot))
                {
                    return false;
                }
            }
            else if (target instanceof ArrayList)
            {
                boolean matched = false;

                for (ItemStack item : (ArrayList<ItemStack>)target)
                {
                    matched = matched || checkItemEquals(item, slot);
                }

                if (!matched)
                {
                    return false;
                }
            }
            else if (target == null && slot != null)
            {
                return false;
            }
        }
    }

    return true;
}
 
Example 4
Source File: ShapedArcaneRecipe.java    From ForbiddenMagic with Do What The F*ck You Want To Public License 4 votes vote down vote up
private boolean checkMatch(IInventory inv, int startX, int startY, boolean mirror)
{
    for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
    {
        for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
        {
            int subX = x - startX;
            int subY = y - startY;
            Object target = null;

            if (subX >= 0 && subY >= 0 && subX < width && subY < height)
            {
                if (mirror)
                {
                    target = input[width - subX - 1 + subY * width];
                }
                else
                {
                    target = input[subX + subY * width];
                }
            }

            ItemStack slot = ThaumcraftApiHelper.getStackInRowAndColumn(inv, x, y);

            if (target instanceof ItemStack)
            {
                if (!checkItemEquals((ItemStack)target, slot))
                {
                    return false;
                }
            }
            else if (target instanceof ArrayList)
            {
                boolean matched = false;

                for (ItemStack item : (ArrayList<ItemStack>)target)
                {
                    matched = matched || checkItemEquals(item, slot);
                }

                if (!matched)
                {
                    return false;
                }
            }
            else if (target == null && slot != null)
            {
                return false;
            }
        }
    }

    return true;
}
 
Example 5
Source File: ShapedArcaneRecipe.java    From PneumaticCraft with GNU General Public License v3.0 4 votes vote down vote up
private boolean checkMatch(IInventory inv, int startX, int startY, boolean mirror)
{
    for (int x = 0; x < MAX_CRAFT_GRID_WIDTH; x++)
    {
        for (int y = 0; y < MAX_CRAFT_GRID_HEIGHT; y++)
        {
            int subX = x - startX;
            int subY = y - startY;
            Object target = null;

            if (subX >= 0 && subY >= 0 && subX < width && subY < height)
            {
                if (mirror)
                {
                    target = input[width - subX - 1 + subY * width];
                }
                else
                {
                    target = input[subX + subY * width];
                }
            }

            ItemStack slot = ThaumcraftApiHelper.getStackInRowAndColumn(inv, x, y);

            if (target instanceof ItemStack)
            {
                if (!checkItemEquals((ItemStack)target, slot))
                {
                    return false;
                }
            }
            else if (target instanceof ArrayList)
            {
                boolean matched = false;

                for (ItemStack item : (ArrayList<ItemStack>)target)
                {
                    matched = matched || checkItemEquals(item, slot);
                }

                if (!matched)
                {
                    return false;
                }
            }
            else if (target == null && slot != null)
            {
                return false;
            }
        }
    }

    return true;
}