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

So I decided to try start up modding to be ready to begin a proper mod with the 1.7.2 release. I've been trying to achieve fairly simple things, but one thing is wrong for sure.

My main class:

 

public class FrozenWorld {
public static final String modID = "FrozenWorld";
public static int SaphireOreID = 899;
public static int SaphireIID = 900;		
//Creating the Forge instance
@Instance(value = "FrozenWorld")
public static FrozenWorld instance;
//Says where client and server proxy files are located
@SidedProxy(clientSide="mods.danilafe.frozenworld.client.ClientProxy",serverSide="mods.danilafe.frozenworld.common.CommonProxy")
public static mods.danilafe.frozenworld.common.CommonProxy proxy;
@EventHandler // used in 1.6.2
    public void preInit(FMLPreInitializationEvent event) {
         
    }
@EventHandler
public void preInit(FMLInitializationEvent event){
	Block SaphireOre = new SaphireOre(SaphireOreID, Material.rock)
			.setHardness(0.5F)
			.setStepSound(Block.soundStoneFootstep)
	        .setUnlocalizedName("SaphireOre")
	        .setCreativeTab(CreativeTabs.tabBlock);
	Item SaphireI = new SaphireI(900)
			.setCreativeTab(CreativeTabs.tabMisc)
			.setMaxStackSize(64)
			.setUnlocalizedName("SaphireI");
	GameRegistry.registerBlock(SaphireOre, "SaphireOre");
	GameRegistry.registerItem(SaphireI, "SaphireI");
	LanguageRegistry.addName(SaphireI, "Saphire");
	LanguageRegistry.addName(SaphireOre, "Saphire Ore");
	MinecraftForge.setBlockHarvestLevel(SaphireOre, "pickaxe", 2);

}
@EventHandler 
    public void load(FMLInitializationEvent event) {
            proxy.registerRenderers();
    }
 @EventHandler
     public void postInit(FMLPostInitializationEvent event) {
             // Stub Method
 }

}

 

My SaphireOre block class:

 

public class SaphireOre extends Block{

public SaphireOre(int par1, Material par2Material) {
	super(par1, par2Material);
}
@SideOnly(Side.CLIENT)
public void registerIcons(IconRegister par1IconRegister)
    {
        this.blockIcon = par1IconRegister.registerIcon("FrozenWorld" + ":" + (this.getUnlocalizedName().substring(5)));
    }
public int idDropped(int i, Random rand, int j){
	return mods.danilafe.frozenworld.FrozenWorld.SaphireIID;
}
public int quantityDropped(Random rand){
	return  1;
}

}

 

Now as you can see, I have it try to drop SaphireIID, from the main class. The SaphireI item should have the id 900. 

BUT.

It has an id of 1156. 256 more. And the same happens when I change is to, for example, 545. The id becomes 801. Please not this does not happen with the block. PLEASE HELP!

“Since when did you start modding?”

“Last night"

Simple problem, fortunately! Vanilla minecraft automatically shifts every single item ID by 256. Originally, those first 256 ID slots were reserved for blocks. You can change the drop to what you want like this:

 

public int idDropped(int par1, Random par2Random, int par3) {

 

return yourpackage.youritem.itemID;

}

 

EDIT: Sorry, missed that you put that in there! In any case, yes, minecraft does this on purpose, but worst comes to worst, just put in

 

return (SaphireIID + 256)

 

EDIT (Man, I've got to stop editing): Also, the first few thousand slots are often for blocks and the later slots are for items. For example, my mod sets block IDs starting at 2500 and item IDs starting at 5000. You can google a list of what mods use what IDs in forge for a general idea of what's good to use and also use a config file to make your ID range fully customizable.

Do not mess with the item IDs, just don't.  You don't need to.  You will never encounter problems unless you're doing bad practice.  Whereas if you do subtract the 256 back out, you will have problems with compatibility with other mods (because they won't subtract 256 and thus their config will look like it has a different ID than your mod to the player, but! it will conflict anyway).

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.

Do not mess with the item IDs, just don't.  You don't need to.  You will never encounter problems unless you're doing bad practice.

 

^ Sums up all I had to say :)

 

If you guys dont get it.. then well ya.. try harder...

  • Author

What do you mean "not mess with the IDs"? Since the variable and the id are different, and it's the variable that's stored in the config, the config and the item would have different values, right?

I don't have a config yet anyway, anyone remind me of how to do it?

“Since when did you start modding?”

“Last night"

What do you mean "not mess with the IDs"? Since the variable and the id are different, and it's the variable that's stored in the config, the config and the item would have different values, right?

 

Yes.  They would.  AND THEY SHOULD.

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.

  • Author

Ok this might seem a stupid question but - how would I make a block drop the selected item? By using

"return SaphireIID +256"?

“Since when did you start modding?”

“Last night"

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.