Java Code Examples for net.minecraftforge.oredict.ShapedOreRecipe#getInput()

The following examples show how to use net.minecraftforge.oredict.ShapedOreRecipe#getInput() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public CachedShapedRecipe forgeShapedRecipe(ShapedOreRecipe recipe) {
    int width;
    int height;
    try {
        width = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 4);
        height = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 5);
    } catch (Exception e) {
        LogHelper.errorError("Error loading recipe", e);
        return null;
    }

    Object[] items = recipe.getInput();
    for (Object item : items) {
        if (item instanceof List && ((List<?>) item).isEmpty())//ore handler, no ores
        {
            return null;
        }
    }

    return new CachedShapedRecipe(width, height, items, recipe.getRecipeOutput());
}
 
Example 2
Source File: ShapedRecipeHandler.java    From NotEnoughItems with MIT License 6 votes vote down vote up
public CachedShapedRecipe forgeShapedRecipe(ShapedOreRecipe recipe) {
    int width;
    int height;
    try {
        width = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 4);
        height = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 5);
    } catch (Exception e) {
        NEIClientConfig.logger.error("Error loading recipe", e);
        return null;
    }

    Object[] items = recipe.getInput();
    for (Object item : items)
        if (item instanceof List && ((List<?>) item).isEmpty())//ore handler, no ores
            return null;

    return new CachedShapedRecipe(width, height, items, recipe.getRecipeOutput());
}
 
Example 3
Source File: RecipeHandlerRollingMachineShaped.java    From NEI-Integration with MIT License 6 votes vote down vote up
private CachedRollingMachineShapedRecipe getCachedOreRecipe(ShapedOreRecipe recipe, boolean genPerms) {
    int width;
    int height;
    try {
        width = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 4);
        height = ReflectionManager.getField(ShapedOreRecipe.class, Integer.class, recipe, 5);
    } catch (Exception e) {
        return null;
    }
    
    Object[] items = recipe.getInput();
    for (Object item : items) {
        if (item instanceof List && ((List<?>) item).isEmpty()) {
            return null;
        }
    }
    
    return new CachedRollingMachineShapedRecipe(width, height, items, recipe.getRecipeOutput(), genPerms);
}
 
Example 4
Source File: CraftingRegistrator.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
private static void scanForFluids(ShapedOreRecipe recipe){
    for(int i = 0; i < recipe.getRecipeSize(); i++) {
        Object o = recipe.getInput()[i];
        if(o instanceof ItemStack) {
            ItemStack stack = (ItemStack)o;
            FluidStack fluid = FluidContainerRegistry.getFluidForFilledItem(stack);
            if(fluid != null) {
                GameRegistry.addRecipe(new RecipeFluid(recipe, i));
            }
        }
    }
}
 
Example 5
Source File: RecipeFluid.java    From PneumaticCraft with GNU General Public License v3.0 5 votes vote down vote up
public RecipeFluid(ShapedOreRecipe recipe, int fluidIndex){
    this.recipe = recipe;
    originalStack = (ItemStack)recipe.getInput()[fluidIndex];
    fluidStack = FluidContainerRegistry.getFluidForFilledItem(originalStack);
    if(fluidStack == null) throw new IllegalArgumentException("Recipe doesn't have fluid item at index " + fluidIndex + ". Item: " + originalStack);
    this.fluidIndex = fluidIndex;
}