Jump to content

How to make a crafting-recipe WITH Item, you won't loose


Recommended Posts

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!

Posted

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.

Posted

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • I tried do download the essential mod to my mod pack but i didnt work. I paly on 1.21 and it should work. I use neoforge for my modding. The weird things is my friend somehow added the mod to his modpack and many others that I somehow can´t. Is there anything i can do? 
    • Thanks, I've now installed a slightly newer version and the server is at least starting up now.
    • i have the same issue. Found 1 Create mod class dependency(ies) in createdeco-1.3.3-1.19.2.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Found 11 Create mod class dependency(ies) in createaddition-fabric+1.19.2-20230723a.jar, which are missing from the current create-1.19.2-0.5.1.i.jar Detailed walkthrough of mods which rely on missing Create mod classes: Mod: createaddition-fabric+1.19.2-20230723a.jar Missing classes of create: com/simibubi/create/compat/jei/category/sequencedAssembly/JeiSequencedAssemblySubCategory com/simibubi/create/compat/recipeViewerCommon/SequencedAssemblySubCategoryType com/simibubi/create/compat/rei/CreateREI com/simibubi/create/compat/rei/EmptyBackground com/simibubi/create/compat/rei/ItemIcon com/simibubi/create/compat/rei/category/CreateRecipeCategory com/simibubi/create/compat/rei/category/WidgetUtil com/simibubi/create/compat/rei/category/animations/AnimatedBlazeBurner com/simibubi/create/compat/rei/category/animations/AnimatedKinetics com/simibubi/create/compat/rei/category/sequencedAssembly/ReiSequencedAssemblySubCategory com/simibubi/create/compat/rei/display/CreateDisplay Mod: createdeco-1.3.3-1.19.2.jar Missing classes of create: com/simibubi/create/content/kinetics/fan/SplashingRecipe
    • The crash points to moonlight lib - try other builds or make a test without this mod and the mods requiring it
    • Do you have shaders enabled? There is an issue with the mod simpleclouds - remove this mod or disable shaders, if enabled  
  • Topics

  • Who's Online (See full list)

    • There are no registered users currently online
×
×
  • Create New...

Important Information

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