Custom bow tutorial(code) Forge 1.18.2 and 1.19.

Started by ImOd102 on

Topic category: User side tutorials

Last seen on 13:56, 19. Dec 2022
Joined Feb 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Custom bow tutorial(code) Forge 1.18.2 and 1.19.
Wed, 10/19/2022 - 19:30 (edited)

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.

Edited by ImOd102 on Wed, 10/19/2022 - 19:30
Last seen on 19:28, 9. Jan 2024
Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@ImOd102 have you found a…
Tue, 05/30/2023 - 15:41

@ImOd102 have you found a way to alter damage/power values or cause a trigger when projectile hits?

Last seen on 22:10, 29. Mar 2024
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I Did all of This and It…
Fri, 12/15/2023 - 04:25

I Did all of This and It Works but the texture is just a purple/black box

Last seen on 22:10, 29. Mar 2024
Joined Oct 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, I Figured Out That Its…
Fri, 12/15/2023 - 23:17

Oh, I Figured Out That Its not items/<bow_name> for the json files but item/<bow_name>

Last seen on 04:52, 24. Apr 2024
Joined Sep 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Good tutorial!
Tue, 12/19/2023 - 00:07

Good tutorial!

Last seen on 00:44, 9. Apr 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@SocialTag did you found a…
Wed, 01/10/2024 - 16:45

@SocialTag did you found a way to alter damage/power values?

Last seen on 18:52, 28. Feb 2024
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
ImOd102 1.16.5 2022.2…
Fri, 01/26/2024 - 18:53

ImOd102 1.16.5 2022.2 tutorial? I would greatly appreciate it.

Last seen on 19:08, 22. Apr 2024
Joined Jan 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@ImOd102 Hey, I've found out…
Fri, 02/02/2024 - 04:18

@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.

Last seen on 00:44, 9. Apr 2024
Joined Nov 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Notchguy76 how "Hey, I've…
Fri, 02/02/2024 - 23:52

@Notchguy76 how "Hey, I've found out a way to make custom Ammo/Damage/Other Stuff"?

Last seen on 02:06, 24. Apr 2024
Joined Mar 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Is there anyway to do this…
Tue, 04/23/2024 - 02:11

Is there anyway to do this in 1.20.1