Topic category: User side tutorials
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
This just causes a compiling error... can we have screenshots of what the entire code is meant to look like please?
apparently the issue is "this.addPropertyOverride". Why..?
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.
In 1.16 property overrides are now registered in client setup event.
forge 1.16.5
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!
Where do you find public ItemRanged():
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?
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
How please tell me
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.
happy to finally present it to your guys (sorry for the really long wait, turns out personal life isn't easy haha): https://mcreator.net/forum/74855/tutorial-how-animate-custom-bow-pulling-116