Jump to content

[1.7.2] Add Recipes to Special Guis!


Kloonder

Recommended Posts

Hey,

does someone know how i can add Recipes to this gui?

width=256 height=256https://lh6.googleusercontent.com/-ArTaN4mTbTI/U4ibdv02K4I/AAAAAAAAAKE/gdIqT0WI_9E/s256-no/blockmixergui.png[/img]

I made this gui by my own and everything is working fine. I can put items into the slot and all these things a gui has to do. But i dont know how to add recipes. If you know any tutorial for this or you know it, please send it to me.

 

Thanks  ;)

Creator of Extra Shoes

 

Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then

Link to comment
Share on other sites

Okay, this may or may not be a long post :P This took me hours of figuring out, so I hope this helps :)

 

Now, in your TileEntity class(I hope you have one :P) you should have a line something like this(if you don't make one, say if you want the full method code :)) :

ItemStack itemstack = BlenderRecipies.getSmeltingResult(ITEMSTACKNAME[0].getItem().itemID, ITEMSTACKNAME[1].getItem().itemID);

 

Now, change the varibles to your coresponding varibles.

Now, you have to fiddle around with that line of code. Pretty self-explanatory, but add

ITEMSTACKNAME[0].getItem().itemID

as many times as slots you have in your gui(input), but change the array. For instance, your third one would be

ITEMSTACKNAME[2].getItem().itemID

, and so on. Bear in mind the code I pasted is for a two slot input.

You don't want the BlenderRecipies part, so make your own class called whatever you like(I'd recommend something like BLOCKNAMERecipies)  And paste this code inside the class:

public CLASSNAME()
    {
    }
    public static ItemStack getSmeltingResult(int i, int j, int k, int l, int m)
    {
        return getOutput(i, j, k, l, m);
    }
    private static ItemStack getOutput(int i, int j, int k, int l, int m)
    {
}

Now inside getOutput, you'll want a bunch of if statments(I guess you could do a for loop, but if statments are a lot easier) for your Recipies.

 

I'm not going to explain how it works, it's extremely easy to see what it does just by looking at it.

 

Here is an example:

if(i == MainModdingFile.ITEMNAME.itemID && j == MainModdingFile.ITEMNAME.itemID && k == MainModdingFile.ITEMNAME.itemID && l == MainModdingFile.ITEMNAME.itemID && m == MainModdingFile.ITEMNAME.itemID{
            return new ItemStack(MainModdingFile.ITEMNAME);
        }

Bear in mind, that this only works if the items are in a particular order, if you want a "shapeless recipie" as it could be called, you can use || (OR in boolean) to do that.

 

Here are two examples, one of a basic recipe, and one for a shapeless recipe.

 

BASIC:

if(i == morefoodmod.ItemBanana.itemID && j == morefoodmod.ItemStrawberry.itemID){
            return new ItemStack(morefoodmod.ItemStrawberryBananaSmoothie);
        }

SHAPELESS:

if(i == morefoodmod.ItemBanana.itemID && j == morefoodmod.ItemStrawberry.itemID || i == morefoodmod.ItemStrawberry.itemID && j == morefoodmod.ItemBanana.itemID){
            return new ItemStack(morefoodmod.ItemStrawberryBananaSmoothie);
        }

I hope this helps a bit :)

 

 

Link to comment
Share on other sites

@Xcox123,

 

That code is completely worthless code for a cut&paster working on a 1.7.2 mod. Please, try not to confuse people with worthless or incorrect gratutitous code.

Link to comment
Share on other sites

@sequituri,

 

In what way is it worthless? He asked for a tutorial. Admitidly, I didn't explain everything, but it's not too hard to figure out. I did specificly say that the code was 1.6.4, and that there was going to be errors. But I'm the only person here who bothered to help. However, with a bit of modifying on their side, it can work. So, my post was in no way "worthless and incorrect", it showed him/her the basic way to add a recipie for a special GUI, and thats what I did. He/her didn't ask for any big explanations on anything.

Link to comment
Share on other sites

You might as well tell him to look at minecraft crafting recipe manager.

That is the type of code one could use.

 

sequituri was probably talking about your CLASSNAME "example". It doesn't contain any valuable code nor information. That kind of stuff :

public class TheUltimateAnswer{
   public static Object getSolution(Object allHumankindProblems){
        //TODO: Think of something
        return 42;
   }
}

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

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