當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。