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