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


Java ForgeHooks.getContainerItem方法代码示例

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


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

示例1: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) {
    final ItemStack[] remainingItems = new ItemStack[inventoryCrafting.getSizeInventory()];

    for (int i = 0; i < remainingItems.length; ++i) {
        final ItemStack itemstack = inventoryCrafting.getStackInSlot(i);

        if (itemstack != null && itemstack.getItem() instanceof ItemAxe) {
            remainingItems[i] = damageAxe(itemstack.copy());
        } else {
            remainingItems[i] = ForgeHooks.getContainerItem(itemstack);
        }
    }

    return remainingItems;
}
 
开发者ID:droidicus,项目名称:AquaRegia,代码行数:17,代码来源:ShapelessCuttingRecipe.java

示例2: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) {
	// Crafting result array
	final ItemStack[] remainingItems = new ItemStack[inventoryCrafting.getSizeInventory()];

	// For each item in the crafting grid...
	for (int i = 0; i < remainingItems.length; ++i) {
		// Get the ItemStack
		final ItemStack itemstack = inventoryCrafting.getStackInSlot(i);

		// If the ItemStack is in the config for freeLightItems
		if (itemstack != null && ModConfig.freeLightItems.contains(itemstack.getItem().getRegistryName())) {
			remainingItems[i] = itemstack.copy(); // Don't consume the item
		} else {
			remainingItems[i] = ForgeHooks.getContainerItem(itemstack); // Consume the item
		}
	}

	return remainingItems;
}
 
开发者ID:WolfieWaffle,项目名称:Survivalist-Lighting,代码行数:21,代码来源:ShapelessReuseRecipe.java

示例3: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) {
	// Crafting result array
	final ItemStack[] remainingItems = new ItemStack[inventoryCrafting.getSizeInventory()];

	// For each item in the crafting grid...
	for (int i = 0; i < remainingItems.length; ++i) {
		// Get the ItemStack
		final ItemStack itemstack = inventoryCrafting.getStackInSlot(i);

		// If the ItemStack is in the config for lightItems
		if (itemstack != null && ModConfig.lightItems.contains(itemstack.getItem().getRegistryName())) {
			remainingItems[i] = damageItem(itemstack.copy()); // Leave a damaged lighter in the grid
		} else {
			remainingItems[i] = ForgeHooks.getContainerItem(itemstack); // Consume the item
		}
	}

	return remainingItems;
}
 
开发者ID:WolfieWaffle,项目名称:Survivalist-Lighting,代码行数:21,代码来源:ShapelessDamageRecipe.java

示例4: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inventoryCrafting) {
    ItemStack[] aitemstack = new ItemStack[inventoryCrafting.getSizeInventory()];
    for (int i = 0; i < aitemstack.length; ++i) {
        ItemStack itemstack = inventoryCrafting.getStackInSlot(i);
        if (itemstack != null && itemstack.getItem() == ModItems.knife) {
            if (itemstack.attemptDamageItem(1, Utils.rand())) {
                if (--itemstack.stackSize < 1) {
                    itemstack = null;
                }
                if (Utils.isClientSide()) {
                    Minecraft.getMinecraft().thePlayer.playSound("random.break", 0.8F, 0.8F + Utils.rand().nextFloat() * 0.4F);
                }
            }
            aitemstack[i] = itemstack == null ? null : itemstack.copy();
        } else {
            aitemstack[i] = ForgeHooks.getContainerItem(itemstack);
        }
    }
    return aitemstack;
}
 
开发者ID:Darkyoooooo,项目名称:DimsumCraft,代码行数:22,代码来源:KnifeRecipes.java

示例5: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的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

示例6: getRemainingItems

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

    matches(inv, null);

    for (int i = 0; i < invSlots.length; i++)
    {
        int amount = damageAmounts[i];
        int invIndex = invSlots[i];
        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,代码行数:30,代码来源:DamageableShapelessOreRecipe.java

示例7: smeltItem

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public void smeltItem()
{
		ItemStack itemStack = findMatchingRecipe();

		if (mainHandler.getStackInSlot(OUTPUT) == null)//STACKNULL
		{
			mainHandler.setStackInSlot(OUTPUT, itemStack.copy());
		}
		else if (mainHandler.getStackInSlot(OUTPUT).getItem() == itemStack.getItem())
		{
			CapUtils.incrementStack(mainHandler, OUTPUT, itemStack.getCount());
		}

		for (int i = INPUTSTART; i < mainHandler.getSlots(); ++i)
		{
			ItemStack stack = mainHandler.getStackInSlot(i);
			if (stack != null)//STACKNULL
			{
				ItemStack containerItem = ForgeHooks.getContainerItem(mainHandler.getStackInSlot(i));
				if (containerItem != null)//STACKNULL
				{
					mainHandler.setStackInSlot(i, containerItem);
				}
				else
				{
				    CapUtils.decrementStack(mainHandler, i, 1);

				    if (mainHandler.getStackInSlot(i).getCount() <= 0)
				    {
					mainHandler.setStackInSlot(i, null);//STACKNULL
				    }
				}
			}
		}
}
 
开发者ID:einsteinsci,项目名称:BetterBeginningsReborn,代码行数:37,代码来源:TileEntityOvenBase.java

示例8: consumeFromInventoryFuel

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public static int consumeFromInventoryFuel(IItemHandlerModifiable handler, int fuelAmtToConsume, boolean simulate, @Nullable NBTTagCompound matchNBTTag) {
    Map<Integer, ItemStack> contents = findItemsIndexedInInventoryFuel(handler, matchNBTTag);
    if (contents.isEmpty()) {
        return fuelAmtToConsume;
    }

    for (int slot : contents.keySet()) {
        ItemStack inSlot = contents.get(slot);
        if(inSlot.getItem().hasContainerItem(inSlot)) {
            if(inSlot.getCount() > 1) {
                continue; //uh... rip. we won't consume 16 buckets at once.
            }
            ItemStack stack = ForgeHooks.getContainerItem(inSlot);
            fuelAmtToConsume -= TileEntityFurnace.getItemBurnTime(inSlot);
            if (!simulate) {
                handler.setStackInSlot(slot, stack.copy());
            }
            if (fuelAmtToConsume <= 0) {
                break;
            }
        }
        int fuelPer = TileEntityFurnace.getItemBurnTime(inSlot);
        int toConsumeDiv = fuelAmtToConsume / fuelPer;
        int fuelMod = fuelAmtToConsume % fuelPer;

        int toConsume = toConsumeDiv + (fuelMod > 0 ? 1 : 0);
        int toRemove = toConsume > inSlot.getCount() ? inSlot.getCount() : toConsume;

        fuelAmtToConsume -= toRemove * fuelPer;
        if (!simulate) {
            handler.setStackInSlot(slot, copyStackWithSize(inSlot, inSlot.getCount() - toRemove));
        }
        if (fuelAmtToConsume <= 0) {
            break;
        }
    }
    return fuelAmtToConsume;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:39,代码来源:ItemUtils.java

示例9: consumeFromInventory

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public static boolean consumeFromInventory(IItemHandlerModifiable handler, ItemStack toConsume, boolean simulate, @Nullable NBTTagCompound matchNBTTag) {
    Map<Integer, ItemStack> contents = findItemsIndexedInInventory(handler, toConsume, false, matchNBTTag);
    if (contents.isEmpty()) return false;

    int cAmt = toConsume.getCount();
    for (int slot : contents.keySet()) {
        ItemStack inSlot = contents.get(slot);
        if(inSlot.getItem().hasContainerItem(inSlot)) {
            if(inSlot.getCount() > 1) {
                continue; //uh... rip. we won't consume 16 buckets at once.
            }
            ItemStack stack = ForgeHooks.getContainerItem(inSlot);
            cAmt--;
            if (!simulate) {
                handler.setStackInSlot(slot, stack.copy());
            }
            if (cAmt <= 0) {
                break;
            }
        }
        int toRemove = cAmt > inSlot.getCount() ? inSlot.getCount() : cAmt;
        cAmt -= toRemove;
        if (!simulate) {
            handler.setStackInSlot(slot, copyStackWithSize(inSlot, inSlot.getCount() - toRemove));
        }
        if (cAmt <= 0) {
            break;
        }
    }
    return cAmt <= 0;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:32,代码来源:ItemUtils.java

示例10: consumeFromInventoryOreDict

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public static boolean consumeFromInventoryOreDict(IItemHandlerModifiable handler, String oreName, int amount, boolean simulate, @Nullable NBTTagCompound matchNBTTag) {
    Map<Integer, ItemStack> contents = findItemsIndexedInInventoryOreDict(handler, oreName, matchNBTTag);
    if (contents.isEmpty()) return false;

    int cAmt = amount;
    for (int slot : contents.keySet()) {
        ItemStack inSlot = contents.get(slot);
        if(inSlot.getItem().hasContainerItem(inSlot)) {
            if(inSlot.getCount() > 1) {
                continue; //uh... rip. we won't consume 16 buckets at once.
            }
            ItemStack stack = ForgeHooks.getContainerItem(inSlot);
            cAmt--;
            if (!simulate) {
                handler.setStackInSlot(slot, stack.copy());
            }
            if (cAmt <= 0) {
                break;
            }
        }
        int toRemove = cAmt > inSlot.getCount() ? inSlot.getCount() : cAmt;
        cAmt -= toRemove;
        if (!simulate) {
            handler.setStackInSlot(slot, copyStackWithSize(inSlot, inSlot.getCount() - toRemove));
        }
        if (cAmt <= 0) {
            break;
        }
    }
    return cAmt <= 0;
}
 
开发者ID:HellFirePvP,项目名称:ModularMachinery,代码行数:32,代码来源:ItemUtils.java

示例11: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public ItemStack[] getRemainingItems(InventoryCrafting inv) {
    // Get our input map; fall back to base functionality if it fails (somehow)
    Map<Integer, RecipeInput> inputMap = getInputMap(inv);
    if(inputMap == null) return super.getRemainingItems(inv);

    ItemStack[] ret = new ItemStack[inv.getSizeInventory()];

    for(Map.Entry<Integer, RecipeInput> input : inputMap.entrySet()) {
        // Get the stack in the given slot; also bypass if this is somehow
        // now null.  Seriously?
        ItemStack slot = inv.getStackInSlot(input.getKey());
        if(slot == null) continue;

        // Duplicate and transform.  Makes me think Replicators...
        ItemStack transformed = input.getValue()
                .applyTransformers(
                        slot.copy(),
                        ForgeHooks.getCraftingPlayer());

        // Check if we're destroying the item or not...
        ret[input.getKey()] = transformed != null && transformed.stackSize != 0
                ? transformed
                : ForgeHooks.getContainerItem(transformed);
    }

    return ret;
}
 
开发者ID:legendblade,项目名称:CraftingHarmonics,代码行数:29,代码来源:ShapelessComponentRecipe.java

示例12: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
public static ItemStack[] getRemainingItems(InventoryCrafting inv) {
    ItemStack[] ret = new ItemStack[inv.getSizeInventory()];
    for (int i = 0; i < inv.getSizeInventory(); i++) {
        ret[i] = ForgeHooks.getContainerItem(inv.getStackInSlot(i));
    }
    return ret;
}
 
开发者ID:purpleposeidon,项目名称:Factorization,代码行数:8,代码来源:CraftUtil.java

示例13: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
/** This just returns whatever should be in the inventory afterwards */
@Override
public ItemStack[] getRemainingItems(InventoryCrafting craft) {
    ItemStack stack = getOutput(null, craft, false);
    if (stack == null || stack.getItem() == null || !(stack.getItem() instanceof ItemTechnology)) {
        // If it was a normal (or other) crafting recipe
        ItemStack[] stacks = new ItemStack[craft.getSizeInventory()];
        for (int index = 0; index < stacks.length; index++) {
            stacks[index] = ForgeHooks.getContainerItem(craft.getStackInSlot(index));
        }
        return stacks;
    }
    ItemTechnology item = (ItemTechnology) stack.getItem();
    int[] packs = item.getScienceCount(stack);
    boolean hasAny = false;
    for (int pack : packs)
        hasAny |= pack > 0;
    if (hasAny) {
        // If it was (tech + beaker(s) -> tech)
        return new ItemStack[craft.getSizeInventory()];
    }
    // If it was (child tech -> parent tech)
    ItemStack[] aitemstack = new ItemStack[craft.getSizeInventory()];
    for (int i = 0; i < aitemstack.length; ++i) {
        ItemStack itemstack = craft.getStackInSlot(i);
        aitemstack[i] = ForgeHooks.getContainerItem(itemstack);
    }
    return aitemstack;
}
 
开发者ID:AlexIIL,项目名称:CivCraft,代码行数:30,代码来源:RecipeTech.java

示例14: getRemainingItems

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public ItemStack[] getRemainingItems(InventoryCrafting p_179532_1_)
{
    ItemStack[] aitemstack = new ItemStack[p_179532_1_.getSizeInventory()];

    for(int i = 0; i < aitemstack.length; ++i)
    {
        ItemStack itemstack = p_179532_1_.getStackInSlot(i);
        aitemstack[i] = ForgeHooks.getContainerItem(itemstack);
    }

    return aitemstack;
}
 
开发者ID:Superloup10,项目名称:Wolf-s-addons,代码行数:14,代码来源:ShapedRecipesCompressor.java

示例15: updateEntity

import net.minecraftforge.common.ForgeHooks; //导入方法依赖的package包/类
@Override
public void updateEntity(IBlockState state) {
	if (world.isRemote || state.getValue(ResearchTable.STATE) != 2)
		return;
	if (this.craftingErrorShowTimer > 0)
		if (this.craftingErrorShowTimer-- == 1 && (craftingError == 2 || craftingError == 3 || craftingError == 4))
			craftingError = 0;
	if (!inv.getStackInSlot(0).isEmpty() && inv.getStackInSlot(0).getItem() == CoreInit.bigNoteBook && inv.getStackInSlot(0).getTagCompound() != null && inv.getStackInSlot(0).getTagCompound().hasKey("owner")) {
		if (checkPower()) {
			if (this.totalResearchProgress > 0 && this.inkLevel > 0) {
				if (this.researchProgress == this.totalResearchProgress) {
					this.totalResearchProgress = 0;
					this.researchProgress = 0;
					ResearchHandler h = getResearchHandler(inv.getStackInSlot(0));
					if (h != null) {
						h.markResearchComplete(currentResearch);
						this.currentResearch = null;
					}
				} else
					this.researchProgress++;
				if (this.researchProgress % 10 == 0)
					this.inkLevel--;
				if (this.currentResearch != null)
					handlePower(this.currentResearch.getEnergyRequired());
			}
			if (this.totalCrafingTime > 0) {
				if (this.totalCrafingTime == this.craftingTime) {
					if (this.craft()) {
						this.craftingTime = 0;
						this.totalCrafingTime = 0;
						this.craftingError = 0;
						if (craftAll) {
							craftAll = startCrafting(null, true);
						}
					} else {
						this.craftingError = 1;
					}
				} else
					this.craftingTime++;
				if (craftingError == 0)
					handlePower(1);
			}
		}
	} else {
		this.currentResearch = null;
	}
	if (this.inkLevel < 1 && OreDict.isOre(inv.getStackInSlot(2), "dyeBlack")) {
		this.inkLevel += 100;
		ItemStack s = ForgeHooks.getContainerItem(decrStackSize(2, 1));
		if (!s.isEmpty()) {
			if (inv.getStackInSlot(2).isEmpty()) {
				inv.setInventorySlotContents(2, s.copy());
			} else {
				InventoryHelper.spawnItemStack(world, pos.getX(), pos.getY(), pos.getZ(), s.copy());
			}
		}
	}
}
 
开发者ID:tom5454,项目名称:Toms-Mod,代码行数:59,代码来源:TileEntityResearchTable.java


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