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 am making a mod that requires you to craft a pocket knife.  When you use the pocket knife in crafting recipes, it takes damage.  I have the code done for it to take damage, but the game will not let me craft the specified item if the pocket knife has taken damage.

 

Item Class:

 

 

package mods.GreatOutdoors.client.core;

import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;

import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.EnumRarity;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class PocketKnife extends Item
{
    public PocketKnife(int par1)
    {
        super(par1);
        this.setHasSubtypes(false);
        this.setMaxDamage(50);
        this.setCreativeTab(CreativeTabs.tabMaterials);
    }

    @SideOnly(Side.CLIENT) 
    @Override 
    public void updateIcons(IconRegister iconRegister) 
    { 
    iconIndex = iconRegister.registerIcon("GreatOutdoors:pocketKnife"); 
    }
}

 

 

 

 

Crafting Handler:

 

 

package mods.GreatOutdoors.client.core;

import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.ICraftingHandler;

public class GreatOutdoorsCraftingHandler implements ICraftingHandler {

@Override
public void onCrafting(EntityPlayer player, ItemStack item, IInventory craftMatrix)
{
	for(int i = 0; i < craftMatrix.getSizeInventory();i++)
	{
		if(craftMatrix.getStackInSlot(i) != null)
		{
			ItemStack j = craftMatrix.getStackInSlot(i);

			if(j.getItem() != null && j.getItem() == GreatOutdoors_Main.PocketKnife)
			{
				ItemStack k = new ItemStack(GreatOutdoors_Main.PocketKnife, 2, (j.getItemDamage()+1));

				if(k.getItemDamage() >= k.getMaxDamage())
				{
					k.stackSize--;
				}

				craftMatrix.setInventorySlotContents(i, k);
			}
		}
	}
}

@Override
public void onSmelting(EntityPlayer player, ItemStack item) 
{

}

}

 

 

 

 

Crafting Recipes:

 

 

GameRegistry.addShapelessRecipe(new ItemStack(Bark),new ItemStack(Block.wood,1,0),new ItemStack(GreatOutdoors_Main.PocketKnife,1,-1));

 

 

 

 

Is there any code I need to add to any of these to allow the bark to be crafted even if the pocket knife has a damage value?  Thanks in advance!

Mojang changed in 1.5 value of "any damage" in recipes. Use "OreDictionary.WILDCARD_VALUE" instead of "-1" and you should fine ;).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

Mojang changed in 1.5 value of "any damage" in recipes. Use "OreDictionary.WILDCARD_VALUE" instead of "-1" and you should fine ;).

mnn.getNativeLang() != English

If I helped you please click on the "thank you" button.

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.