本文整理汇总了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));
}
}
}
}
示例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);
}
}
}
}
}
}