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


Java IRecipe.getIngredients方法代码示例

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


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

示例1: addPressureChamberStorageBlockRecipes

import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
/**
 * Adds recipes like 9 gold ingot --> 1 gold block, and 1 gold block --> 9 gold ingots.
 */
public static void addPressureChamberStorageBlockRecipes() {
    // search for a 3x3 recipe where all 9 ingredients are the same
    for (IRecipe recipe : CraftingManager.REGISTRY) {
        if (recipe instanceof ShapedRecipes) {
            ShapedRecipes shaped = (ShapedRecipes) recipe;
            NonNullList<Ingredient> ingredients = recipe.getIngredients();
            ItemStack ref = ingredients.get(0).getMatchingStacks()[0];
            if (ref.isEmpty() || ingredients.size() < 9) continue;
            boolean valid = true;
            for (int i = 0; i < 9; i++) {
                ItemStack stack = ingredients.get(i).getMatchingStacks()[0];
                if (!stack.isItemEqual(ref)) {
                    valid = false;
                    break;
                }
            }
            if (valid) {
                ItemStack inputStack = ref.copy();
                inputStack.setCount(9);
                PressureChamberRecipe.chamberRecipes.add(new PressureChamberRecipe(new ItemStack[]{inputStack}, 1.0F, new ItemStack[]{shaped.getRecipeOutput()}, false));

                ItemStack inputStack2 = shaped.getRecipeOutput().copy();
                inputStack2.setCount(1);
                PressureChamberRecipe.chamberRecipes.add(new PressureChamberRecipe(new ItemStack[]{inputStack2}, -0.5F, new ItemStack[]{inputStack}, false));

            }
        }
    }
}
 
开发者ID:TeamPneumatic,项目名称:pnc-repressurized,代码行数:33,代码来源:CraftingRegistrator.java

示例2: actionPerformed

import net.minecraft.item.crafting.IRecipe; //导入方法依赖的package包/类
@Override
@SuppressWarnings("unchecked")
protected void actionPerformed(GuiButton button) throws IOException {
	if (button.id < 12) {
		int currentRecipe = button.id + this.firstIndex;
		((ContainerTF2Workbench) this.inventorySlots).currentRecipe = currentRecipe;
		this.mc.playerController.sendEnchantPacket(this.inventorySlots.windowId, currentRecipe);
		setButtons();
		this.inventorySlots.onCraftMatrixChanged(null);
		itemsToRender = new ItemStack[9];
		if (currentRecipe >= 0 && currentRecipe < TF2CraftingManager.INSTANCE.getRecipeList().size()) {
			IRecipe recipe = TF2CraftingManager.INSTANCE.getRecipeList().get(currentRecipe);
			if (recipe instanceof AustraliumRecipe) {
				itemsToRender[0] = new ItemStack(TF2weapons.itemTF2, 1, 2);
				itemsToRender[1] = new ItemStack(TF2weapons.itemTF2, 1, 2);
				itemsToRender[2] = new ItemStack(TF2weapons.itemTF2, 1, 2);
				itemsToRender[3] = new ItemStack(TF2weapons.itemTF2, 1, 2);
				itemsToRender[5] = new ItemStack(TF2weapons.itemTF2, 1, 2);
				itemsToRender[6] = new ItemStack(TF2weapons.itemTF2, 1, 2);
				itemsToRender[7] = new ItemStack(TF2weapons.itemTF2, 1, 2);
				itemsToRender[8] = new ItemStack(TF2weapons.itemTF2, 1, 2);
				itemsToRender[4] = new ItemStack(TF2weapons.itemTF2, 1, 9);
			} else if (recipe instanceof JumperRecipe) {
				itemsToRender[0] = new ItemStack(Items.FEATHER);
				itemsToRender[1] = new ItemStack(Items.FEATHER);
				itemsToRender[2] = new ItemStack(Items.FEATHER);
				itemsToRender[3] = new ItemStack(Items.FEATHER);
				itemsToRender[5] = new ItemStack(Items.FEATHER);
				itemsToRender[6] = new ItemStack(Items.FEATHER);
				itemsToRender[7] = new ItemStack(Items.FEATHER);
				itemsToRender[8] = new ItemStack(Items.FEATHER);
				itemsToRender[4] = ItemFromData.getNewStack(((JumperRecipe)recipe).nameBefore);
			} else if (recipe instanceof RecipeToScrap) {
				itemsToRender[0] = new ItemStack(TF2weapons.itemTF2, 1, 9);
				itemsToRender[1] = new ItemStack(TF2weapons.itemTF2, 1, 9);
			} else if (recipe instanceof OpenCrateRecipe) {
				itemsToRender[0] = new ItemStack(TF2weapons.itemTF2, 1, 7);
				itemsToRender[1] = ItemFromData.getNewStack("crate1");
			}
			else{
				List<Ingredient> input = recipe.getIngredients();
				
				for (int i = 0; i < input.size(); i++) {
					int space = 0;
					if(recipe instanceof ShapedRecipes)
						space = (3-((ShapedRecipes)recipe).recipeWidth)*(i/((ShapedRecipes)recipe).recipeWidth);
					else if(recipe instanceof ShapedOreRecipe)
						space = (3-((ShapedOreRecipe)recipe).getWidth())*(i/((ShapedOreRecipe)recipe).getWidth());
						
					if(input.get(i).getMatchingStacks().length>0) {
						itemsToRender[i + space] = input.get(i).getMatchingStacks()[0];
						if(itemsToRender[i + space].getMetadata()==32767)
							itemsToRender[i + space].setItemDamage(0);
					}
				}
			}
		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:60,代码来源:GuiTF2Crafting.java


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