Search in sources :

Example 1 with IngredientAccess

use of mod.azure.doom.mixin.IngredientAccess in project MCDoom by AzureDoom.

the class GunTableScreenHandler method switchTo.

public void switchTo(int recipeIndex) {
    // index out of bounds
    if (this.getRecipes().size() > recipeIndex) {
        GunTableRecipe gunTableRecipe = getRecipes().get(recipeIndex);
        for (int i = 0; i < 5; i++) {
            ItemStack slotStack = gunTableInventory.getStack(i);
            if (!slotStack.isEmpty()) {
                // if all positions can't be filled, transfer nothing
                if (!this.insertItem(slotStack, 6, 39, false)) {
                    return;
                }
                gunTableInventory.setStack(i, slotStack);
            }
        }
        for (int i = 0; i < 5; i++) {
            Ingredient ingredient = gunTableRecipe.getIngredientForSlot(i);
            if (!ingredient.isEmpty()) {
                ItemStack[] possibleItems = ((IngredientAccess) (Object) ingredient).getMatchingStacksMod();
                if (possibleItems != null) {
                    ItemStack first = new ItemStack(possibleItems[0].getItem(), gunTableRecipe.countRequired(i));
                    autofill(i, first);
                }
            }
        }
    }
}
Also used : Ingredient(net.minecraft.recipe.Ingredient) IngredientAccess(mod.azure.doom.mixin.IngredientAccess) GunTableRecipe(mod.azure.doom.util.recipes.GunTableRecipe) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IngredientAccess (mod.azure.doom.mixin.IngredientAccess)1 GunTableRecipe (mod.azure.doom.util.recipes.GunTableRecipe)1 ItemStack (net.minecraft.item.ItemStack)1 Ingredient (net.minecraft.recipe.Ingredient)1