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

Hi, this is probalby rather basic :

GameRegistry.addShapelessRecipe(new ItemStack(CommonProxy.largeGoldCoin,1), new ItemStack(CommonProxy.goldCoin,10));

My intention is to make a recipe that will turn 10 normal coins into one large, but when I test it, it only "eats" one normal coin for each large given. What am I doing wrong ? Is it even possible this way or do I need to handle this stuff differently ?

Ordinary shapeless recipes don't examine the item stack size, only the item reference, because it would cause problems with mass crafting otherwise.

 

You may require a new recipe class to accomplish this coin changing thing.

  • Author

as far as I understand what I see there are no classes for recipes, the behaviour is hardcoded into CraftingManager, so I guess I'd either convert them into 9's or do some "magic" with them.

You have to make a new implementation of

IRecipe

. Then you have to register your recipe class with

GameRegistry.registerRecipe(new YourRecipe())

.

Don't PM me with questions. They will be ignored! Make a thread on the appropriate board for support.

 

1.12 -> 1.13 primer by williewillus.

 

1.7.10 and older versions of Minecraft are no longer supported due to it's age! Update to the latest version for support.

 

http://www.howoldisminecraft1710.today/

  • Author

I figured I could do 5 coins, but that would be a pain the butt of each player, and my own, so I'd try the IRecipe then

  • Author

Where can I change how are inputs processed after crafting ? They are only decremented by amount of 1, no matter what I change.

 

My current code (sloppy, I know) :

public class MultipleInputRecipe implements IRecipe
{
    /** Is the ItemStack that you get when craft the recipe. */
    private final ItemStack recipeOutput;
    
public final Item recipeInput;

private int multiplier;

    public MultipleInputRecipe(ItemStack outputStack, Item item, int multi)
    {
        this.recipeOutput = outputStack;
        this.recipeInput = item;
        this.multiplier = multi;
    }

    public ItemStack getRecipeOutput()
    {
        return this.recipeOutput;
    }

    public ItemStack[] func_179532_b(InventoryCrafting inventory)
    {System.out.println("fired!");
        ItemStack[] aitemstack = new ItemStack[inventory.getSizeInventory()];

        return aitemstack;
    }

    /**
     * Used to check if a recipe matches current crafting inventory
     */
    public boolean matches(InventoryCrafting inventory, World worldIn)
    {
        int amount = 0;
        for (int i = 0; i < inventory.func_174923_h(); ++i)
        {
            for (int j = 0; j < inventory.func_174922_i(); ++j)
            {
                ItemStack itemstack = inventory.getStackInRowAndColumn(j, i);

                if (itemstack != null)
                {
                    if(itemstack.getItem() instanceof SilverCoin && this.recipeInput instanceof SilverCoin)amount+=itemstack.stackSize;
                    if(itemstack.getItem() instanceof GoldCoin && this.recipeInput instanceof GoldCoin)amount+=itemstack.stackSize;
                    if(itemstack.getItem() instanceof LargeGoldCoin && this.recipeInput instanceof LargeGoldCoin)amount+=itemstack.stackSize;
                }
            }
        }
        
        if(amount>=this.multiplier)return true;
        return false;
    }

    /**
     * Returns an Item that is the result of this recipe
     */
    public ItemStack getCraftingResult(InventoryCrafting p_77572_1_)
    {
        return this.recipeOutput.copy();
    }

    /**
     * Returns the size of the recipe area
     */
    public int getRecipeSize()
    {
        return 2;
    }
}

In 1.8, IRecipe conveniently provides

ItemStack[] getRemainingItems(InventoryCrafting p_179532_1_);

to do exactly this.

In 1.7.10 I think you might have to do something clever with

ItemCraftedEvent  (i.e. modify the crafting matrix to remove "extra" itemstacks).

 

See SlotCrafting.onPickupFromSlot() for the vanilla code where it all happens.  Never tried it myself, it may not work...

 

-TGG

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.