Jump to content

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


WiseNoobCrusher

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!!!

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.

Announcements



×
×
  • Create New...

Important Information

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