Item Metadata, In this bit of code "names" is getting an error:
public String getItemNameIS(ItemStack i){
try{ //Just in case of NullPointerException
return names[i.getItemDamage()];
}catch(Exception e){
return "";
}
Try this:
@Override
public String getItemNameIS(ItemStack is)
{
switch(is.getItemDamage())
{
case 0: return "item1";
case 1: return "item2";
case 2: return "item3";
default: return "itemUnknown";
}
}
Cool, the first six tutorials are up! 'Setting up your workspace', 'Setting up the mod', 'Creating your first basic item', 'Metadata items', 'Recipes, smelting and fuel' and 'Custom creative mode tabs'.
It is in my main mod file. Obviously I'm trying to add a name to three items with different damage values. For some reason though, in the creative inventory they are all called Large Gate, and I can not figure out why.
It is in my main mod file. Obviously I'm trying to add a name to three items with different damage values. For some reason though, in the creative inventory they are all called Large Gate, and I can not figure out why.
There are two things it could be:
1 - Do you have setHasSubtypes(True) in the item constructor?
2 - Do you have the setItemNameIS method in your item class?
Cool, the first six tutorials are up! 'Setting up your workspace', 'Setting up the mod', 'Creating your first basic item', 'Metadata items', 'Recipes, smelting and fuel' and 'Custom creative mode tabs'.
Take a look!
Looking good so far.
I might suggest a slight change in how you set up Creative Tabs though.
Minecraft.src does this annoying thing with getTranslatedTabLabel by returning "itemgroup." + this.getTabLabel();
I would suggest following that formula though, obviously removing the "itemgroup." from the return. The reason being is that I think that this method allows for Language pack support - support not currently implemented, but may be. (actually I have intentions of Subclassing Forges LanguageRegistry to add Creative Tab Support if I cant find a suitable method.
something similar to:
@Override
@SideOnly(Side.CLIENT)
public String getTranslatedTabLabel()
{
return mod_mine.core.LanguageRegistry.instance().getStringTabLabel(this, "en_US");
}
So as to return Tab Labels in other Languages as required. While Most mods will never be international, Its not a bad practice to teach it anyway
I am a little lost following your tutorials. I am not getting caught up by how you don't always tell us where to put things, but someone less observant might. Also, I am not sure where you want us to put the ItemRuby class, as you say "We need a new package for items, for me it is: deverionx.tutorial.common.item." and then for the code you have "package deverionx.tutorial.client.core.item" as you said that common was for server side, and client was for client only, I put it in kalmondo.tutorial.common.core.item. Is this the correct location? And then the next line is a real snag for me. where do you want me to put "publicstaticItem ruby =newItemRuby(15000);//The ruby object"? Please help, as I am trying to learn this so I can start trying my hand at modding. Thought that should be obvious as I am here, lol!
Looking good so far.
I might suggest a slight change in how you set up Creative Tabs though.
Minecraft.src does this annoying thing with getTranslatedTabLabel by returning "itemgroup." + this.getTabLabel();
I would suggest following that formula though, obviously removing the "itemgroup." from the return. The reason being is that I think that this method allows for Language pack support - support not currently implemented, but may be. (actually I have intentions of Subclassing Forges LanguageRegistry to add Creative Tab Support if I cant find a suitable method.
something similar to:
@Override
@SideOnly(Side.CLIENT)
public String getTranslatedTabLabel()
{
return mod_mine.core.LanguageRegistry.instance().getStringTabLabel(this, "en_US");
}
So as to return Tab Labels in other Languages as required. While Most mods will never be international, Its not a bad practice to teach it anyway
Ah, thanks, I am thinking of figuring out Language Pack support soon, hopefully will be successful
I am a little lost following your tutorials. I am not getting caught up by how you don't always tell us where to put things, but someone less observant might. Also, I am not sure where you want us to put the ItemRuby class, as you say "We need a new package for items, for me it is: deverionx.tutorial.common.item." and then for the code you have "package deverionx.tutorial.client.core.item" as you said that common was for server side, and client was for client only, I put it in kalmondo.tutorial.common.core.item. Is this the correct location? And then the next line is a real snag for me. where do you want me to put "publicstaticItem ruby =newItemRuby(15000);//The ruby object"? Please help, as I am trying to learn this so I can start trying my hand at modding. Thought that should be obvious as I am here, lol!
Hmm, sry, didn't notice that! I like to put my items in name.mod.common.items, but honestly you can just put everything in name.mod, It's just for neatness sake
Then your item's object goes in your mod class, put it with the proxy variable
Okay! I finished setting up my first basic item! And I loaded the client via the play button at the top of eclipse, and then....it didn't load my mod....I clicked on the mods button, and my mod was no there, so I went in to creative anyway, and checked the tabs, no ruby....not even with search. I have 6 warnings and no errors:
Description Resource Path Location Type
Resource leak: 'input' is never closed Configuration.java /Minecraft/common/net/minecraftforge/common line 268 Java Problem
Dead code World.java /Minecraft/common/net/minecraft/src line 2128 Java Problem
Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. Minecraft Build path JRE System Library Problem
Resource leak: '<unassigned Closeable value>' is never closed RegionFile.java /Minecraft/common/net/minecraft/src line 184 Java Problem
Resource leak: 'var7' is never closed ThreadDownloadResources.java /Minecraft/src/net/minecraft/src line 182 Java Problem
Dead code World.java /Minecraft/common/net/minecraft/src line 2076 Java Problem
Please help. Let me know if you need any different info.
I did have both, setHasSubtypes() and setItemNameIs(), but I suddenly realized that I couldn't override setItemNameIs and obviously that is one that I should be able to override. So I looked into Item and realized I wasn't capitalizing the "s" at the end of Is. So the proper name is setItemNameIS(). My bad for asking for help on such a noobish thing, this was really annoying me! I haven't tested it yet, but I'm sure that is it.
Okay! I finished setting up my first basic item! And I loaded the client via the play button at the top of eclipse, and then....it didn't load my mod....I clicked on the mods button, and my mod was no there, so I went in to creative anyway, and checked the tabs, no ruby....not even with search. I have 6 warnings and no errors:
Description Resource Path Location Type
Resource leak: 'input' is never closed Configuration.java /Minecraft/common/net/minecraftforge/common line 268 Java Problem
Dead code World.java /Minecraft/common/net/minecraft/src line 2128 Java Problem
Build path specifies execution environment JavaSE-1.6. There are no JREs installed in the workspace that are strictly compatible with this environment. Minecraft Build path JRE System Library Problem
Resource leak: '<unassigned Closeable value>' is never closed RegionFile.java /Minecraft/common/net/minecraft/src line 184 Java Problem
Resource leak: 'var7' is never closed ThreadDownloadResources.java /Minecraft/src/net/minecraft/src line 182 Java Problem
Dead code World.java /Minecraft/common/net/minecraft/src line 2076 Java Problem
Please help. Let me know if you need any different info.
Try this:
Take a look!
If so can you make tree gen tutorial?
Can you show your code?
Agreed, I need to see your code to be able to help properly
LanguageRegistry.addName(new ItemStack(itemGateControl, 1, 0), "Small Gate");
LanguageRegistry.addName(new ItemStack(itemGateControl, 1, 1), "Medium Gate");
LanguageRegistry.addName(new ItemStack(itemGateControl, 1, 2), "Large Gate");
It is in my main mod file. Obviously I'm trying to add a name to three items with different damage values. For some reason though, in the creative inventory they are all called Large Gate, and I can not figure out why.
There are two things it could be:
1 - Do you have setHasSubtypes(True) in the item constructor?
2 - Do you have the setItemNameIS method in your item class?
Looking good so far.
I might suggest a slight change in how you set up Creative Tabs though.
Minecraft.src does this annoying thing with getTranslatedTabLabel by returning "itemgroup." + this.getTabLabel();
I would suggest following that formula though, obviously removing the "itemgroup." from the return. The reason being is that I think that this method allows for Language pack support - support not currently implemented, but may be. (actually I have intentions of Subclassing Forges LanguageRegistry to add Creative Tab Support if I cant find a suitable method.
something similar to:
So as to return Tab Labels in other Languages as required. While Most mods will never be international, Its not a bad practice to teach it anyway
Ah, thanks, I am thinking of figuring out Language Pack support soon, hopefully will be successful
Hmm, sry, didn't notice that! I like to put my items in name.mod.common.items, but honestly you can just put everything in name.mod, It's just for neatness sake
Then your item's object goes in your mod class, put it with the proxy variable
"Programmers never repeat themselves. They loop."
Please help. Let me know if you need any different info.
Could you provide your code?
EDIT: Preferably in Code blocks in spoilers.
"Programmers never repeat themselves. They loop."
That code gives me this:
Syntax error on token "addNames", Identifier expected after this token
As far as my code, I will just paste bin it, because I am not sure which ones you guys would need.
TutorialMain
CommonProxy
SeverPacketHandler
ClientPacketHandler
ClientProxy
CommonProxy
ItemRuby
I should mention that when I load the work space I get an error about Git, or eGit or something like that.... Not sure if that is relevant.