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

Hi

 

I am a new moder and just making a very simple mod which add an food item and the recipe to make it. The problem is as I open minecraft in mcp and use my recipe to craft the item, I get an Leather Cape.... It could not be eaten, but the name of the item is right what I set.  :(

 

I started my code with helfull's tutorial and also checked forge wiki and many posts here but still can't figure out the problem. The iconindex of Leather Cape is 0, I think the problem might have relation to this.

 

Can anyone tell me where is the problem?

 

 

Thanks!

 

PS: Sorry for my bad English. I am Chinese.

 

 

 

======================================

Problem solved.

Using the "new" method in mod class incorrectly.

 

 

 

 

 

 

Code

 

Mod_JBGZ

 

 

package net.minecraft.src;

 

 

import net.minecraft.src.forge.*;

 

 

public class mod_JBGZ extends BaseMod

{     

 

public static Item itemJBGZ;

 

 

 

        public void load()     

        {             

MinecraftForgeClient.preloadTexture("/JBGZ/item.png");

            this.addNames(); 

this.registerRecipes();

    }

 

 

 

 

private void addNames()

{

ModLoader.addName(itemJBGZ,"JBGZ");

}

 

private void registerRecipes()

{

ModLoader.addRecipe(new ItemStack(itemJBGZ, 1),new Object[]

{

"XXX","YZY","XXX",'X',Item.wheat,'Y',Item.egg,'Z',Item.porkRaw

});

}

 

 

 

static

{

Props.initProps();

 

itemJBGZ = (new ItemFood(Props.itemJBGZID,8,1F,false)).setPotionEffect(Potion.damageBoost.id,15*20,1,1F).setIconIndex(0).setItemName("JBGZ");

}

 

 

 

 

        public String getVersion() 

        {             

                return "0.1";       

        }

 

}

 

 

 

itemJBGZ

 

 

package net.minecraft.src;

 

 

import net.minecraft.src.forge.*;

import net.minecraft.src.ItemFood;

 

 

public class itemJBGZ extends ItemFood implements ITextureProvider

{

 

public itemJBGZ(int i,int j,float k,boolean m)

{

super(i, j, k, m);

maxStackSize = 64;

}

 

public String getTextureFile()

{

return"/JBGZ/item.png";

}

 

 

}

 

 

 

 

 

 

package net.minecraft.src;

 

import java.io.File;

import java.io.IOException;

 

import net.minecraft.client.Minecraft;

import net.minecraft.src.forge.Configuration;

 

 

public class Props

{

public static Configuration config;

 

public static int itemJBGZID;

 

public static void initProps()

{

config = new Configuration(new File(Minecraft.getMinecraftDir(),"config/JBGZ.cfg"));

 

config.load();

itemJBGZID = Integer.parseInt(config.getOrCreateIntProperty("JBGZ",Configuration.CATEGORY_ITEM,300).value);

 

config.save();

 

}

}

 

 

1) Your names are horrible, use better naming scheme.

2) How the hell do you expect the item to use your code if you never tell it to use your code?

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

  • Author

I get your point and correct my code. Thank you.

 

Sorry for a stupid question.

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.