Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

Hello people

I am working on a mod and it adds a new crafting table with its own recipes and it works, but the output slot doesnt show the item the recipe is resulting, even though if you click on the slot with no items, it crafts the item like it should.

I have tried a lot of changes on the code and it still doesnt show the right output, anyone has an ideia of what is happening?

 

Crafting Manager

 

package torresmon235.crystalgun.crafting;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;

import net.minecraft.block.Block;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.item.crafting.ShapedRecipes;
import net.minecraft.item.crafting.ShapelessRecipes;
import net.minecraft.world.World;
import torresmon235.crystalgun.common.CrystalGunMain;

public class AlchemyManager
{
    /** The static instance of this class */
    private static final AlchemyManager instance = new AlchemyManager();

    /** A list of all the recipes added */
    private List recipes = new ArrayList();

    /**
     * Returns the static instance of this class
     */
    public static final AlchemyManager getInstance()
    {
        return instance;
    }

    private AlchemyManager()
    {
        this.addRecipe(new ItemStack(CrystalGunMain.PoisonCrystal, 3), new Object[] {"F", "W", "F", 'F', CrystalGunMain.FireCrystal, 'W', CrystalGunMain.WaterCrystal});
        this.addRecipe(new ItemStack(CrystalGunMain.PoisonCrystal, 2), new Object[] {"G", "F", 'F', CrystalGunMain.FireCrystal, 'G', CrystalGunMain.GrassCrystal});
        this.addRecipe(new ItemStack(CrystalGunMain.GrassCrystal, 2), new Object[] {"F", "W", 'F', CrystalGunMain.FireCrystal, 'W', CrystalGunMain.WaterCrystal});
        this.addRecipe(new ItemStack(CrystalGunMain.IceCrystal, 2), new Object[] {"A", "W", 'A', CrystalGunMain.AirCrystal, 'W', CrystalGunMain.WaterCrystal});
        this.addRecipe(new ItemStack(CrystalGunMain.SandCrystal, 2), new Object[] {"F", "A", 'F', CrystalGunMain.FireCrystal, 'A', CrystalGunMain.AirCrystal});
        this.addRecipe(new ItemStack(CrystalGunMain.LifeCrystal, 6), new Object[] {"FWA", "PPP", "GIS", 'F', CrystalGunMain.FireCrystal, 'W', CrystalGunMain.WaterCrystal, 'A', CrystalGunMain.AirCrystal, 'G', CrystalGunMain.GrassCrystal, 'I', CrystalGunMain.IceCrystal, 'S', CrystalGunMain.SandCrystal, 'P', Item.gunpowder});
        System.out.println(this.recipes.size() + " Achemy Recipes");
    }

    void addRecipe(ItemStack itemstack, Object ... inputArray)
    {
             String var3 = "";
             int var4 = 0;
             int var5 = 0;
             int var6 = 0;
             int var9;
             if (inputArray[var4] instanceof String[])
             {
                     String[] var7 = (String[])((String[])inputArray[var4++]);
                     String[] var8 = var7;
                     var9 = var7.length;
                     for (int var10 = 0; var10 < var9; ++var10)
                     {
                             String var11 = var8[var10];
                             ++var6;
                             var5 = var11.length();
                             var3 = var3 + var11;
                     }
             }
             else
             {
                     while (inputArray[var4] instanceof String)
                     {
                             String var13 = (String)inputArray[var4++];
                             ++var6;
                             var5 = var13.length();
                             var3 = var3 + var13;
                     }
             }
             HashMap var14;
             for (var14 = new HashMap(); var4 < inputArray.length; var4 += 2)
             {
                     Character var16 = (Character)inputArray[var4];
                     ItemStack var17 = null;
                     if (inputArray[var4 + 1] instanceof Item)
                     {
                             var17 = new ItemStack((Item)inputArray[var4 + 1]);
                     }
                     else if (inputArray[var4 + 1] instanceof Block)
                     {
                             var17 = new ItemStack((Block)inputArray[var4 + 1], 1, -1);
                     }
                     else if (inputArray[var4 + 1] instanceof ItemStack)
                     {
                             var17 = (ItemStack)inputArray[var4 + 1];
                     }
                     var14.put(var16, var17);
             }
             ItemStack[] var15 = new ItemStack[var5 * var6];
             for (var9 = 0; var9 < var5 * var6; ++var9)
             {
                     char var18 = var3.charAt(var9);
                     if (var14.containsKey(Character.valueOf(var18)))
                     {
                             var15[var9] = ((ItemStack)var14.get(Character.valueOf(var18))).copy();
                     }
                     else
                     {
                             var15[var9] = null;
                     }
             }
             this.recipes.add(new ShapedRecipes(var5, var6, var15, itemstack));
    }
    
    void addShapelessRecipe(ItemStack itemstack, Object ... inputArray)
    {
             ArrayList var3 = new ArrayList();
             Object[] var4 = inputArray;
             int var5 = inputArray.length;
             for (int var6 = 0; var6 < var5; ++var6)
             {
                     Object var7 = var4[var6];
                     if (var7 instanceof ItemStack)
                     {
                             var3.add(((ItemStack)var7).copy());
                     }
                     else if (var7 instanceof Item)
                     {
                             var3.add(new ItemStack((Item)var7));
                     }
                     else
                     {
                             if (!(var7 instanceof Block))
                             {
                                     throw new RuntimeException("Invalid shapeless recipy!");
                             }
                             var3.add(new ItemStack((Block)var7));
                     }
             }
             this.recipes.add(new ShapelessRecipes(itemstack, var3));
    }

    public ItemStack findMatchingRecipe(InventoryCrafting par1InventoryCrafting, World par2World)
    {
        int var3 = 0;
        ItemStack var4 = null;
        ItemStack var5 = null;
        int var6;

        for (var6 = 0; var6 < par1InventoryCrafting.getSizeInventory(); ++var6)
        {
            ItemStack var7 = par1InventoryCrafting.getStackInSlot(var6);

            if (var7 != null)
            {
                if (var3 == 0)
                {
                    var4 = var7;
                }

                if (var3 == 1)
                {
                    var5 = var7;
                }

                ++var3;
            }
        }

        if (var3 == 2 && var4.itemID == var5.itemID && var4.stackSize == 1 && var5.stackSize == 1 && Item.itemsList[var4.itemID].isRepairable())
        {
            Item var11 = Item.itemsList[var4.itemID];
            int var13 = var11.getMaxDamage() - var4.getItemDamageForDisplay();
            int var8 = var11.getMaxDamage() - var5.getItemDamageForDisplay();
            int var9 = var13 + var8 + var11.getMaxDamage() * 5 / 100;
            int var10 = var11.getMaxDamage() - var9;

            if (var10 < 0)
            {
                var10 = 0;
            }

            return new ItemStack(var4.itemID, 1, var10);
        }
        else
        {
            for (var6 = 0; var6 < this.recipes.size(); ++var6)
            {
                IRecipe var12 = (IRecipe)this.recipes.get(var6);

                if (var12.matches(par1InventoryCrafting, par2World))
                {
                    return var12.getCraftingResult(par1InventoryCrafting);
                }
            }

            return null;
        }
    }

    /**
     * returns the List<> of all recipes
     */
    public List getRecipeList()
    {
        return this.recipes;
    }
}

 

  • Author

After some testing, it seems like the output shows icons for the normal crafting table recipes, if i try to make a fence, it shows on the output but it wont let me grab the fences. And if i try a recipe from the custom table the icon wont show up, but if i try to grab it will craft the item.

I have been looking for the code that shows the output icon, but with no luck, anyone knows where can i find and change it?

I got the same problem.

When I want to take out the item that I set in that slot then it reset back to what it was before :(

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.