Java 类net.minecraft.inventory.InventoryCrafting 实例源码

项目:CustomWorldGen    文件:CraftingManager.java   
public ItemStack[] getRemainingItems(InventoryCrafting craftMatrix, World worldIn)
{
    for (IRecipe irecipe : this.recipes)
    {
        if (irecipe.matches(craftMatrix, worldIn))
        {
            return irecipe.getRemainingItems(craftMatrix);
        }
    }

    ItemStack[] aitemstack = new ItemStack[craftMatrix.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        aitemstack[i] = craftMatrix.getStackInSlot(i);
    }

    return aitemstack;
}
项目:Adventurers-Toolbox    文件:HoeRecipe.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    ItemStack out = new ItemStack(ModItems.hoe);

    if (adornmentMat == null) {
        adornmentMat = ModMaterials.ADORNMENT_NULL;
    }

    if (headMat == null || haftMat == null || handleMat == null || adornmentMat == null) {
        return ItemStack.EMPTY;
    }

    NBTTagCompound tag = new NBTTagCompound();
    tag.setString(IHeadTool.HEAD_TAG, headMat.getName());
    tag.setString(IHaftTool.HAFT_TAG, haftMat.getName());
    tag.setString(IHandleTool.HANDLE_TAG, handleMat.getName());
    tag.setString(IAdornedTool.ADORNMENT_TAG, adornmentMat.getName());
    out.setTagCompound(tag);

    return out;
}
项目:customstuff4    文件:DamageableShapelessOreRecipeTest.java   
@Test
public void test_useUpItem()
{
    DamageableShapelessOreRecipe recipe = new DamageableShapelessOreRecipe(new ResourceLocation("group"),
                                                                           new int[] {60}, new ItemStack(Blocks.DIRT), new ItemStack(Items.WOODEN_SWORD));
    InventoryCrafting inv = new InventoryCrafting(new Container()
    {
        @Override
        public boolean canInteractWith(EntityPlayer playerIn)
        {
            return false;
        }
    }, 3, 3);
    inv.setInventorySlotContents(3, new ItemStack(Items.WOODEN_SWORD));

    assertTrue(recipe.matches(inv, null));
    NonNullList<ItemStack> remaining = recipe.getRemainingItems(inv);
    assertTrue(remaining.get(3).isEmpty());
}
项目:Adventurers-Toolbox    文件:ShovelRecipe.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    ItemStack out = new ItemStack(ModItems.shovel);

    if (adornmentMat == null) {
        adornmentMat = ModMaterials.ADORNMENT_NULL;
    }

    if (headMat == null || haftMat == null || handleMat == null || adornmentMat == null) {
        return ItemStack.EMPTY;
    }

    NBTTagCompound tag = new NBTTagCompound();
    tag.setString(IHeadTool.HEAD_TAG, headMat.getName());
    tag.setString(IHaftTool.HAFT_TAG, haftMat.getName());
    tag.setString(IHandleTool.HANDLE_TAG, handleMat.getName());
    tag.setString(IAdornedTool.ADORNMENT_TAG, adornmentMat.getName());
    out.setTagCompound(tag);

    return out;
}
项目:pnc-repressurized    文件:RecipeGunAmmo.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting invCrafting) {
    ItemStack potion = ItemStack.EMPTY;
    ItemStack ammo = ItemStack.EMPTY;
    for (int i = 0; i < invCrafting.getSizeInventory(); i++) {
        ItemStack stack = invCrafting.getStackInSlot(i);
        if (!stack.isEmpty()) {
            if (stack.getItem() == Items.POTIONITEM) {
                potion = stack;
            } else {
                ammo = stack;
            }
        }
    }
    ammo = ammo.copy();
    ItemGunAmmo.setPotion(ammo, potion);
    return ammo;
}
项目:BaseClient    文件:RecipesArmorDyes.java   
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem().hasContainerItem())
        {
            aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
        }
    }

    return aitemstack;
}
项目:Mods    文件:JumperRecipe.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    // TODO Auto-generated method stub
    ItemStack stack2 = ItemStack.EMPTY;

    for (int x = 0; x < inv.getSizeInventory(); x++) {
        ItemStack stack = inv.getStackInSlot(x);
        if (!stack.isEmpty())
            if (!(stack.getItem() == Items.FEATHER))
                stack2 = stack;
    }
    // System.out.println("OutPut: "+stack2);
    if (!stack2.isEmpty()) {
        if(ItemFromData.isSameType(stack2, nameBefore))
            stack2=ItemFromData.getNewStack(nameAfter);
    }
    return stack2;
}
项目:BaseClient    文件:RecipesMapExtending.java   
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = null;

    for (int i = 0; i < inv.getSizeInventory() && itemstack == null; ++i)
    {
        ItemStack itemstack1 = inv.getStackInSlot(i);

        if (itemstack1 != null && itemstack1.getItem() == Items.filled_map)
        {
            itemstack = itemstack1;
        }
    }

    itemstack = itemstack.copy();
    itemstack.stackSize = 1;

    if (itemstack.getTagCompound() == null)
    {
        itemstack.setTagCompound(new NBTTagCompound());
    }

    itemstack.getTagCompound().setBoolean("map_is_scaling", true);
    return itemstack;
}
项目:Backmemed    文件:ShapedRecipes.java   
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    for (int i = 0; i <= 3 - this.recipeWidth; ++i)
    {
        for (int j = 0; j <= 3 - this.recipeHeight; ++j)
        {
            if (this.checkMatch(inv, i, j, true))
            {
                return true;
            }

            if (this.checkMatch(inv, i, j, false))
            {
                return true;
            }
        }
    }

    return false;
}
项目:BetterThanWeagles    文件:RecipeSimicSlaw.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    ItemStack inputSlaw = inv.getStackInSlot(0);

    byte additions = 0;
    if (inputSlaw.hasTagCompound()) {
        additions = inputSlaw.getTagCompound().getByte("additions");
    }
    additions += 1;

    ItemStack outputStack = new ItemStack(ModItems.simic_slaw);
    outputStack.setTagCompound(new NBTTagCompound());
    outputStack.getTagCompound().setByte("additions", additions);

    return outputStack;
}
项目:MeeCreeps    文件:RemoveCartridgeFactory.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inventoryCrafting) {
    ItemStack result = super.getCraftingResult(inventoryCrafting);
    if (!result.isEmpty()) {

        ItemStack portalGunItem = ItemStack.EMPTY;

        for (int i = 0; i < inventoryCrafting.getSizeInventory(); ++i) {
            ItemStack stack = inventoryCrafting.getStackInSlot(i);

            if (!stack.isEmpty()) {
                if (stack.getItem() instanceof PortalGunItem) {
                    portalGunItem = stack;
                }
            }
        }

        if (!portalGunItem.isEmpty()) {
            int charge = PortalGunItem.getCharge(portalGunItem);
            CartridgeItem.setCharge(result, charge);
        }
    }
    return result;
}
项目:BaseClient    文件:ShapedRecipes.java   
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = this.getRecipeOutput().copy();

    if (this.copyIngredientNBT)
    {
        for (int i = 0; i < inv.getSizeInventory(); ++i)
        {
            ItemStack itemstack1 = inv.getStackInSlot(i);

            if (itemstack1 != null && itemstack1.hasTagCompound())
            {
                itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy());
            }
        }
    }

    return itemstack;
}
项目:BetterBeginningsReborn    文件:AdvancedRecipe.java   
public boolean matches(InventoryCrafting invCrafting, InventoryWorkbenchAdditionalMaterials materials,
                       World world)
{
    for (int i = 0; i <= 3 - recipeWidth; ++i)
    {
        for (int j = 0; j <= 3 - recipeHeight; ++j)
        {
            if (checkMatch(invCrafting, materials, i, j, false))
            {
                return true;
            }

            if (mirrored && checkMatch(invCrafting, materials, i, j, true))
            {
                return true;
            }
        }
    }

    return false;
}
项目:Randores2    文件:RandoresForgeUpgradeRecipe.java   
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
    int count = 0;
    boolean forge = false;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if(!stack.isEmpty()) {
            if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof CraftiniumForge) {
                if(forge && !this.combining) {
                    return false;
                } else {
                    forge = true;
                    if(!stack.hasTagCompound() || stack.getSubCompound("randores") == null || !stack.getSubCompound("randores").hasKey("furnace_speed")) {
                        return false;
                    }
                }
            } else if (this.upgrades.keySet().stream().noneMatch(k -> k.apply(stack))) {
                return false;
            }
            count++;
        }
    }
    return count >= 2 && forge;
}
项目:Randores2    文件:RandoresForgeUpgradeRecipe.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    double speed = 0;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if(stack.getItem() instanceof ItemBlock && ((ItemBlock) stack.getItem()).getBlock() instanceof CraftiniumForge) {
            speed += stack.getSubCompound("randores").getInteger("furnace_speed");
        } else {
            speed += this.upgrades.entrySet().stream().filter(e -> e.getKey().apply(stack)).map(Entry::getValue).findFirst().orElse(0d);
        }
    }

    int intSpeed = (int) speed;
    if(intSpeed > this.clamp) {
        intSpeed = this.clamp;
    }

    ItemStack res = new ItemStack(CraftingBlocks.forgeItem);
    res.getOrCreateSubCompound("randores").setInteger("furnace_speed", intSpeed);
    return res;
}
项目:BaseClient    文件:ShapedRecipes.java   
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = this.getRecipeOutput().copy();

    if (this.copyIngredientNBT)
    {
        for (int i = 0; i < inv.getSizeInventory(); ++i)
        {
            ItemStack itemstack1 = inv.getStackInSlot(i);

            if (itemstack1 != null && itemstack1.hasTagCompound())
            {
                itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy());
            }
        }
    }

    return itemstack;
}
项目:minecraft-quiverbow    文件:Recipe_AA_Armor.java   
private ItemStack getAAFromMatrix(InventoryCrafting matrix)
{
    int counter = 0;

    while (counter < matrix.getSizeInventory())
    {
        if (matrix.getStackInSlot(counter) != null && matrix.getStackInSlot(counter).getItem() instanceof PackedUpAA)
        {
            return matrix.getStackInSlot(counter);  // Found it
        }

        counter += 1;
    }

    return null;
}
项目:Randores2    文件:RandoresTomeRecipe.java   
@Override
public boolean matches(InventoryCrafting inv, World worldIn) {
    boolean book = false;
    boolean material = false;
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ItemStack stack = inv.getStackInSlot(i);
        if (!stack.isEmpty()) {
            if (this.book.apply(stack)) {
                if (book) {
                    return false;
                } else {
                    book = true;
                }
            } else if (stack.getItem() instanceof RandoresMaterial && RandoresItemData.hasData(stack)) {
                if(material) {
                    return false;
                } else {
                    material = true;
                }
            } else {
                return false; //Not a book, not a data'd material, not empty
            }
        }
    }
    return book && material;
}
项目:BaseClient    文件:ShapelessRecipes.java   
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem().hasContainerItem())
        {
            aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
        }
    }

    return aitemstack;
}
项目:BetterBeginningsReborn    文件:AdvancedRecipe.java   
public ItemStack getCraftingResult(InventoryCrafting crafting)
{
    ItemStack itemstack = getRecipeOutput().copy();

    if (strangeFlag)
    {
        for (int i = 0; i < crafting.getSizeInventory(); ++i)
        {
            ItemStack itemstack1 = crafting.getStackInSlot(i);

            if (itemstack1 != null && itemstack1.hasTagCompound())
            {
                itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy());
            }
        }
    }

    return itemstack;
}
项目:DecompiledMinecraft    文件:RecipesBanners.java   
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && TileEntityBanner.getPatterns(itemstack) > 0)
        {
            ItemStack itemstack1 = itemstack.copy();
            itemstack1.stackSize = 1;
            return itemstack1;
        }
    }

    return null;
}
项目:DecompiledMinecraft    文件:RecipesMapExtending.java   
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = null;

    for (int i = 0; i < inv.getSizeInventory() && itemstack == null; ++i)
    {
        ItemStack itemstack1 = inv.getStackInSlot(i);

        if (itemstack1 != null && itemstack1.getItem() == Items.filled_map)
        {
            itemstack = itemstack1;
        }
    }

    itemstack = itemstack.copy();
    itemstack.stackSize = 1;

    if (itemstack.getTagCompound() == null)
    {
        itemstack.setTagCompound(new NBTTagCompound());
    }

    itemstack.getTagCompound().setBoolean("map_is_scaling", true);
    return itemstack;
}
项目:CustomWorldGen    文件:ShapedRecipes.java   
/**
 * Returns an Item that is the result of this recipe
 */
@Nullable
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = this.getRecipeOutput().copy();

    if (this.copyIngredientNBT)
    {
        for (int i = 0; i < inv.getSizeInventory(); ++i)
        {
            ItemStack itemstack1 = inv.getStackInSlot(i);

            if (itemstack1 != null && itemstack1.hasTagCompound())
            {
                itemstack.setTagCompound(itemstack1.getTagCompound().copy());
            }
        }
    }

    return itemstack;
}
项目:DecompiledMinecraft    文件:RecipeRepairItem.java   
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem().hasContainerItem())
        {
            aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
        }
    }

    return aitemstack;
}
项目:Solar    文件:EntangledCloningRecipe.java   
@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;
}
项目:minecraft-quiverbow    文件:Recipe_AA_Weapon.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting matrix)
   {
    ItemStack stack = this.result.copy();
    ItemStack previousAA = this.getAAFromMatrix(matrix);

    if (previousAA != null && previousAA.hasTagCompound())  // Copying existing properties
    {
        stack.setTagCompound((NBTTagCompound) previousAA.getTagCompound().copy());
    }
    else    // ...or just applying new ones
    {
        stack.setTagCompound(new NBTTagCompound());
    }

    // Apply the new upgrade now
    stack.getTagCompound().setBoolean("hasWeaponUpgrade", true);

    if (stack.getTagCompound().getInteger("currentHealth") == 0)    // Just making sure it's not shown with 0 health
    {
        if (stack.getTagCompound().getBoolean("hasArmorUpgrade")) { stack.getTagCompound().setInteger("currentHealth", 40); }
        else { stack.getTagCompound().setInteger("currentHealth", 20); } // Fresh turret, so setting some health
    }

       return stack;
   }
项目:DecompiledMinecraft    文件:RecipeBookCloning.java   
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem() instanceof ItemEditableBook)
        {
            aitemstack[i] = itemstack;
            break;
        }
    }

    return aitemstack;
}
项目:Adventurers-Toolbox    文件:AxeRecipe.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inv) {
    ItemStack out = new ItemStack(ModItems.axe);

    if (adornmentMat == null) {
        adornmentMat = ModMaterials.ADORNMENT_NULL;
    }

    if (headMat == null || haftMat == null || handleMat == null || adornmentMat == null) {
        return ItemStack.EMPTY;
    }

    NBTTagCompound tag = new NBTTagCompound();
    tag.setString(IHeadTool.HEAD_TAG, headMat.getName());
    tag.setString(IHaftTool.HAFT_TAG, haftMat.getName());
    tag.setString(IHandleTool.HANDLE_TAG, handleMat.getName());
    tag.setString(IAdornedTool.ADORNMENT_TAG, adornmentMat.getName());
    out.setTagCompound(tag);

    return out;
}
项目:DecompiledMinecraft    文件:ShapedRecipes.java   
/**
 * Returns an Item that is the result of this recipe
 */
public ItemStack getCraftingResult(InventoryCrafting inv)
{
    ItemStack itemstack = this.getRecipeOutput().copy();

    if (this.copyIngredientNBT)
    {
        for (int i = 0; i < inv.getSizeInventory(); ++i)
        {
            ItemStack itemstack1 = inv.getStackInSlot(i);

            if (itemstack1 != null && itemstack1.hasTagCompound())
            {
                itemstack.setTagCompound((NBTTagCompound)itemstack1.getTagCompound().copy());
            }
        }
    }

    return itemstack;
}
项目:Technical    文件:AutoWorkBenchRecipes.java   
public ItemStack[] getSmeltingResult(InventoryCrafting inv, World world, Tier tier) {
    return new ItemStack[] { CraftingManager.getInstance().findMatchingRecipe(inv, world) };
    /*
    @SuppressWarnings("unchecked")
    List<IRecipe> recipeList = CraftingManager.getInstance().getRecipeList();

    Iterator<IRecipe> iterator = recipeList.iterator();
    while(iterator.hasNext()) {
        IRecipe recipe = iterator.next();
        if(recipe != null && inv != null) {
            if(recipe.getCraftingResult(inv) != null)
                FMLLog.log(Level.INFO, "result: " + recipe.getCraftingResult(inv));
            else
                FMLLog.log(Level.INFO, "result: null");
            if(recipe.matches(inv, world)) {
                return new ItemStack[] { recipe.getCraftingResult(inv) };
            }
        } else {
            FMLLog.log(Level.INFO, "_null");
        }
    }
    return null;
    */
}
项目:DecompiledMinecraft    文件:RecipesArmorDyes.java   
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem().hasContainerItem())
        {
            aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
        }
    }

    return aitemstack;
}
项目:BaseClient    文件:RecipesBanners.java   
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem().hasContainerItem())
        {
            aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
        }
    }

    return aitemstack;
}
项目:DecompiledMinecraft    文件:ShapedRecipes.java   
public ItemStack[] getRemainingItems(InventoryCrafting inv)
{
    ItemStack[] aitemstack = new ItemStack[inv.getSizeInventory()];

    for (int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem().hasContainerItem())
        {
            aitemstack[i] = new ItemStack(itemstack.getItem().getContainerItem());
        }
    }

    return aitemstack;
}
项目:CustomWorldGen    文件:RecipesArmorDyes.java   
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    ItemStack itemstack = null;
    List<ItemStack> list = Lists.<ItemStack>newArrayList();

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack1 = inv.getStackInSlot(i);

        if (itemstack1 != null)
        {
            if (itemstack1.getItem() instanceof ItemArmor)
            {
                ItemArmor itemarmor = (ItemArmor)itemstack1.getItem();

                if (itemarmor.getArmorMaterial() != ItemArmor.ArmorMaterial.LEATHER || itemstack != null)
                {
                    return false;
                }

                itemstack = itemstack1;
            }
            else
            {
                if (itemstack1.getItem() != Items.DYE)
                {
                    return false;
                }

                list.add(itemstack1);
            }
        }
    }

    return itemstack != null && !list.isEmpty();
}
项目:Mods    文件:TF2CraftingManager.java   
/**
 * Retrieves an ItemStack that has multiple recipes for it.
 */
@Nullable
public ItemStack findMatchingRecipe(InventoryCrafting craftMatrix, World worldIn) {
    for (IRecipe irecipe : this.recipes)
        if (irecipe.matches(craftMatrix, worldIn))
            return irecipe.getCraftingResult(craftMatrix);

    return ItemStack.EMPTY;
}
项目:pnc-repressurized    文件:RecipePneumaticHelmet.java   
@Override
public ItemStack getCraftingResult(InventoryCrafting inventory) {
    ItemStack output = getRecipeOutput();
  //As the recipe is 2 high it could be in the 2nd row too.
    int offsetY = inventory.getStackInRowAndColumn(0, 0).isEmpty() ? 1 : 0;
    int totalDamage = inventory.getStackInRowAndColumn(0, offsetY).getItemDamage()
            + inventory.getStackInRowAndColumn(2, offsetY).getItemDamage()
            + inventory.getStackInRowAndColumn(0, offsetY + 1).getItemDamage()
            + inventory.getStackInRowAndColumn(2, offsetY + 1).getItemDamage();

    ((IPressurizable) output.getItem()).addAir(output, PneumaticValues.PNEUMATIC_HELMET_VOLUME * 10 - totalDamage);
    return output;
}
项目:BaseClient    文件:RecipeRepairItem.java   
/**
 * Used to check if a recipe matches current crafting inventory
 */
public boolean matches(InventoryCrafting inv, World worldIn)
{
    List<ItemStack> list = Lists.<ItemStack>newArrayList();

    for (int i = 0; i < inv.getSizeInventory(); ++i)
    {
        ItemStack itemstack = inv.getStackInSlot(i);

        if (itemstack != null)
        {
            list.add(itemstack);

            if (list.size() > 1)
            {
                ItemStack itemstack1 = (ItemStack)list.get(0);

                if (itemstack.getItem() != itemstack1.getItem() || itemstack1.stackSize != 1 || itemstack.stackSize != 1 || !itemstack1.getItem().isDamageable())
                {
                    return false;
                }
            }
        }
    }

    return list.size() == 2;
}
项目:minecraft-quiverbow    文件:Recipe_Ammo.java   
private boolean isInMatrix(InventoryCrafting matrix, Item item) 
{
    if (item == null) { return false; } // Can't find what doesn't exist

    int counter = 0;

    ItemStack stack = matrix.getStackInSlot(counter);

    while (counter < matrix.getSizeInventory()) // scouring through the entire thing
    {
        if (stack != null && stack.getItem().getClass() == item.getClass()) // Found one!
        { 
            if (stack.getItem() instanceof _WeaponBase) // Is a weapon, so need to ensure that it's empty
            {
                if (stack.getItemDamage() == stack.getMaxDamage()) { return true; }
                // else, isn't empty
            }
            else if (stack.getItem() instanceof _AmmoBase)  // is ammo
            {
                this.metadata = stack.getItemDamage();  // Keeping track of what this is gonna make, so I don't have to constantly recheck
                return true; 
            }
            // else, don't care what this is
        }
        // else, empty. That's fine

        // Next!
        counter += 1;
        stack = matrix.getStackInSlot(counter);
    }

    return false;   // Fallback. Didn't find what I'm looking for
}
项目:pnc-repressurized    文件:RecipeColorDrone.java   
@Override
public boolean matches(InventoryCrafting inventoryCrafting, World world) {
    boolean hasDrone = false, hasDye = false;
    for (int i = 0; i < inventoryCrafting.getSizeInventory(); i++) {
        ItemStack stack = inventoryCrafting.getStackInSlot(i);
        if (stack.getItem() == Itemss.DRONE) {
            if (!hasDrone) hasDrone = true;
            else return false;
        } else if (!stack.isEmpty() && TileEntityPlasticMixer.getDyeIndex(stack) >= 0) {
            if (!hasDye) hasDye = true;
            else return false;
        }
    }
    return hasDrone && hasDye;
}
项目:pnc-repressurized    文件:AbstractRecipe.java   
/**
 * Copied from ShapedRecipes
 */
@Override
public NonNullList<ItemStack> getRemainingItems(InventoryCrafting inv) {
    NonNullList<ItemStack> aitemstack = NonNullList.withSize(inv.getSizeInventory(), ItemStack.EMPTY);

    for (int i = 0; i < aitemstack.size(); ++i) {
        ItemStack itemstack = inv.getStackInSlot(i);
        aitemstack.set(i, net.minecraftforge.common.ForgeHooks.getContainerItem(itemstack));
    }

    return aitemstack;
}