Jump to content

Custom Items - ItemSpear?


HydroBane

Recommended Posts

I want to create a spear for my mod, Mo Tools, and I was wondering how to create an ItemSpear.class to save myself the time of declaring all the properties individually in my IitemWoodenSpear.class, ItemStoneSpear.class etc..

 

Can anyone give me a hand?

 

~ Hydro

Link to comment
Share on other sites

I want to create a spear for my mod, Mo Tools, and I was wondering how to create an ItemSpear.class to save myself the time of declaring all the properties individually in my IitemWoodenSpear.class, ItemStoneSpear.class etc..

 

Can anyone give me a hand?

 

~ Hydro

Link to comment
Share on other sites

Each item type can get it's own instance you could do something like

public class Spear extends Item{
public final int damage;
public Spear(int id, int dmg){
damage = dmg
}
}

and then set the values on init

Item spearWood = new ItemSpear(woodSpearID, 2);
Item spearDiamond = new ItemSpear(diamSpearID, ;

 

I think its my java of the variables.

Link to comment
Share on other sites

Each item type can get it's own instance you could do something like

public class Spear extends Item{
public final int damage;
public Spear(int id, int dmg){
damage = dmg
}
}

and then set the values on init

Item spearWood = new ItemSpear(woodSpearID, 2);
Item spearDiamond = new ItemSpear(diamSpearID, ;

 

I think its my java of the variables.

Link to comment
Share on other sites

So...

 

public class ItemSpear extends Item{
public final int damage;
public ItemSpear(int id, int dmg){
damage = dmg
}
}

 

is my ItemSpear.class, yes?

I'm probably going to sound like a complete idiot here but; How, then, do I add textures to the individual spears?

Link to comment
Share on other sites

So...

 

public class ItemSpear extends Item{
public final int damage;
public ItemSpear(int id, int dmg){
damage = dmg
}
}

 

is my ItemSpear.class, yes?

I'm probably going to sound like a complete idiot here but; How, then, do I add textures to the individual spears?

Link to comment
Share on other sites

well you will need to set the unlocalized name per item, and you can use that to access the file, if the file is directly related to the unlocalized name, otherwise you could create an if statement or add it to your constructor(not recommended due to side differences)

 

so something like

//pseudo code
public void registerIcon(IconRegister i){
//if using unlocalized
i.registerIcon("yourmod:" + getUnlocalizedName());
//item id switch
switch(itemID){
case(woodSpearID):
i.registerIcon("yourmod:wooden spear";
break;
case(diamondSpearID):
i.registerIcon("yourmod:diamond spear";
break;
default:
break
}

}

 

I think its my java of the variables.

Link to comment
Share on other sites

well you will need to set the unlocalized name per item, and you can use that to access the file, if the file is directly related to the unlocalized name, otherwise you could create an if statement or add it to your constructor(not recommended due to side differences)

 

so something like

//pseudo code
public void registerIcon(IconRegister i){
//if using unlocalized
i.registerIcon("yourmod:" + getUnlocalizedName());
//item id switch
switch(itemID){
case(woodSpearID):
i.registerIcon("yourmod:wooden spear";
break;
case(diamondSpearID):
i.registerIcon("yourmod:diamond spear";
break;
default:
break
}

}

 

I think its my java of the variables.

Link to comment
Share on other sites

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.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.