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.
@ImOd102 have you found a way to alter damage/power values or cause a trigger when projectile hits?
I Did all of This and It Works but the texture is just a purple/black box
Oh, I Figured Out That Its not items/<bow_name> for the json files but item/<bow_name>
Good tutorial!
@SocialTag did you found a way to alter damage/power values?
ImOd102 1.16.5 2022.2 tutorial? I would greatly appreciate it.
@ImOd102 Hey, I've found out a way to make custom Ammo/Damage/Other Stuff, but I can't seem to get the bow item to check for any other ammo then the normal arrows, by this I mean it will still only consume the custom ammo I set but only after it does the "ammo check" for arrows.
@Notchguy76 how "Hey, I've found out a way to make custom Ammo/Damage/Other Stuff"?
Video Tutorial - https://www.youtube.com/watch?v=TPxzv3YTBLQ
@Notchguy76 how
Is there anyway to do this in 1.20.1