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.

[1.7.10] [SOLVED] How do i add durable items to my crafting recipes???

Featured Replies

  • Author

IronFile Class:

package com.hardwareplus.items;

import net.minecraft.client.renderer.texture.IIconRegister;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import com.hardwareplus.creativetabs.MCreativeTabs;
import com.hardwareplus.lib.RefStrings;
import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;

public class IronFile extends Item{

public static void mainRegistry(){
	initializeItem();
	registerItem();
}

public static Item iFile;

    public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) {
        return false;
    }
    
    public boolean hasContainerItem() {
    	return true;
    }
    
    public ItemStack getContainerItem(ItemStack itemStack) {
    	itemStack.attemptDamageItem(1, itemRand);
    	
    	return itemStack;
    }


public static void initializeItem(){
	iFile = new Item().setUnlocalizedName("iFile").setMaxDamage(64).setMaxStackSize(1).setNoRepair().setCreativeTab(MCreativeTabs.tabItems).setTextureName(RefStrings.MODID + ":IFile");

}


public static void registerItem(){
	GameRegistry.registerItem(iFile, iFile.getUnlocalizedName());

}

}

 

CraftingManager class:

package com.hardwareplus.Main;

import net.minecraft.item.ItemStack;
import net.minecraftforge.oredict.OreDictionary;

import com.hardwareplus.items.IronFile;
import com.hardwareplus.items.IronPlate;
import com.hardwareplus.items.IronRod;

import cpw.mods.fml.common.registry.GameRegistry;

public class CraftingManager {
public static void mainRegistry(){
	addCraftingRec();
	addSmeltingRec();
}
public static void addCraftingRec(){
	//Iron File
	GameRegistry.addRecipe(new ItemStack(IronFile.iFile, 1), new Object[]{"  P"," P ","R  ", 'P', IronPlate.iPlate, 'R', IronRod.iRod});
	//Iron Rod
	GameRegistry.addShapelessRecipe(new ItemStack(IronRod.iRod, 4), new ItemStack(IronPlate.iPlate), new ItemStack(IronFile.iFile, 1));

}
public static void addSmeltingRec(){

}
}

 

I don't get whats wrong

Ok, seriously you need to learn how to program Minecraft mods. Why do you initialize your item in your item class? You have to initialize it under the preInit in your main mod file. Please watch some Minecraft Modding tutorials before posting problems like this.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

I did.....MChewy....guess he is wrong

 

Item myItem = new Item().setUnlocalizedName("mymod:myitem");

does not equal

Item myItem = new MyItem();

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Draco is right, I didn't even notice it but, you have to set your item equal to the class for the item or anything in that class won't be called. You can't just make a class for an item and not initialize your item variable with it.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Just redo your setup with a video from MrCrayFish or something of the sort. If you give up you shouldn't of started at all.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

  • Author

OMFG!!! I DID IT!!! I followed crayfish's tutorial and posted ur code in the item class and used the recipe u posted and it fianlly works!!! it takes the durability!! DUDE i cannot thank you enough man :D U ARE AWESOME!!! YESSS!!!

  • Author

This is my new code:

 

Main class:

package com.hardwareplus.mod;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.registry.GameRegistry;

@Mod(modid = "hardwareplus", name = "Hardware Plus", version = "0.1")
public class HardwarePlus {

public static Item itemIronPlate;
public static Item itemIronRod;
public static Item itemIronFile;

@EventHandler
public void preInit(FMLPreInitializationEvent event) {
	//Item/Block init and registering
	//Config Handler
	itemIronPlate = new ItemIronPlate().setUnlocalizedName("ItemIronPlate").setTextureName("hardwareplus:itemironplate").setCreativeTab(tabHardwarePlus);
	GameRegistry.registerItem(itemIronPlate, itemIronPlate.getUnlocalizedName().substring(5));
        
	itemIronRod = new ItemIronRod().setUnlocalizedName("ItemIronRod").setTextureName("hardwareplus:itemironrod").setCreativeTab(tabHardwarePlus);
	GameRegistry.registerItem(itemIronRod, itemIronRod.getUnlocalizedName().substring(5));

	itemIronFile = new ItemIronFile().setUnlocalizedName("ItemIronFile").setTextureName("hardwareplus:itemironfile").setCreativeTab(tabHardwarePlus);
	GameRegistry.registerItem(itemIronFile, itemIronFile.getUnlocalizedName().substring(5));
}

@EventHandler
public void init(FMLInitializationEvent event) {
	//Proxy, TileEntity, entity, GUI and packet
	GameRegistry.addShapelessRecipe(new ItemStack(itemIronRod, 4), new ItemStack(itemIronPlate, 1), new ItemStack(itemIronFile, 1));
}

@EventHandler
public void PostInit(FMLPostInitializationEvent event) {

}

public static CreativeTabs tabHardwarePlus = new CreativeTabs("tabHardwarePlus"){
	@Override
	public Item getTabIconItem(){
		return new ItemStack(itemIronPlate).getItem();
	}
};

}

 

IronFile class:

 

package com.hardwareplus.mod;

import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;

public class ItemIronFile extends Item {
public ItemIronFile() {
	this.setMaxDamage(20);
	this.setMaxStackSize(1);
	this.setNoRepair();
}
    public boolean doesContainerItemLeaveCraftingGrid(ItemStack stack) {
        return false;
    }

    public boolean hasContainerItem() {
    	return true;
    }
    
    public ItemStack getContainerItem(ItemStack itemStack) {
    	itemStack.attemptDamageItem(1, itemRand);
    	
    	return itemStack;
    }
}

 

Your right, you should never give up man :) Cheers to you!! Thx alot!!!

No problem! Just remember, when creating code - think like the code is a person you are talking to.

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

Sorry about that! Didn't realize it needed that to work. :P Glad you figured it out!

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

I think my hammer might work a bit differently than yours. :P

I am not a cat. I know my profile picture is sexy and amazing beyond anything you could imagine but my cat like features only persist in my fierce eyes. I might be a cat.

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.