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 know the code to load/register a Basic Item on 1.6.4 and prior was:

 

Item Loader:

package SackCastellon.craftablehorsearmor.library.loader;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class ItemLoader {

public static Item Stirrup;

public static void load() {

	Stirrup = new SKCItem(1000).setUnlocalizedName("Stirrup").setCreativeTab(CreativeTabs.tabMisc).setTextureName( "CraftableHorseArmor:Stirrup");
}
}

 

Main Class:

package SackCastellon.craftablehorsearmor;

import java.io.File;

import SackCastellon.core.helper.LogHelper;
import SackCastellon.craftablehorsearmor.loader.ItemLoader;
import SackCastellon.craftablehorsearmor.proxy.CommonProxy;
import SackCastellon.craftablehorsearmor.reference.Reference;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

@Mod(modid=Reference.MODID, name=Reference.NAME, version=Reference.VERSION, dependencies=Reference.DEPENDENCIES)
public class CraftableHorseArmor {	

    @Instance(Reference.MODID)
    public static CraftableHorseArmor instance;

    @SidedProxy(clientSide=Reference.CLPROXY, serverSide=Reference.CMPROXY)
    public static CommonProxy proxy;
   
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {}
   
    @EventHandler
    public void load(FMLInitializationEvent event) {
    	
// Items
    	
    	LogHelper.info(Reference.MODID, "Loading items.");
    	
	try {

    	ItemLoader.load();
    	
		LogHelper.info(Reference.MODID, "Items succesfully loaded.");

	} catch(Exception e) {

		LogHelper.severe(Reference.MODID, "Could not load items.");
	} 
    }
   
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {}

}

 

But how in 1.7.2 there aren't ID because the items are based on strings this code doesn't work.

 

So i tried to write a new code based on vanilla minecraft code, like this:

 

package SackCastellon.craftablehorsearmor.loader;

import SackCastellon.craftablehorsearmor.reference.Reference;

import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;

public class ItemLoader {

public static final Item Stirrup = (Item)Item.field_150901_e.getObject("stirrup");

public static void load() {

	Item.field_150901_e.func_148756_a(500, "stirrup", (new Item()).setUnlocalizedName("Stirrup").setCreativeTab(CreativeTabs.tabMisc).setTextureName("CraftableHorseArmor:Stirrup"));
}
}

 

But still doesn't work..

 

Somebody know how to load/register a Item now?

 

Thanks for helping  :)

 

 

SOLUTION:

 

Just move the ItemLoader.load() from the load method to the preInit method in the Main Class

 

package SackCastellon.craftablehorsearmor;

import java.io.File;

import SackCastellon.core.helper.LogHelper;
import SackCastellon.craftablehorsearmor.loader.ItemLoader;
import SackCastellon.craftablehorsearmor.proxy.CommonProxy;
import SackCastellon.craftablehorsearmor.reference.Reference;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.Mod.EventHandler;
import cpw.mods.fml.common.Mod.Instance;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;

@Mod(modid=Reference.MODID, name=Reference.NAME, version=Reference.VERSION, dependencies=Reference.DEPENDENCIES)
public class CraftableHorseArmor {	

    @Instance(Reference.MODID)
    public static CraftableHorseArmor instance;

    @SidedProxy(clientSide=Reference.CLPROXY, serverSide=Reference.CMPROXY)
    public static CommonProxy proxy;
   
    @EventHandler
    public void preInit(FMLPreInitializationEvent event) {

// Items
    	
    	LogHelper.info(Reference.MODID, "Loading items.");
    	
	try {

    	ItemLoader.load();
    	
		LogHelper.info(Reference.MODID, "Items succesfully loaded.");

	} catch(Exception e) {

		LogHelper.severe(Reference.MODID, "Could not load items.");
	} 
}
   
    @EventHandler
    public void load(FMLInitializationEvent event) {}
   
    @EventHandler
    public void postInit(FMLPostInitializationEvent event) {}

}

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.