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

Hey Guys,

first I want to say sorry, because my english maybe can be bad, it's school english...

So my question is, how can I define a crafting recipe, with some factors, wich won't be away after crafting and stay at there slot?

Maybe someone knows Equivalent Exchange, there are many crafting-recipes with the philosophers stone and the stone stays in the slot, even if I've crafted something...So I don't consume it...

My Code:

Relevant parts of the mod_***

//...
public static Block vaporizer;
public static BlockFlower aloeVera;
public static Item aloeVeraAloin;
//...
vaporizer = (new BlockVaporizer(539, 0)) .setBlockName("vaporizer");
	LanguageRegistry.addName(vaporizer, "Vaporizer");
	GameRegistry.registerBlock(vaporizer);
aloeVera = (BlockFlower) new BlockAloeVera(540,0).setBlockName("aloeVera");
	LanguageRegistry.addName(aloeVera, "Aloe Vera");
	GameRegistry.registerBlock(aloeVera);

aloeVeraAloin = (new ItemFoodAloeVeraAloin(904)).setIconIndex(4).setItemName("aloeVeraAloin");
	LanguageRegistry.addName(aloeVeraAloin, "Aloin");
	GameRegistry.addRecipe(new ItemStack(aloeVeraAloin,1), new Object[]{"A", "V", 'A', mod_eltersmiasmata.aloeVera, 'V', mod_eltersmiasmata.vaporizer});
//...

Ok I want, that you can craft aloeVeraAloin with AloeVera and a vaporizer, the AloeVeraPlant is consumed after crafting but the vaporizer is still there...

 

Hope you can help me!

Greetings!

Its a container Item

 

look in the Item.java an search for the item bucketLava

 

there is setContainerItem(item) and there comes the item

 

public static Item test = new Item(111).setContainerItem(test).setItemName("test");

 

and now when you craft an item with this item look here:

 

ModLoader.addRecipe(new ItemStack(Item.diamond, 1), new Object[]{"XY", 'X', Item.test, 'Y', Block.dirt});

 

with this recipe the Dirt will consumed but the test item will be still there. I hope it help.

I have a note on this.... ok here it is,

 

Now I haven't tested it myself but I found it here a while back.

 

You need a Crafting Handler class, and you need to register it in your main mod class with:

 

GameRegistry.registerCraftingHandler(new Your Crafting Handler());

 

 

And then inside the crafting handler, which implements ICraftingHandler, your onCrafting method should look a little something like this.

public void onCrafting(EntityPlayer player, ItemStack item, IInventory inv) 
{
    for(int i=0; i < inv.getSizeInventory(); i++)
    {
        if(inv.getStackInSlot(i) != null)
        {
            ItemStack j = inv.getStackInSlot(i);
            if(j.getItem() != null && j.getItem() == Your Item)
            {
                ItemStack k = new ItemStack(Your Item, 2, (j.getItemDamage() + 1));
                inv.setInventorySlotContents(i, k);
            }
        }
    }
}

 

Basically what this does, is run a check every time something is crafted. It looks in every slot and if it finds Your Item, it replaces that stack with a new stack of 2 of your item, one of which is used up in the crafting. It also adds one damage to the item.

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.