Jump to content

Recommended Posts

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();

 

}

}

 

 

Posted

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

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.