Jump to content

Recommended Posts

Posted

Hello guys i've a problem with 1.5 coding. Some time ago, i made a simple mod that able you to "repair " damaged items, look at this piece of code:

 

GameRegistry.addRecipe(new ItemStack(Item.swordWood), new Object[] {" Y ", " X ", "  ", 'X', new ItemStack(Item.swordWood, 1, -1), 'Y', Block.planks});

 

Well, with this code you can craft one brand new wooden sword with one damaged wooden sword and whatever block of planks, this works well in 1.4.7, but not in 1.5.1.

 

Anybody can help me please.

 

Thanks.

Posted

Hello there,

  I would like to first say that I am by no means what you could even call a moder as I have a million questions my self.

 

  I decided to try and solve this issue, and at my level, I found that it is not quite as easy as what you had shown.

 

This is the code that would be put in the @Init part of your main class.

 

GameRegistry.addRecipe(new ItemStack(Item.swordWood, 1), 
    new Object[]
        {
            "XYX",
            'X', Block.planks, 'Y', new Item.swordWood
        });

 

However, the problem with this is that it does not accept a damaged item.  While I have some suspicions as to ways you could go about this, I lack the experience with the base classes and forge classes to figure it out yet.

 

On a positive note, I believe that you can use an Anvil to do the same thing that you are trying to make a recipe for.

 

With a quick google search: [lmgtfy]minecraft anvil[/lmgtfy], I was able to come up with the following results.

 

http://www.minecraftwiki.net/wiki/Anvil

 

http://www.minecraftwiki.net/wiki/Anvil_mechanics

 

On a final thought, you may be able to make a modified crafting table, with functionality of the anvil.

 

Good luck to you.

Posted

xD. I made whole Mod which is makeing a lots of repair/damage recipes.

I used Forloops for this.

 

like this:

for(int i = 0; i < yourItem.getMaxItemDamage(); i++)
{
      GameRegistry.addRecipe(new ItemStack(yourItem, 1, i - extradamage), new Object [] {"XY", 'X', new ItemStack(yourItem, 1, i), 'Y', new ItemStack(repairItem, 1, 0)});
}

and the forloops was about 10k. And it was about 2,5mio recipes. and the game starts to lag.

  • 2 weeks later...
Posted

Thanks to all the code that for now works for me is

 

    public static final int WILDCARD_VALUE = Short.MAX_VALUE;

 

then

 

GameRegistry.addShapelessRecipe(new ItemStack(Item.swordIron), new ItemStack(Item.swordIron, 1, WILDCARD_VALUE), Item.ingotIron);

Posted

I also have a hint for you. never make too much forloops!

 

Why. I made with forloops about 2 Mio recipes.

 

and then after coding i tried to craft a workbench and the framerate goes down to 6 everytime i put a Item/Block in the craftingmatrix!

 

This lagging starts at 100k recipes! (Tested!)

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



×
×
  • Create New...

Important Information

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