[Tutorial] Custom Bow pulling

Started by TheLuxureSlime on

Topic category: User side tutorials

Last seen on 17:03, 19. Apr 2024
Joined Sep 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Tutorial] Custom Bow pulling

Howdy everyone!
It's my first tutorial and im gonna show how to make pulling for your (maybe) amazing bow!


1 step: Modifying model
Go by this path: ~/src/main/resources/assets/your_mod_name/models/item
There choose your bow name. Example: example.json
Open your bow file.
Put in the end of your file this lines:
  },
    "overrides": [
        {
            "predicate": {
                "pulling": 1
            },
            "model": "your_mod_name:item/example_bow_pulling0"
        },
        {
            "predicate": {
                "pulling": 1,
                "pull": 0.65
            },
            "model": "your_mod_name:item/example_bow_pulling1"
        },
        {
            "predicate": {
                "pulling": 1,
                "pull": 0.9
            },
            "model": "your_mod_name:item/example_bow_pulling2"
        }
    ]
}

After make file: example_bow_pulling0.json
Replace pulling0 by pulling1, pulling2 or stay pulling0.
In pulling files write this:
{
    "parent": "item/bow",
    "textures": 
    {
        "layer0": "your_mod_name:items/example_bow_pulling0"
    }
}

Also, you need texture for your bow as well. So first step is finished! Let's go in second step.


2nd step: Codding


Don't scary! It will be easy! I hope!
1st: Find public ItemRanged():
Put in it this lines:
this.addPropertyOverride(new ResourceLocation("pull"), (p_210310_0_, p_210310_1_, p_210310_2_) -> {
                if (p_210310_2_ == null) {
                    return 0.0F;
                } else {
                    return !(p_210310_2_.getActiveItemStack().getItem() instanceof BowItem)
                            ? 0.0F
                            : (float) (p_210310_0_.getUseDuration() - p_210310_2_.getItemInUseCount()) / 20.0F;
                }
            });
            this.addPropertyOverride(new ResourceLocation("pulling"), (p_210309_0_, p_210309_1_, p_210309_2_) -> {
                return p_210309_2_ != null && p_210309_2_.isHandActive() && p_210309_2_.getActiveItemStack() == p_210309_0_ ? 1.0F : 0.0F;
            });

And finished!
Also, click on CTRL+W. It possibly will fix some errors in your code.
Currently, it works only with pulling0 so when i will figured how make pulling1 and pulling2 work im will update this 'tutorial'. (I would not call it a tutorial)


And thanks what read this.
If you have any questions, feel free to ask me

Last seen on 07:56, 15. Nov 2022
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
This just causes a compiling…
Sun, 05/23/2021 - 02:34

This just causes a compiling error... can we have screenshots of what the entire code is meant to look like please?

Last seen on 07:56, 15. Nov 2022
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
apparently the issue is …
Sun, 05/23/2021 - 05:02

apparently the issue is "this.addPropertyOverride". Why..?

Last seen on 08:14, 28. Nov 2023
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
i believe it may have got…
Sun, 05/23/2021 - 05:53

i believe it may have got something to do with the "addPropertyOverride" function either no longer existing or having been renamed. if you didn't know, some parts of MC code change in updates so you'll need to adapt to the new one and change some parts of code in your bow item. so your problem might be because of that being outdated. sadly, we still don't know what version that code is for and what Forge version you're modding, but maybe knowing both things might help fix this.

Last seen on 23:21, 17. Jun 2022
Joined Apr 2018
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
In 1.16 property overrides…
Sun, 05/23/2021 - 07:14

In 1.16 property overrides are now registered in client setup event.

Last seen on 07:56, 15. Nov 2022
Joined Apr 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
forge 1.16.5
Sun, 05/23/2021 - 07:27

forge 1.16.5

Last seen on 08:14, 28. Nov 2023
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
alright, thanks Frostygames0…
Sun, 05/23/2021 - 10:13

alright, thanks Frostygames0. but do you by chance know of a way to implement it in MCreator's current registry and (client) setup system? coz afaik, MCreator uses one that's different from the standard Forge registry system most mods use. I've been checking source code of open-source Forge 1.16 mods that have bows (e.g. Gobber) and learning how they do it, to finally try to code it a mod workspace... but to no avail. (I'm unfamiliar with the way MCreator registers/sets up stuff so unfortunately I'm lost with some errors.) if you know how it can be done in MCreator, you can take it from here!

Last seen on 13:21, 23. Jan 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Where do you find public…
Mon, 05/24/2021 - 21:10

Where do you find public ItemRanged():

 

Last seen on 08:14, 28. Nov 2023
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
omg... YES!!! i finally…
Wed, 05/26/2021 - 06:45

omg... YES!!! i finally figured out how to make the arrow pulling animation for 1.16.5 after literal hours of coding! i'd be glad to share it! but should i share it here, or can i make a separate user-side tutorial?

Last seen on 08:14, 28. Nov 2023
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
alright, never mind. since…
Fri, 05/28/2021 - 00:56

alright, never mind. since we're now talking about 1.16, I'll just make a separate tutorial that's meant to "extend" upon this one instead of wasting more time waiting for an answer when many people modding 1.16 could be helped. plus, in that MC version, the code for custom bow pulling is a bit more complicated with more things to do. the JSON code for the item model is still applicable though, so huge thanks to this tutorial for the template! imma link this page on my tutorial, because some people might be looking for how to make this in 1.15 and below, and because it deserves to be credited :D

Last seen on 13:21, 23. Jan 2022
Joined Oct 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
How please tell me
Fri, 05/28/2021 - 01:59

How please tell me

Last seen on 08:14, 28. Nov 2023
Joined Aug 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
VaderCraft_, you can find…
Fri, 05/28/2021 - 03:05

VaderCraft_, you can find the constructor "public itemRanged()" by searching the code (using ctrl + F and typing "public itemranged"). btw, please be patient about the tutorial; I don't find the preparation & organization part of it very easy, and at the time I finished writing that previous comment I still had to deal with other more important stuff. I'm sure we can all wait for at least half an hour, and it'll be worth it in the end.