Java 类net.minecraft.item.crafting.ShapedRecipes 实例源码

项目:ArcaneMagic    文件:RecipeHelper.java   
/**
 * Same thing as genShaped above, but uses a specific group.
 */
private static ShapedRecipes genShaped(String group, ItemStack output, int l, int w, Object[] input)
{
    if (input[0] instanceof List)
        input = ((List<?>) input[0]).toArray();
    if (l * w != input.length)
        throw new UnsupportedOperationException(
                "Attempted to add invalid shaped recipe.  Complain to the author of " + MODNAME);
    NonNullList<Ingredient> inputL = NonNullList.create();
    for (int i = 0; i < input.length; i++)
    {
        Object k = input[i];
        if (k instanceof String)
            inputL.add(i, new OreIngredient((String) k));
        else if (k instanceof ItemStack && !((ItemStack) k).isEmpty())
            inputL.add(i, Ingredient.fromStacks((ItemStack) k));
        else if (k instanceof IForgeRegistryEntry)
            inputL.add(i, Ingredient.fromStacks(makeStack((IForgeRegistryEntry<?>) k)));
        else
            inputL.add(i, Ingredient.EMPTY);
    }

    return new ShapedRecipes(group, l, w, inputL, output);
}
项目:CustomWorldGen    文件:RecipeSorter.java   
private RecipeSorter()
{
    register("minecraft:shaped",       ShapedRecipes.class,       SHAPED,    "before:minecraft:shapeless");
    register("minecraft:mapextending", RecipesMapExtending.class, SHAPED,    "after:minecraft:shaped before:minecraft:shapeless");
    register("minecraft:shapeless",    ShapelessRecipes.class,    SHAPELESS, "after:minecraft:shaped");
    register("minecraft:shield_deco",  ShieldRecipes.Decoration.class, SHAPELESS, "after:minecraft:shapeless"); //Size 2
    register("minecraft:repair",       RecipeRepairItem.class,    SHAPELESS, "after:minecraft:shapeless"); //Size 4
    register("minecraft:bookcloning",  RecipeBookCloning.class,   SHAPELESS, "after:minecraft:shapeless"); //Size 9
    register("minecraft:tippedarrow",  RecipeTippedArrow.class,   SHAPELESS, "after:minecraft:shapeless"); //Size 9
    register("minecraft:fireworks",    RecipeFireworks.class,     SHAPELESS, "after:minecraft:shapeless"); //Size 10
    register("minecraft:armordyes",    RecipesArmorDyes.class,    SHAPELESS, "after:minecraft:shapeless"); //Size 10
    register("minecraft:mapcloning",   RecipesMapCloning.class,   SHAPELESS, "after:minecraft:shapeless"); //Size 10
    register("minecraft:pattern_dupe", RecipeDuplicatePattern.class, SHAPELESS, "after:minecraft:shapeless"); //Size 2
    register("minecraft:pattern_add",  RecipeAddPattern.class,       SHAPELESS, "after:minecraft:shapeless"); //Size 10

    register("forge:shapedore",     ShapedOreRecipe.class,    SHAPED,    "after:minecraft:shaped before:minecraft:shapeless");
    register("forge:shapelessore",  ShapelessOreRecipe.class, SHAPELESS, "after:minecraft:shapeless");
}
项目:CustomWorldGen    文件:ShapedOreRecipe.java   
ShapedOreRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
{
    output = recipe.getRecipeOutput();
    width = recipe.recipeWidth;
    height = recipe.recipeHeight;

    input = new Object[recipe.recipeItems.length];

    for(int i = 0; i < input.length; i++)
    {
        ItemStack ingredient = recipe.recipeItems[i];

        if(ingredient == null) continue;

        input[i] = recipe.recipeItems[i];

        for(Entry<ItemStack, String> replace : replacements.entrySet())
        {
            if(OreDictionary.itemMatches(replace.getKey(), ingredient, true))
            {
                input[i] = OreDictionary.getOres(replace.getValue());
                break;
            }
        }
    }
}
项目:ExtraUtilities    文件:EnderConstructorHandler.java   
public void loadUsageRecipes(final ItemStack ingredient) {
    for (final IRecipe irecipe : EnderConstructorRecipesHandler.recipes) {
        ShapedRecipeHandler.CachedShapedRecipe recipe = null;
        if (irecipe instanceof ShapedRecipes) {
            recipe = new ShapedRecipeHandler.CachedShapedRecipe((ShapedRecipes)irecipe);
        }
        else if (irecipe instanceof ShapedOreRecipe) {
            recipe = this.forgeShapedRecipe((ShapedOreRecipe)irecipe);
        }
        if (recipe != null) {
            if (!recipe.contains((Collection)recipe.ingredients, ingredient.getItem())) {
                continue;
            }
            recipe.computeVisuals();
            if (!recipe.contains((Collection)recipe.ingredients, ingredient)) {
                continue;
            }
            recipe.setIngredientPermutation((Collection)recipe.ingredients, ingredient);
            this.arecipes.add(recipe);
        }
    }
}
项目:ExtraUtilities    文件:EnderConstructorHandler.java   
public void loadCraftingRecipes(final String outputId, final Object... results) {
    if (outputId.equals(this.getOverlayIdentifier())) {
        for (final IRecipe irecipe : EnderConstructorRecipesHandler.recipes) {
            ShapedRecipeHandler.CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes) {
                recipe = new ShapedRecipeHandler.CachedShapedRecipe((ShapedRecipes)irecipe);
            }
            else if (irecipe instanceof ShapedOreRecipe) {
                recipe = this.forgeShapedRecipe((ShapedOreRecipe)irecipe);
            }
            if (recipe == null) {
                continue;
            }
            recipe.computeVisuals();
            this.arecipes.add(recipe);
        }
    }
    else if (outputId.equals("item")) {
        this.loadCraftingRecipes((ItemStack)results[0]);
    }
}
项目:ExtraUtilities    文件:EnderConstructorHandler.java   
public void loadCraftingRecipes(final ItemStack result) {
    for (final IRecipe irecipe : EnderConstructorRecipesHandler.recipes) {
        if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
            ShapedRecipeHandler.CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes) {
                recipe = new ShapedRecipeHandler.CachedShapedRecipe((ShapedRecipes)irecipe);
            }
            else if (irecipe instanceof ShapedOreRecipe) {
                recipe = this.forgeShapedRecipe((ShapedOreRecipe)irecipe);
            }
            if (recipe == null) {
                continue;
            }
            recipe.computeVisuals();
            this.arecipes.add(recipe);
        }
    }
}
项目:ExtraUtilities    文件:FMPMicroBlocksHandler.java   
public void loadCraftingRecipes(final ItemStack result) {
    if (!result.hasTagCompound() || "".equals(result.getTagCompound().getString("mat"))) {
        return;
    }
    final MicroMaterialRegistry.IMicroMaterial m = MicroMaterialRegistry.getMaterial(result.getTagCompound().getString("mat"));
    if (m == null) {
        return;
    }
    this.scroll = false;
    this.currentMaterial = result.getTagCompound().getString("mat");
    this.currentBlock = m.getItem().copy();
    for (final ShapedRecipes irecipe : getCraftingRecipes()) {
        if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
            final MicroblockCachedRecipe recipe = new MicroblockCachedRecipe(irecipe);
            recipe.computeVisuals();
            this.arecipes.add(recipe);
        }
    }
}
项目:ExtraUtilities    文件:FMPMicroBlockRecipeCreator.java   
public static ArrayList<ShapedRecipes> loadRecipes() {
    final ArrayList<ShapedRecipes> set = new ArrayList<ShapedRecipes>();
    FMPMicroBlockRecipeCreator.mat = MicroRecipe.findMaterial(FMPMicroBlockRecipeCreator.stone);
    if (FMPMicroBlockRecipeCreator.mat == -1) {
        return set;
    }
    FMPMicroBlockRecipeCreator.saw = new ItemStack(MicroblockProxy.sawDiamond());
    if (FMPMicroBlockRecipeCreator.saw == null) {
        return set;
    }
    loadThinningRecipes(set);
    loadSplittingRecipes(set);
    loadHollowRecipes(set);
    loadHollowFillingRecipes(set);
    loadGluingRecipes(set);
    return set;
}
项目:ExtraUtilities    文件:FMPMicroBlockRecipeCreator.java   
public static void loadThinningRecipes(final ArrayList<ShapedRecipes> recipes) {
    FMPMicroBlockRecipeCreator.craft.clear();
    FMPMicroBlockRecipeCreator.craft.setInventorySlotContents(0, 0, FMPMicroBlockRecipeCreator.saw);
    for (final int mclass : FMPMicroBlockRecipeCreator.validClasses) {
        for (final int msize : FMPMicroBlockRecipeCreator.validSizes2) {
            if (msize != 8 || mclass == 0) {
                final ItemStack a = MicroRecipe.create(1, mclass, msize, FMPMicroBlockRecipeCreator.mat);
                FMPMicroBlockRecipeCreator.craft.setInventorySlotContents(0, 1, a);
                final ItemStack b = MicroRecipe.getCraftingResult((InventoryCrafting)FMPMicroBlockRecipeCreator.craft);
                if (b != null) {
                    recipes.add(new ShapedRecipes(1, 2, new ItemStack[] { FMPMicroBlockRecipeCreator.saw, a }, b));
                }
            }
        }
    }
}
项目:ExtraUtilities    文件:FMPMicroBlockRecipeCreator.java   
public static void loadSplittingRecipes(final ArrayList<ShapedRecipes> recipes) {
    FMPMicroBlockRecipeCreator.craft.clear();
    FMPMicroBlockRecipeCreator.craft.setInventorySlotContents(0, 0, FMPMicroBlockRecipeCreator.saw);
    for (final int mclass : FMPMicroBlockRecipeCreator.validClasses) {
        for (final int msize : FMPMicroBlockRecipeCreator.validSizes2) {
            if (msize != 8 || mclass == 0) {
                final ItemStack a = MicroRecipe.create(1, mclass, msize, FMPMicroBlockRecipeCreator.mat);
                FMPMicroBlockRecipeCreator.craft.setInventorySlotContents(1, 0, a);
                final ItemStack b = MicroRecipe.getCraftingResult((InventoryCrafting)FMPMicroBlockRecipeCreator.craft);
                if (b != null) {
                    recipes.add(new ShapedRecipes(2, 1, new ItemStack[] { FMPMicroBlockRecipeCreator.saw, a }, b));
                }
            }
        }
    }
}
项目:ExtraUtilities    文件:ExtraUtils.java   
public static void registerRecipe(final Class<? extends IRecipe> recipe) {
    if (ExtraUtils.registeredRecipes.contains(recipe)) {
        return;
    }
    if (!recipe.getName().startsWith("com.rwtema.")) {
        return;
    }
    ExtraUtils.registeredRecipes.add(recipe);
    LogHelper.fine("Registering " + recipe.getSimpleName() + " to RecipeSorter", new Object[0]);
    if (ShapedOreRecipe.class.isAssignableFrom(recipe)) {
        RecipeSorter.register("extrautils:" + recipe.getSimpleName(), (Class)recipe, RecipeSorter.Category.SHAPED, "after:forge:shapedore");
    }
    else if (ShapelessOreRecipe.class.isAssignableFrom(recipe)) {
        RecipeSorter.register("extrautils:" + recipe.getSimpleName(), (Class)recipe, RecipeSorter.Category.SHAPELESS, "after:forge:shapelessore");
    }
    else if (ShapedRecipes.class.isAssignableFrom(recipe)) {
        RecipeSorter.register("extrautils:" + recipe.getSimpleName(), (Class)recipe, RecipeSorter.Category.SHAPED, "after:minecraft:shaped before:minecraft:shapeless");
    }
    else if (ShapelessRecipes.class.isAssignableFrom(recipe)) {
        RecipeSorter.register("extrautils:" + recipe.getSimpleName(), (Class)recipe, RecipeSorter.Category.SHAPELESS, "after:minecraft:shapeless before:minecraft:bookcloning");
    }
    else {
        RecipeSorter.register("extrautils:" + recipe.getSimpleName(), (Class)recipe, RecipeSorter.Category.SHAPELESS, "after:forge:shapelessore");
    }
}
项目:4Space-5    文件:CompressorRecipes.java   
private static boolean matches(ShapedRecipes recipe, IInventory inventory, World par2World)
{
    for (int i = 0; i <= 3 - recipe.recipeWidth; ++i)
    {
        for (int j = 0; j <= 3 - recipe.recipeHeight; ++j)
        {
            if (CompressorRecipes.checkMatch(recipe, inventory, i, j, true))
            {
                return true;
            }

            if (CompressorRecipes.checkMatch(recipe, inventory, i, j, false))
            {
                return true;
            }
        }
    }

    return false;
}
项目:4Space-5    文件:ShapedRecipeHandler.java   
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
    if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
        for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes)
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            else if (irecipe instanceof ShapedOreRecipe)
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

            if (recipe == null)
                continue;

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    } else {
        super.loadCraftingRecipes(outputId, results);
    }
}
项目:4Space-5    文件:ShapedRecipeHandler.java   
@Override
public void loadCraftingRecipes(ItemStack result) {
    for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
        if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes)
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            else if (irecipe instanceof ShapedOreRecipe)
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

            if (recipe == null)
                continue;

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    }
}
项目:4Space-5    文件:ShapedRecipeHandler.java   
@Override
public void loadUsageRecipes(ItemStack ingredient) {
    for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
        CachedShapedRecipe recipe = null;
        if (irecipe instanceof ShapedRecipes)
            recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
        else if (irecipe instanceof ShapedOreRecipe)
            recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

        if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem()))
            continue;

        recipe.computeVisuals();
        if (recipe.contains(recipe.ingredients, ingredient)) {
            recipe.setIngredientPermutation(recipe.ingredients, ingredient);
            arecipes.add(recipe);
        }
    }
}
项目:CrystalMod    文件:ShapedOreCrystalRecipe.java   
ShapedOreCrystalRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
{
    output = recipe.getRecipeOutput();
    width = recipe.recipeWidth;
    height = recipe.recipeHeight;

    input = new Object[recipe.recipeItems.length];

    for(int i = 0; i < input.length; i++)
    {
        ItemStack ingred = recipe.recipeItems[i];

        if(ItemStackTools.isEmpty(ingred)) continue;

        input[i] = recipe.recipeItems[i];

        for(Entry<ItemStack, String> replace : replacements.entrySet())
        {
            if(OreDictionary.itemMatches(replace.getKey(), ingred, true))
            {
                input[i] = OreDictionary.getOres(replace.getValue());
                break;
            }
        }
    }
}
项目:TRHS_Club_Mod_2016    文件:ShapedOreRecipe.java   
ShapedOreRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
{
    output = recipe.func_77571_b();
    width = recipe.field_77576_b;
    height = recipe.field_77577_c;

    input = new Object[recipe.field_77574_d.length];

    for(int i = 0; i < input.length; i++)
    {
        ItemStack ingred = recipe.field_77574_d[i];

        if(ingred == null) continue;

        input[i] = recipe.field_77574_d[i];

        for(Entry<ItemStack, String> replace : replacements.entrySet())
        {
            if(OreDictionary.itemMatches(replace.getKey(), ingred, true))
            {
                input[i] = OreDictionary.getOres(replace.getValue());
                break;
            }
        }
    }
}
项目:BIGB    文件:ShapedRecipeHandler.java   
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
    if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
        for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes)
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            else if (irecipe instanceof ShapedOreRecipe)
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

            if (recipe == null)
                continue;

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    } else {
        super.loadCraftingRecipes(outputId, results);
    }
}
项目:BIGB    文件:ShapedRecipeHandler.java   
@Override
public void loadCraftingRecipes(ItemStack result) {
    for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
        if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes)
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            else if (irecipe instanceof ShapedOreRecipe)
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

            if (recipe == null)
                continue;

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    }
}
项目:BIGB    文件:ShapedRecipeHandler.java   
@Override
public void loadUsageRecipes(ItemStack ingredient) {
    for (IRecipe irecipe : (List<IRecipe>) CraftingManager.getInstance().getRecipeList()) {
        CachedShapedRecipe recipe = null;
        if (irecipe instanceof ShapedRecipes)
            recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
        else if (irecipe instanceof ShapedOreRecipe)
            recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);

        if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem()))
            continue;

        recipe.computeVisuals();
        if (recipe.contains(recipe.ingredients, ingredient)) {
            recipe.setIngredientPermutation(recipe.ingredients, ingredient);
            arecipes.add(recipe);
        }
    }
}
项目:UncraftingTable    文件:RecipeHandlers.java   
private static void buildHandlerMap()
{
    // RecipesMapExtending extends ShapedRecipes, and causes a crash when attempting to uncraft a map
    HANDLERS.put(RecipesMapExtending.class, null);

    // vanilla Minecraft recipe handlers
    HANDLERS.put(ShapedRecipes.class, new ShapedRecipeHandler());
    HANDLERS.put(ShapelessRecipes.class, new ShapelessRecipeHandler());
    HANDLERS.put(RecipeFireworks.class, new FireworksRecipeHandler());
    HANDLERS.put(RecipeTippedArrow.class, new TippedArrowRecipeHandler());

    // Forge Ore Dictionary recipe handlers
    HANDLERS.put(ShapedOreRecipe.class, new ShapedOreRecipeHandler());
    HANDLERS.put(ShapelessOreRecipe.class, new ShapelessOreRecipeHandler());

    // cofh recipe handlers
    if (CoFHRecipeHandlers.CoverRecipeHandler.recipeClass != null) HANDLERS.put(CoFHRecipeHandlers.CoverRecipeHandler.recipeClass, new CoFHRecipeHandlers.CoverRecipeHandler());

    // industrialcraft 2 recipe handlers
    if (ShapedIC2RecipeHandler.recipeClass != null) HANDLERS.put(ShapedIC2RecipeHandler.recipeClass, new ShapedIC2RecipeHandler());
    if (ShapelessIC2RecipeHandler.recipeClass != null) HANDLERS.put(ShapelessIC2RecipeHandler.recipeClass, new ShapelessIC2RecipeHandler());

    // tinker's construct recipe handlers
    if (TinkersRecipeHandlers.TableRecipeHandler.recipeClass != null) HANDLERS.put(TinkersRecipeHandlers.TableRecipeHandler.recipeClass, new TinkersRecipeHandlers.TableRecipeHandler());
}
项目:UncraftingTable    文件:RecipeHandlers.java   
@Override
public NonNullList<ItemStack> getCraftingGrid(IRecipe r)
{
    // cast the IRecipe instance
    ShapedRecipes shapedRecipe = (ShapedRecipes)r;

    // get a copy of the recipe items with normalised metadata
    NonNullList<ItemStack> recipeStacks = copyRecipeStacks(shapedRecipe.recipeItems);

    // get the recipe dimensions
    int recipeWidth = shapedRecipe.recipeWidth;
    int recipeHeight = shapedRecipe.recipeHeight;

    // rearrange the itemstacks according to the recipe width and height
    return reshapeRecipe(recipeStacks, recipeWidth, recipeHeight);
}
项目:TeambattleMod    文件:RecipeUtil.java   
public static ItemStack[] matches(ShapedRecipes re) {
    for (int i = 0; i <= 3 - re.recipeWidth; ++i) {
        for (int j = 0; j <= 3 - re.recipeHeight; ++j) {
            ItemStack[] st = checkMatch(re, i, j, true);
            if (st != null) {
                return st;
            }
            ItemStack[] st2 = checkMatch(re, i, j, false);
            if (st2 != null) {
                return st2;
            }
        }
    }

    return null;
}
项目:TeambattleMod    文件:RecipeUtil.java   
private static ItemStack[] checkMatch(ShapedRecipes re, int p_77573_2_, int p_77573_3_, boolean p_77573_4_) {
    ItemStack[] stacks = new ItemStack[9];

    for (int i = 0; i < 3; ++i) {
        for (int j = 0; j < 3; ++j) {
            int k = i - p_77573_2_;
            int l = j - p_77573_3_;
            ItemStack itemstack = null;

            if (k >= 0 && l >= 0 && k < re.recipeWidth && l < re.recipeHeight) {
                if (p_77573_4_) {
                    itemstack = re.recipeItems[re.recipeWidth - k - 1 + l * re.recipeWidth];
                } else {
                    itemstack = re.recipeItems[k + l * re.recipeWidth];
                }
            }
            stacks[(i + (j * 3))] = itemstack;
        }
    }
    return stacks;
}
项目:TeambattleMod    文件:ClientRegistryUtil.java   
public static void addTeambattleRecipes() {
    ArrayList<CommonGuiRecipe> stacks = new ArrayList<CommonGuiRecipe>();
    List<IRecipe> re = CraftingManager.getInstance().getRecipeList();
    for (IRecipe r : re) {
        if (r.getRecipeOutput() != null && r.getRecipeOutput().getItem() != null && r.getRecipeOutput().getItem().getRegistryName().startsWith(TeambattleReference.modid)) {
            if (r instanceof ShapedRecipes) {
                ShapedRecipes rep = (ShapedRecipes) r;
                stacks.add(new CommonGuiRecipe(RecipeUtil.matches(rep), rep.getRecipeOutput()));
            } else if (r instanceof ShapelessRecipes) {
                List<ItemStack> rs = ((ShapelessRecipes) r).recipeItems;
                ItemStack[] ar = new ItemStack[rs.size()];
                for (int i = 0; i < ar.length; i++) {
                    ar[i] = rs.get(i);
                }
                stacks.add(new CommonGuiRecipe(ar, r.getRecipeOutput()));
            } else {
                continue;
            }
        }
    }
    guirecipes.addAll(stacks);
}
项目:RorysMod    文件:RoryShapedRecipe.java   
RoryShapedRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements) {
    output = recipe.getRecipeOutput();
    width = recipe.recipeWidth;
    height = recipe.recipeHeight;

    input = new Object[recipe.recipeItems.length];

    for (int i = 0; i < input.length; i++) {
        ItemStack ingred = recipe.recipeItems[i];
        if (ingred == null) continue;
        input[i] = recipe.recipeItems[i];
        for (Entry<ItemStack, String> replace : replacements.entrySet()) {
            if (OreDictionary.itemMatches(replace.getKey(), ingred, true)) {
                input[i] = OreDictionary.getOres(replace.getValue());
                break;
            }
        }
    }
}
项目:Factorization    文件:StandardObjectWriters.java   
static void setup() {
    if (is_setup) return;
    is_setup = true;
    reg(ItemStack.class, new WriteItemStack());
    reg(Item.class, new WriteItem());
    reg(Block.class, new WriteBlock());
    reg(String.class, new WriteStringOreDictionary());
    reg(Number.class, new WriteObjectToString());
    reg(NBTBase.class, new WriteObjectToString());
    reg(FluidStack.class, new WriteFluidStack());
    reg(Fluid.class, new WriteFluid());
    reg(Collection.class, new WriteCollection());
    // IRecipe: "embedded IRecipe"; haven't seen it crop up tho
    reg(ShapedOreRecipe.class, new WriteShapedOreRecipe());
    reg(ShapedRecipes.class, new WriteShapedRecipe());
    reg(ShapelessOreRecipe.class, new WriteShapelessOreRecipe());
    reg(ShapelessRecipes.class, new WriteShapelessRecipe());
    reg(Map.Entry.class, new WriteEntry());

    IObjectWriter.adapter.register(new ArrayAdapter());
    IObjectWriter.adapter.setFallbackAdapter(new GenericAdapter<Object, IObjectWriter>(Object.class, new ReflectionWriter()));
}
项目:TaleCraft    文件:GuiWorkbench.java   
@Override
protected void actionPerformed(GuiButton button) throws IOException {
    if(button.id == 0 || button.id == 1){
        boolean empty = true;
        ItemStack[] stacks = new ItemStack[9];
        for(int i = 0; i < container.craftMatrix.getSizeInventory(); i++){
            if(container.craftMatrix.getStackInSlot(i) != null){
                empty = false;
            }
            stacks[i] = container.craftMatrix.getStackInSlot(i);
        }
        if(!empty){
            if(container.getSlot(0).getStack() != null){
                if(button.id == 0){
                    TaleCraft.network.sendToServer(new WorkbenchCraftingPacket(new ShapedRecipes(3, 3, stacks, container.getSlot(0).getStack()), true));
                }else{
                    TaleCraft.network.sendToServer(new WorkbenchCraftingPacket(new ShapedRecipes(3, 3, stacks, container.getSlot(0).getStack()), false));
                }
            }
        }
    }else{
        TaleCraft.network.sendToServer(new WorkbenchCraftingPacket());
    }
}
项目:TaleCraft    文件:WorkbenchManager.java   
private static NBTTagCompound shapedToNBT(ShapedRecipes shaped){
    NBTTagCompound tag = new NBTTagCompound();
    tag.setString("type", "shaped");
    tag.setInteger("width", shaped.recipeWidth);
    tag.setInteger("height", shaped.recipeHeight);
    for(int i = 0; i < 9; i++){
        ItemStack stack = shaped.recipeItems[i];
        NBTTagCompound stackTag = new NBTTagCompound();
        if(stack != null){
            stack.writeToNBT(stackTag);
        }
        tag.setTag("item_" + i, stackTag);
    }
    tag.setTag("output", shaped.getRecipeOutput().writeToNBT(new NBTTagCompound()));
    return tag;
}
项目:TaleCraft    文件:WorkbenchManager.java   
private static ShapedRecipes shapedFromNBT(NBTTagCompound tag){
    int width = tag.getInteger("width");
    int height = tag.getInteger("height");
    ItemStack[] items = new ItemStack[9];
    for(int i = 0; i < 9; i++){
        NBTTagCompound stackTag = tag.getCompoundTag("item_" + i);
        if(stackTag.hasNoTags()){
            items[i] = null;
            continue;
        }else{
            items[i] = new ItemStack(stackTag);
        }
    }
    ItemStack output = new ItemStack(tag.getCompoundTag("output"));
    return new ShapedRecipes(width, height, items, output);
}
项目:NotEnoughItems    文件:ShapedRecipeHandler.java   
@Override
public void loadCraftingRecipes(String outputId, Object... results) {
    if (outputId.equals("crafting") && getClass() == ShapedRecipeHandler.class) {
        for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes) {
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            } else if (irecipe instanceof ShapedOreRecipe) {
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
            }

            if (recipe == null) {
                continue;
            }

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    } else {
        super.loadCraftingRecipes(outputId, results);
    }
}
项目:NotEnoughItems    文件:ShapedRecipeHandler.java   
@Override
public void loadCraftingRecipes(ItemStack result) {
    for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
        if (NEIServerUtils.areStacksSameTypeCrafting(irecipe.getRecipeOutput(), result)) {
            CachedShapedRecipe recipe = null;
            if (irecipe instanceof ShapedRecipes) {
                recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
            } else if (irecipe instanceof ShapedOreRecipe) {
                recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
            }

            if (recipe == null) {
                continue;
            }

            recipe.computeVisuals();
            arecipes.add(recipe);
        }
    }
}
项目:NotEnoughItems    文件:ShapedRecipeHandler.java   
@Override
public void loadUsageRecipes(ItemStack ingredient) {
    for (IRecipe irecipe : CraftingManager.getInstance().getRecipeList()) {
        CachedShapedRecipe recipe = null;
        if (irecipe instanceof ShapedRecipes) {
            recipe = new CachedShapedRecipe((ShapedRecipes) irecipe);
        } else if (irecipe instanceof ShapedOreRecipe) {
            recipe = forgeShapedRecipe((ShapedOreRecipe) irecipe);
        }

        if (recipe == null || !recipe.contains(recipe.ingredients, ingredient.getItem())) {
            continue;
        }

        recipe.computeVisuals();
        if (recipe.contains(recipe.ingredients, ingredient)) {
            recipe.setIngredientPermutation(recipe.ingredients, ingredient);
            arecipes.add(recipe);
        }
    }
}
项目:DMTweaks    文件:RecipeRemover.java   
public static void removeShapedRecipe (ItemStack resultItem)
{
    Preconditions.checkNotNull(resultItem);
    List<IRecipe> recipes = CraftingManager.getInstance().getRecipeList();
    for (int i = 0; i < recipes.size(); i++)
    {
        IRecipe tmpRecipe = recipes.get(i);
        if (tmpRecipe instanceof ShapedRecipes)
        {
            ShapedRecipes recipe = (ShapedRecipes) tmpRecipe;
            ItemStack recipeResult = recipe.getRecipeOutput();

            if (ItemStack.areItemStacksEqual(resultItem, recipeResult))
            {
                recipes.remove(i--);
            }
        }
    }
}
项目:TFC2    文件:RecipeSorterTFC.java   
public int compareRecipes(IRecipe irecipe, IRecipe irecipe1)
{
    if (irecipe instanceof ShapelessRecipes && irecipe1 instanceof ShapedRecipes)
    {
        return 1;
    }
    if (irecipe1 instanceof ShapelessRecipes && irecipe instanceof ShapedRecipes)
    {
        return -1;
    }
    if (irecipe1.getRecipeSize() < irecipe.getRecipeSize())
    {
        return -1;
    }
    return irecipe1.getRecipeSize() <= irecipe.getRecipeSize() ? 0 : 1;
}
项目:TFC2    文件:ShapedOreRecipeTFC.java   
ShapedOreRecipeTFC(ShapedRecipes recipe, Map<ItemStack, String> replacements)
{
    output = recipe.getRecipeOutput();
    width = recipe.recipeWidth;
    height = recipe.recipeHeight;

    input = new ArrayList<Object>(recipe.recipeItems.length);

    for(int i = 0; i < recipe.recipeItems.length; i++)
    {
        ItemStack ingredient = recipe.recipeItems[i];

        if(ingredient == null) continue;

        input.add(recipe.recipeItems[i]);

        for(Entry<ItemStack, String> replace : replacements.entrySet())
        {
            if(OreDictionary.itemMatches(replace.getKey(), ingredient, true))
            {
                input.set(i, OreDictionary.getOres(replace.getValue()));
                break;
            }
        }
    }
}
项目:CauldronGit    文件:ShapedOreRecipe.java   
ShapedOreRecipe(ShapedRecipes recipe, Map<ItemStack, String> replacements)
{
    output = recipe.getRecipeOutput();
    width = recipe.recipeWidth;
    height = recipe.recipeHeight;

    input = new Object[recipe.recipeItems.length];

    for(int i = 0; i < input.length; i++)
    {
        ItemStack ingred = recipe.recipeItems[i];

        if(ingred == null) continue;

        input[i] = recipe.recipeItems[i];

        for(Entry<ItemStack, String> replace : replacements.entrySet())
        {
            if(OreDictionary.itemMatches(replace.getKey(), ingred, true))
            {
                input[i] = OreDictionary.getOres(replace.getValue());
                break;
            }
        }
    }
}
项目:AetherCraft2    文件:ShapedCraftingHandler.java   
@Override
public List<RecipeLink> getRecipes() {
    List<RecipeLink> a = new ArrayList<RecipeLink>();

    for (Object obj : RecipeRegistry.vanillaCrafting.get(ShapedRecipes.class)) {
        ShapedRecipes recipe = (ShapedRecipes) obj;
        RecipeLink link = new RecipeLink();

        for (ItemStack stack : recipe.recipeItems) {
            if (stack!=null) {
                link.inputs.add(new ItemDataStack(stack));
            }
        }

        link.outputs.add(new ItemDataStack(recipe.getRecipeOutput()));

        a.add(link);
    }

    return a;
}
项目:TFCWaterCompatibility    文件:RecipeSorterTFC.java   
public int compareRecipes(IRecipe irecipe, IRecipe irecipe1)
{
    if (irecipe instanceof ShapelessRecipes && irecipe1 instanceof ShapedRecipes)
    {
        return 1;
    }
    if (irecipe1 instanceof ShapelessRecipes && irecipe instanceof ShapedRecipes)
    {
        return -1;
    }
    if (irecipe1.getRecipeSize() < irecipe.getRecipeSize())
    {
        return -1;
    }
    return irecipe1.getRecipeSize() <= irecipe.getRecipeSize() ? 0 : 1;
}
项目:Skills    文件:SK_FishingRod.java   
private static void removeVanillaRecipe()
{
    Iterator craftingList = CraftingManager.getInstance().getRecipeList().iterator();
    int index = 0;
    while(craftingList.hasNext())
    {
        Object recipe = craftingList.next();

        if(recipe instanceof ShapedRecipes)
        {
            ShapedRecipes shapedRecipe = (ShapedRecipes)recipe;

            if(shapedRecipe.getRecipeOutput().getItem() == Items.fishing_rod)
            {
                //shapedRecipe.getRecipeOutput().setItem(fishingrod);
                CraftingManager.getInstance().getRecipeList().remove(index);
                break;
            }


        }
        index++;
    }


}