WeaponMechanics / MechanicsMain

A New Age of Weapons in Minecraft.
https://www.spigotmc.org/resources/WeaponMechanics.99913/
MIT License
85 stars 28 forks source link

Gun Animation #68

Open Jellychicken opened 2 years ago

Jellychicken commented 2 years ago

Description

Adds the ability to use gun animation. This animation feature need resourcepack. If anyone use this feature, you should add 9.6 to translation y of 3d model's display.

example: https://streamable.com/ovm4cy https://streamable.com/a5rhef

Configuration

Animations:
  Use_Animation: <true/false> #if this value is true, when player swap item to wm gun, system will give player mining fatigue 200 for max seconds to delete minecraft own item swap motion
  Shooting:
    Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
  Reloading:
    Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
    Open_Animation_List: #execute animation when reloading gun without left bullets
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
  Scoping:
    Duration: <ticks>
    Zoom_Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
    Zoom_Off_Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
    Zoom_Shoot_Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
  Firearms:
    Open_Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
    Close_Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
  Sprint:
    Sprint_Delay: <ticks>
    Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
  Swap:
    Duration: <ticks>
    Animation_List:
    - <item>-<custommodeldata>-<ticks>
    - <etc.>
    #Swap_Sound_List:
    #- <sound>-<volume>-<pitch>
    #- <sound>-<volume>-<pitch>-<delay>-<pitchNoise>
    #- custom:<sound>-<volume>-<pitch>
    #- custom:<sound>-<volume>-<pitch>-<delay>-<pitchNoise>
    #- <etc.>
CJCrafter commented 2 years ago

I am very unfamiliar with animations. Do you have an example model with an animation that I can use for testing?

Jellychicken commented 2 years ago

Sure. test-animation.zip

ladakx commented 2 years ago

The idea looks very cool and could make the plugin more unique and not repeatable.

CJCrafter commented 2 years ago

EDIT

This is not possible with a plugin, the model will bob whenever we change the custom model data, which would ruin the animation It may be possible to prevent this if we made a companion datapack for weaponmechanics, but I don't know how that would work. Something worth investigating in the future, but impossible for now.


End of edit

Oh so it is literally just a bunch of different positions of the model? Did you use blockbench to make the animations or did you have to set the positions for each one?

Either way, here is my idea:

Concept

We could have a Transition value that can define a list of custom model datas to animate. Say we start in the Default position. When the player scopes, we first check Scope.Transition to see if we should be using an animation. If the animation is over, we can just set the skin to scope skin. When going from Scope back to Default, we can use either Default's transition, or Scope's transition in reverse.

Transition:
  Ticks_Per_Animation: 1 # Setting this higher may cause a "stuttery" animation
  Use_Backwards_List_On_Leave: true # Setting this to 'true' causes the `Default` transition to never be used
  List:
    - 131 # frame 1
    - 132 # frame 2
    - 133 # frame 3
    - 134 # frame 4

In current config

Currently skin config looks like this (I removed a scope_1 and no_ammo to make it less bulky)

  Skin:
    Default:
      Type: <Material>
      Legacy_Data: <Integer>
      Custom_Model_Data: <Integer>
      Durability: <Integer>
      Transition:
        Ticks_Per_Animation: 1 
        Use_Backwards_List_On_Leave: true 
        List:
          - <Integer>
    Scope:
      Type: <Material>
      Legacy_Data: <Integer>
      Custom_Model_Data: <Integer>
      Durability: <Integer>
      Transition:
        Ticks_Per_Animation: 1 
        Use_Backwards_List_On_Leave: true 
        List:
          - <Integer>
    Reload:
      Type: <Material>
      Legacy_Data: <Integer>
      Custom_Model_Data: <Integer>
      Durability: <Integer>
      Transition:
        Ticks_Per_Animation: 1 
        Use_Backwards_List_On_Leave: true 
        List:
          - <Integer>
    Sprint:
      Type: <Material>
      Legacy_Data: <Integer>
      Custom_Model_Data: <Integer>
      Durability: <Integer>
      Transition:
        Ticks_Per_Animation: 1 
        Use_Backwards_List_On_Leave: true 
        List:
          - <Integer>

Missing

We will need some way to add fire actions (open/close animations) and per frame time

I-am-ddang commented 2 years ago

I know that he (https://streamable.com/ovm4cy / https://streamable.com/a5rhef) uses his private gun plugin for his animation work And he specified that "Use_Animation: <true/false> #if this value is true, when player swap item to wm gun, system will give player mining fatigue 200 for max seconds to delete minecraft own item swap motion". Minecraft own item swap motion == bobing item == swing up and down when changing item's itemmeta.

This is one Minecraft trick, and the model is not bob if mining fatigue 200 is given to player If player has mining fatigue 200, item is down the screen. And in resourcepack-side, add 9.6 to y value of model's display to pull item's model.

So, server can offer 3d model's animation to user

Thank you for your answer, bro.

LemonCaramel commented 2 years ago

This can be implemented as a plugin.

This video used Minecraft's tricks and ClientboundContainerSetSlotPacket.

DeeCaaD commented 2 years ago

Quick FYI, you can use Item_Serializer attribute GENERIC ATTACK SPEED to achieve same thing as mining fatigue

RollexGrief commented 2 years ago

EDIT

This is not possible with a plugin, the model will bob whenever we change the custom model data, which would ruin the animation It may be possible to prevent this if we made a companion datapack for weaponmechanics, but I don't know how that would work. Something worth investigating in the future, but impossible for now.

End of edit

Oh so it is literally just a bunch of different positions of the model? Did you use blockbench to make the animations or did you have to set the positions for each one?

Either way, here is my idea:

Concept

We could have a Transition value that can define a list of custom model datas to animate. Say we start in the Default position. When the player scopes, we first check Scope.Transition to see if we should be using an animation. If the animation is over, we can just set the skin to scope skin. When going from Scope back to Default, we can use either Default's transition, or Scope's transition in reverse.

Transition:
  Ticks_Per_Animation: 1 # Setting this higher may cause a "stuttery" animation
  Use_Backwards_List_On_Leave: true # Setting this to 'true' causes the `Default` transition to never be used
  List:
    - 131 # frame 1
    - 132 # frame 2
    - 133 # frame 3
    - 134 # frame 4

In current config

Currently skin config looks like this (I removed a scope_1 and no_ammo to make it less bulky)

  Skin:
    Default:
      Type: <Material>
      Legacy_Data: <Integer>
      Custom_Model_Data: <Integer>
      Durability: <Integer>
      Transition:
        Ticks_Per_Animation: 1 
        Use_Backwards_List_On_Leave: true 
        List:
          - <Integer>
    Scope:
      Type: <Material>
      Legacy_Data: <Integer>
      Custom_Model_Data: <Integer>
      Durability: <Integer>
      Transition:
        Ticks_Per_Animation: 1 
        Use_Backwards_List_On_Leave: true 
        List:
          - <Integer>
    Reload:
      Type: <Material>
      Legacy_Data: <Integer>
      Custom_Model_Data: <Integer>
      Durability: <Integer>
      Transition:
        Ticks_Per_Animation: 1 
        Use_Backwards_List_On_Leave: true 
        List:
          - <Integer>
    Sprint:
      Type: <Material>
      Legacy_Data: <Integer>
      Custom_Model_Data: <Integer>
      Durability: <Integer>
      Transition:
        Ticks_Per_Animation: 1 
        Use_Backwards_List_On_Leave: true 
        List:
          - <Integer>

Missing

We will need some way to add fire actions (open/close animations) and per frame time

It is quite possible to implement this on WeaponMechanics: https://vimeo.com/706381367

DeeCaaD commented 2 years ago

I might revisit this soon #78 .

DeeCaaD commented 2 years ago

After some testing:

Is this still worth implementing?

Jellychicken commented 2 years ago

Off hand animation is not a necessary feature, so it doesn't matter if you delete it.