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

I really need to know a working (and tested, too) way to code it so when you craft with an item, it takes damage for each use until it finally runs out of durability and gets destroyed. I am working on a mod for my modpack and I have searched through a ridiculous amount of pages explaining how to do it with no success. I managed to get it to take 1 damage when crafted with but after you craft with it once, its done. You can't craft with it anymore and you are left with a slightly damaged item. I understand you use a crafting handler but I can't seem to get it to work any better then what I just explained. Can somebody out there please just take some time and explain to me exactly how to get this to work with minecraft version 1.6.2?  If you could, I'd also like to know how to do the same thing, only instead of taking damage it just has infinite uses. I tried setting the metadata value in the crafting recipes to -1 but that had no effect.

 

An example of this is Equivalent Exchange 3 and Pam's Harvestcraft. In EE3, if you craft with a minium stone, for every time you use it it takes a damage then destroys itself when it's out of durability, just like a tool such as a pickaxe does when it's out of uses. I need to get this same thing to happen with 2 of my mod items.

 

In Pam's Harvestcraft, the cooking utensils such as the juicer or the cutting board have infinite uses in crafting. For example, if you need to use the juicer for some jelly, you put it next to the fruit of choice in the crafting table and when you click on the final product to craft it, the juicer stays while the fruit is consumed. I want this exact thing to happen for a few of my mod items.

 

If you need any more information on my coding/mod please let me know and Il be happy to post it to you.

I am not looking for a reply that leads me to another post unless it has been tested and proven to work with MC 1.6.2, so if you are going to reply with a link to a tutorial or something like that, please make sure that you KNOW it works.

The mod EE3 is open source and has an item that does this called the Minium Stone, I would check that out! All his code is really readable too, so it should be quite easy to track down how he did that!

Creator of Metroid Cubed! Power Suits, Beams, Hypermode and more!

width=174 height=100http://i.imgur.com/ghgWmA3.jpg[/img]

Hi

 

I don't have any working code, so if that's a problem you should stop reading now :-P

 

I think I might be able to help you get one step further what what you've figured out already-

ShapedRecipes:

.checkMatch()

and in particular

                if (itemstack1 != null || itemstack != null)
                {
                    if (itemstack1 == null && itemstack != null || itemstack1 != null && itemstack == null)
                    {
                        return false;
                    }

                    if (itemstack.itemID != itemstack1.itemID)
                    {
                        return false;
                    }

                    if (itemstack.getItemDamage() != 32767 && itemstack.getItemDamage() != itemstack1.getItemDamage())
                    {
                        return false;
                    }
                }

This is probably the reason that your item stops crafting when it's been damaged.

Luckily it looks like you can create your own MyRecipe implements IRecipe to change the matching to whatever you want (i.e. ignoring damage).

Alternatively, if you put your Item in the Recipe as an ItemStack with damage of 32767, I think it will match regardless of the damage of the tool.

 

-TGG

 

 

  • Author

Thanks for the suggestions so far but I have no success :( either that or im entering in your code into the wrong place/replacing the wrong parts

Hi

 

Hmm that's a bummer

 

What I mean is for example

 

ItemStack dirtStack = new ItemStack(Block.dirt);
ItemStack matchAnyDamageValueItemStack = new ItemStack(MyItem, 1, 32767);

GameRegistry.addRecipe(new ItemStack(Block.cobblestone), "xy", "yx", 
                                    'x', dirtStack, 'y', matchAnyDamageValueItemStack);

 

That way the recipe should match your item regardless of its damage value.  (You said you've already figured out how to damage the item by 1 every time it is crafted with?)

 

-TGG

 

Hi

 

Hmm that's a bummer

 

What I mean is for example

 

ItemStack dirtStack = new ItemStack(Block.dirt);
ItemStack matchAnyDamageValueItemStack = new ItemStack(MyItem, 1, 32767);

GameRegistry.addRecipe(new ItemStack(Block.cobblestone), "xy", "yx", 
                                    'x', dirtStack, 'y', matchAnyDamageValueItemStack);

 

That way the recipe should match your item regardless of its damage value.  (You said you've already figured out how to damage the item by 1 every time it is crafted with?)

 

-TGG

 

Here use this

ItemStack dirtStack = new ItemStack(Block.dirt);
ItemStack matchAnyDamageValueItemStack = new ItemStack(MyItem, 1, WILDCARD_VALUE);

GameRegistry.addRecipe(new ItemStack(Block.cobblestone), "xy", "yx", 
                                    'x', dirtStack, 'y', matchAnyDamageValueItemStack);

 

and put this somewhere too

public static final int WILDCARD_VALUE = Short.MAX_VALUE;

I'd complete ThePocketSoul answer with

OreDictionary.WILD_CARD_VALUE

let Forge handle that for you :)

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.