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

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

  • Author

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

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.

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.

  • Author

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?

  • Author

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?

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.

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.

  • Author

And that would go in my load event?

Sorry for all the questions, forge modding isn't my strong point.

  • Author

And that would go in my load event?

Sorry for all the questions, forge modding isn't my strong point.

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.