Jump to content

[1.7.10] Custom bow animation and behaviour


MuffinMonster

Recommended Posts

I've been able to create a custom bow with different range and damage that the usual bow, now the bow doesn't animate as needed and after looking through the ItemBow class and referred classes inside I cannot make up where the actual animation length and "zooming-in" effect comes from.

 

I have been able to find where the animation is decided which should be this:

/**
     * returns the action that specifies what animation to play when the items is being used
     */
    public EnumAction getItemUseAction(ItemStack p_77661_1_)
    {
        return EnumAction.bow;
    }

 

But there is nothing in that EnumAction class that declares the parameters of the animation.

 

As far as the "zooming-in" effect goes, I'm confused as to why it isn't already functioning since I'm just extending the base ItemBow class which should have that in it.

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

Thanks, I already got the texture transformation now. The animation I was referring to is the one that makes the bow move towards the camera and start to shake a bit, that animation is not defined as far as I can see in the base item class for the bow.

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

As I check the FOVUpdateEvent I cannot see anything else than the fov variable, and the shaking occurs on the item itself, not the camera. May there be a function for it inside the Item class maybe?

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

Yea, it does work, somewhat(The animation enum is set to bow by default at the base ItemBow class so no further code needed).

The animation first slowly moves the bow closer to the player and at full tension the bow starts to shake, when I modify the pulltimes the animation gets offset from what the custom bow actually does. This isn't a big issue though so I'll manage without going deep into the coding for it to fix a fraction of a second.

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

As noted before it's not the texture that is the issue, it is synchronized based on the pulltime so no problem there.

 

A bow kinda has 3 different animations:

- Fov change

- Texture change

- Bow position change(move and then shake)

 

The Fov and texture is working properly, its the moving and shaking of the bow that's the issue(The time when the bow start to shake is hardcoded to the default bow pulltime). I'm not sure if this requires some extra classes or some deep minecraft source digging to find the root of the shaking or what.

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

The thing is that I do not know if it's hardcoded or not because I cannot find where the code for it lies.

 

Anyway, this issue isn't noticed if you use the bow normally so I'm just going to leave that as is for now. At least I got the Fov to change thanks to you!

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

Uhm, one last thing here.

 

I noted that the position and rotation of the bow in the hand is way off now. I tried with setting the setFull3D() function but it's still not correctly placed.

 

Is there a way I can change the position and rotation of the bow while pullin it?

--Remember to "Thank you" posts that actually helped you, and if a person seems nice, why not give them an applaud while you're at it--

Link to comment
Share on other sites

I was curious about this myself so I did a quick search. The bow rendering stuff you care about is in two different places I could find.

 

*.renderer.ItemRenderer (lines 459-488), handles the first person view entity renders, deals with the EnumAction.bow animations, and *renderer.entity.RenderPlayer (lines 345-353), which looks like it sets the position, rotation, and scaling of the bow item in the hands of the third person player entity. You said you looked at the ItemBow class so you know about how the draw animation is handled no doubt.

 

The ItemRenderer bit involves checking the getMaxItemUseDuration on the held ItemStack, which is something you'd be able to influence.

 

Unfortunately it looks like the bit in RenderPlayer tests whether the held ItemStack == Items.bow, which obviously won't work for your mod item.

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.