Jump to content

[1.7.10] How to properly extend ItemBow?


kauan99

Recommended Posts

I noticed I have to implement getIcon and getIconForUseDuration and registerIcons, and also probably onItemRightClick if I want to change the damage my bow causes to entities. I read a (very old) tutorial about bows, but I was hoping someone could either link me to a more recent and clearer one, or give me a quick explanation of how this is done. I don't really like just copy-pasting stuff, I prefer to actually undestand what I'm doing, so, a link to a plain coded example, while appreciated, is not exactly what I'm looking for. thanks.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

You could just extend ItemBow and override what you need to make changes to. Extending it would only allow you to get away with not writing all of the methods because its already done for you.

 

You could also create a class extending item, override the methods onItemRightClick, getMaxItemUseDuration, onItemStoppedUsing, getEnumAction, etc. It shouldn't be hard at all, all the information is in the bow class itself ready to use. Also, one thing to note is that the bow's damage depends on the entity arrow being spawned. It is increased depending on the bow's use time (this is seen in the EntityArrow class).

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

I see, so if I just extend ItemBow all I have to override is what, onPlayerStoppedUsing, and change the code where it sets be arrow damage? what about the icons? this is the hardest part for me, I have a hard time understanding everything that's related to graphics or art in general.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

Link to comment
Share on other sites

I imagine it would be something like this (a little code example).

 


public class ExampleBow extends ItemBow
{

public static final String[]	 ICONNAMES = new String[] {"modid:pulling_0", "modid:pulling_1", "modid:pulling_2"};

/** We call super to initialize the values in the parent constructor - if you don't you may modify these values **/
public ExampleBow()
{
	super();
}

/** We call the super method to execute it instead - if you want to spawn an arrow with more damage, ignore the super call and modify **/
@Override
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft)
{
	super.onPlayerStoppedUsing(stack, worldIn, playerIn, timeLeft);
}

}

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

This is the line that interests me:

 

public static final String[]	 ICONNAMES = new String[] {"modid:pulling_0", "modid:pulling_1", "modid:pulling_2"};

 

I imagine I need to have (inside assets\textures\items\) textures with the names

<bow>_pulling_0.png

,

<bow>_pulling_1.png

,

<bow>_pulling_2.png

and

<bow>_standby.png

, where

<bow>

is the name of my Bow's class?

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

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.

Announcements



×
×
  • Create New...

Important Information

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