当前位置: 首页>>代码示例>>Java>>正文


Java InventoryCrafting.getWidth方法代码示例

本文整理汇总了Java中net.minecraft.inventory.InventoryCrafting.getWidth方法的典型用法代码示例。如果您正苦于以下问题:Java InventoryCrafting.getWidth方法的具体用法?Java InventoryCrafting.getWidth怎么用?Java InventoryCrafting.getWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.inventory.InventoryCrafting的用法示例。


在下文中一共展示了InventoryCrafting.getWidth方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: matches

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
	int slots = inv.getHeight() * inv.getWidth();
	int center = (int) ((float)slots / 2F);
	ItemStack checked = inv.getStackInSlot(center);
	if(checked.isEmpty() || !checked.hasTagCompound()) return false;
	int amount = 0;

	for(int j = 0; j < slots; j++) {
		ItemStack stack = inv.getStackInSlot(j);
		if(!stack.isEmpty() && (!hasTag(stack) || stack.getItem() != checked.getItem())) return false;
		if(!stack.isEmpty() && j != center) {
			amount++;
		}
	}

	return amount > 0;
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:19,代码来源:EntangledCloningRecipe.java

示例2: getCraftingResult

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
	int slots = inv.getHeight() * inv.getWidth();
	int center = (int) ((float)slots / 2F);
	ItemStack checked = inv.getStackInSlot(center);
	if(checked.isEmpty() || !checked.hasTagCompound()) return ItemStack.EMPTY;
	int amount = 0;

	for(int j = 0; j < slots; j++) {
		ItemStack stack = inv.getStackInSlot(j);
		if(!stack.isEmpty() && (!hasTag(stack) || stack.getItem() != checked.getItem())) return ItemStack.EMPTY;
		if(!stack.isEmpty() && j != center) {
			amount++;
		}
	}

	if(amount > 0) {
		ItemStack entanglement = new ItemStack(checked.getItem(), amount);
		getKey(checked).ifPresent(uuid -> setKey(entanglement, uuid));
		return entanglement;
	}
	return ItemStack.EMPTY;
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:24,代码来源:EntangledCloningRecipe.java

示例3: matchesShaped

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
protected boolean matchesShaped(InventoryCrafting inv) {
	for (int iy = 0; iy <= inv.getHeight() - 2; iy++) {
		for (int ix = 0; ix <= inv.getWidth() - 3; ix++) {
			boolean foundMistake = false;
			innerLoop: for (int y = 0; y < 2; y++) {
				for (int x = 0; x < 3; x++) {
					Ingredient ingredient = ingredients.get(y*3 + x);
					if (!ingredient.apply(inv.getStackInRowAndColumn(ix+x, iy+y))) {
						foundMistake = true;
						break innerLoop;
					}
				}
			}

			if (!foundMistake) {
				return true;
			}
		}
	}

	return false;
}
 
开发者ID:asiekierka,项目名称:PonySocks2,代码行数:23,代码来源:RecipeBase.java

示例4: extractReduceMirror

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
public List<ItemStack[][]> extractReduceMirror(InventoryCrafting inv) {
    ItemStack[][] grid = new ItemStack[inv.getHeight()][inv.getWidth()];
    for (int y = 0; y < inv.getHeight(); y++) {
        for (int x = 0; x < inv.getWidth(); x++) {
            grid[y][x] = inv.getStackInRowAndColumn(x, y);
        }
    }
    return mirror(reduceBlank(grid));
}
 
开发者ID:Randores,项目名称:Randores2,代码行数:10,代码来源:RandoresItemRecipe.java

示例5: matches

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    List<ItemStack> list = Lists.newArrayList(this.recipeItems);

    for (int i = 0; i < inv.getHeight(); ++i)
    {
        for (int j = 0; j < inv.getWidth(); ++j)
        {
            ItemStack itemstack = inv.getStackInRowAndColumn(j, i);

            if (itemstack != null)
            {
                boolean flag = false;

                for (ItemStack itemstack1 : list)
                {
                    if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getMetadata() == 32767 || itemstack.getMetadata() == itemstack1.getMetadata()))
                    {
                        flag = true;
                        list.remove(itemstack1);
                        break;
                    }
                }

                if (!flag)
                {
                    return false;
                }
            }
        }
    }

    return list.isEmpty();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:38,代码来源:ShapelessRecipes.java

示例6: getRemainingItems

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
	int slots = inv.getHeight() * inv.getWidth();
	NonNullList<ItemStack> nonNullList = NonNullList.<ItemStack>withSize(slots, ItemStack.EMPTY);
	int center = (int) ((float) slots / 2);

	ItemStack stack = inv.getStackInSlot(center);
	nonNullList.set(center, stack.copy());

	return nonNullList;
}
 
开发者ID:ArekkuusuJerii,项目名称:Solar,代码行数:12,代码来源:EntangledCloningRecipe.java

示例7: getRemainingItems

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv)
{
    NonNullList<ItemStack> items = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);

    getMatch(inv);

    int[] amounts = getAmounts(wasMirrored);

    for (int col = 0; col < getWidth(); col++)
    {
        for (int row = 0; row < getHeight(); row++)
        {
            int amountIndex = col + row * getWidth();
            int invIndex = matchX + col + (row + matchY) * inv.getWidth();
            int amount = amounts[amountIndex];
            if (amount > 0)
            {
                ItemStack stack = inv.getStackInSlot(invIndex).copy();
                stack.setItemDamage(stack.getItemDamage() + amount);
                if (stack.getItemDamage() > stack.getMaxDamage())
                {
                    stack = ForgeHooks.getContainerItem(stack);
                }
                items.set(invIndex, stack);
            } else
            {
                items.set(invIndex, ForgeHooks.getContainerItem(inv.getStackInSlot(invIndex)));
            }
        }
    }

    return items;
}
 
开发者ID:cubex2,项目名称:customstuff4,代码行数:35,代码来源:DamageableShapedOreRecipe.java

示例8: matches

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    if (inv.getWidth() == 3 && inv.getHeight() == 3)
    {
        for (int i = 0; i < inv.getWidth(); ++i)
        {
            for (int j = 0; j < inv.getHeight(); ++j)
            {
                ItemStack itemstack = inv.getStackInRowAndColumn(i, j);

                if (itemstack.func_190926_b())
                {
                    return false;
                }

                Item item = itemstack.getItem();

                if (i == 1 && j == 1)
                {
                    if (item != Items.LINGERING_POTION)
                    {
                        return false;
                    }
                }
                else if (item != Items.ARROW)
                {
                    return false;
                }
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:42,代码来源:RecipeTippedArrow.java

示例9: matches

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    List<ItemStack> list = Lists.newArrayList(this.recipeItems);

    for (int i = 0; i < inv.getHeight(); ++i)
    {
        for (int j = 0; j < inv.getWidth(); ++j)
        {
            ItemStack itemstack = inv.getStackInRowAndColumn(j, i);

            if (!itemstack.func_190926_b())
            {
                boolean flag = false;

                for (ItemStack itemstack1 : list)
                {
                    if (itemstack.getItem() == itemstack1.getItem() && (itemstack1.getMetadata() == 32767 || itemstack.getMetadata() == itemstack1.getMetadata()))
                    {
                        flag = true;
                        list.remove(itemstack1);
                        break;
                    }
                }

                if (!flag)
                {
                    return false;
                }
            }
        }
    }

    return list.isEmpty();
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:38,代码来源:ShapelessRecipes.java

示例10: matches

import net.minecraft.inventory.InventoryCrafting; //导入方法依赖的package包/类
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    if (inv.getWidth() == 3 && inv.getHeight() == 3)
    {
        for (int i = 0; i < inv.getWidth(); ++i)
        {
            for (int j = 0; j < inv.getHeight(); ++j)
            {
                ItemStack itemstack = inv.getStackInRowAndColumn(i, j);

                if (itemstack == null)
                {
                    return false;
                }

                Item item = itemstack.getItem();

                if (i == 1 && j == 1)
                {
                    if (item != Items.LINGERING_POTION)
                    {
                        return false;
                    }
                }
                else if (item != Items.ARROW)
                {
                    return false;
                }
            }
        }

        return true;
    }
    else
    {
        return false;
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:42,代码来源:RecipeTippedArrow.java


注:本文中的net.minecraft.inventory.InventoryCrafting.getWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。