Topic category: User side tutorials
This tutorial will let you make a custom bow, that works like the vanilla one.
Before you start you will want to have:
- 4 bow textures, 1 base texture, and 3 different pulling ones.
- Maybe, possibly some java or coding knowledge(If you want to understand the tutorial) and knowledge on how to use mcreator.
We'll start with the bow tutorial. First, make a normal item(not a ranged item). Then you can add texture, name and special information/lore(optional), but make sure to change the stack size to 1 and set the durability to whatever you want. Lock the code and enter the code editor. Now delete all the methods(like "getUseAnimation") except for "appendHoverText"(if you added lore this should appear). Look for the starting point of the code that says public class (item name)Item. Between that and the brackets add: "extends BowItem". Your code should look something like this https://imgur.com/LyWT1bh(click for image). Now reformat(ctrl/command + w) and save your code. Go to your workspace settings go to the 3rd tab labeled Advanced Setting and check "Lock base mod files" and save changes. Now create a custom code element called ModItemProperties and add this code to it:
@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class ModItemProperties { public static void addCustomItemProperties() { makeBow(TutorialModItems.IRON_BOW.get()); } private static void makeBow(Item item) { ItemProperties.register(item, new ResourceLocation("pull"), (p_174635_, p_174636_, p_174637_, p_174638_) -> { if (p_174637_ == null) { return 0.0f; } else { return p_174637_.getUseItem() != p_174635_ ? 0.0f : (float) (p_174635_.getUseDuration() - p_174637_.getUseItemRemainingTicks()) / 20.0f; } }); ItemProperties.register(item, new ResourceLocation("pulling"), (p_174630_, p_174631_, p_174632_, p_174633_) -> { return p_174632_ != null && p_174632_.isUsingItem() && p_174632_.getUseItem() == p_174630_ ? 1.0f : 0.0f; }); } }
Change Aetheriamodck in AetheriamodckModItems to your mod name,(example: Mod name: TutorialExample = TutorialExampleModItems) And IRON_BOW to your item's id(in ALL CAPS). That line can be added as many times as you want for each bow, just change the id. Reformat and save. Now go to your main mod file(which should be located in source/net/mod_name/). Look for the method that has stuff like REGISTRY and add to the bottom: bus.addListener(this::clientSetup); Then above the last method(addNetworkMessage) add this code:
private void clientSetup(final FMLClientSetupEvent event) { ModItemProperties.addCustomItemProperties(); }
Reformat and save again. Now go to the left side of the window and search up your item id(example: iron_bow). Right click on the json file you find and click show in explorer. Now copy paste that json file 3 times. You should now have 4 different copies. Keep the regular one, don't give it a new name. For the other ones get your item id and add "_pulling_0", "_pulling_1", and "_pulling_2". Now go to your item's main json file in mcreator. Put this code in:
{ "parent": "item/bow", "textures": { "layer0": "mod_id:items/iron_bow" }, "overrides": [ { "predicate": { "minecraft:pulling": 1 }, "model": "mod_id:item/iron_bow_pulling_0" }, { "predicate": { "minecraft:pulling": 1, "minecraft:pull": 0.65 }, "model": "mod_id:item/iron_bow_pulling_1" }, { "predicate": { "minecraft:pulling": 1, "minecraft:pull": 0.9 }, "model": "mod_id:item/iron_bow_pulling_2" } ] }
The three strings near the bottom that start with "model" must be changed to your names for each of the pulling json files. Change all the mod ids. The top is your texture file path. Reformat and save. Now go to each of your pulling files. You'll want each of your files to look something like this:
{ "parent": "mod_id:item/bow_id", "textures": { "layer0": "mod_id:items/iron_bow_pulling_0" } }
You're done! Thanks again to Kid Justice Gaming.
It might not fix the error but in "iron_bow.json" the "item/generated" should be replaced "item/bow".
I changed that & the results didn't change as well as the same errors were outputted. Does the iron_bow.json have to have it's own model as well as a texture? I see a pull back animation but just no sequence of textures from the 3 pulling textures. That's my only thought because it says "unable to load model" & I've only used 4 textures including iron_bow.json. However unless i'm mistaken this tutorial doesn't call for that correct?
BudTheGod, are you sure you did this part?
Excuse me for being uneducated, but I'm really confused with the whole "Now delete all the methods(like "getUseAnimation") except for "appendHoverText"(if you added lore this should appear)." thing, I don't know what a method is really and searching it up isn't helping all too much. Any guidance? Am I probably going to never manage to finish this tutorial? 😫
Alright scratch my last message I figured that one out, now I'm just stumped on what "Change Aetheriamodck in AetheriamodckModItems to your mod name,(example: Mod name: TutorialExample = TutorialExampleModItems) And IRON_BOW to your item's id(in ALL CAPS)." means? I couldn't find "Aetheriamodck" in the Custom Element script?
I believe I did everything correctly besides what I last messaged about however I'm getting this error: https://imgur.com/a/yKdkyiO
Here's my console and the errors popping up: https://imgur.com/a/jEKNVVL
I'm sorry I've been messaging here like crazy lol, but I actually managed to get it working completely fine after comparing the workspace you sent over to mine, the only thing is now that I can't figure out how to change the bow's attributes like the arrow damage, arrow speed, stuff like that.
Hello @rubenquent, I'm thankful you can have solved the problems with your code. At the moment I do not know how to change the damage and speed(actually power), I will look into it though and will see if I can give you a solution.
Thank you so much for just even trying. This guide was a life saver, everywhere else I looked either didn't work or just didn't make sense to me lol.
is there a way to make this bow shoot custom arrows?
I don't know what I did wrong, but the animation doesn't work for me. Everything compiles perfectly, but it is not clear what is happening with the animation. I can give link for my project if someone want to help me, there is only a bow and that script for properties.
https://drive.google.com/file/d/1oiU5_nyWr2HbQp2C-8rE17yCCXKZW8qF/view?…
"Look for the method that has stuff like REGISTRY and add to the bottom: bus.addListener(this::clientSetup); Then above the last method(addNetworkMessage) add this code:"
Where do I find the method with REGISTRY?
nvm I found it