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 22:53, 20. Jun 2023
Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks this was really…
Sat, 10/01/2022 - 20:17

Thanks this was really helpful!

You can save some time by not having all the display parts in the "example_bow.json" model file. Instead you can change the parent to "item/bow", so you only need to put the texture and overrides.

{
    "parent": "item/bow",
    "textures": {
        "layer0": "modid:items/example_bow"
    },
    "overrides": [
        {
            "predicate": {
                "pulling": 1
            },
            "model": "modid:item/example_bow_pulling_0"
        },
        {
            "predicate": {
                "pulling": 1,
                "pull": 0.65
            },
            "model": "modid:item/example_bow_pulling_1"
        },
        {
            "predicate": {
                "pulling": 1,
                "pull": 0.9
            },
            "model": "modid:item/example_bow_pulling_2"
        }
    ]
}
Last seen on 03:52, 28. Jul 2023
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I don't understand. I did…
Sat, 10/01/2022 - 23:14

I don't understand. I did everything right but I keep getting this error.

MCreatorWorkspaces\animm\src\main\java\net\mcreator\animm\ModItemProperties.java:9:

error: cannot find symbol import net.mcreator.animm.ModItemProperties;

 

 

 

Last seen on 03:52, 28. Jul 2023
Joined Feb 2021
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Also can you give a example…
Sat, 10/01/2022 - 23:19

Also can you give a example workspace to download?

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
@Yuudachi thanks, I made…
Sun, 10/02/2022 - 14:09

@Yuudachi thanks, I made some personal errors on this tutorial which I will fix. Thanks for your suggestions!

Last seen on 01:17, 31. May 2023
Joined Oct 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Before any one ask. Yes this…
Mon, 10/17/2022 - 22:33

Before any one ask. Yes this also works for 1.19

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for saying it, I'll…
Wed, 10/19/2022 - 19:29

Thanks for saying it, I'll change the title so it says 1.19 too.

Last seen on 03:37, 10. Dec 2022
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
First of all I would like to…
Wed, 11/02/2022 - 19:47

First of all I would like to say thank you for making an updated version to this tutorial as I was previously attempting to update the 1.16 version I saw floating around. 

 

I believe I have followed the steps to the very word however I get one error of "package weaponbuddy(my MODID) does not exist". I've attempted to play around with the package name a bit to fix this without any luck. Also if I were to add "net.mcreator.weaponbuddy.itemid" I just get an error that the last period is a unknown symbol. Attached are images of the file the error derives from as well as the error code with just "weaponbuddy.ITEMID" inputed as shown in the ModItemProperties.java image labaled below. .  

 

ModItemProperties.java code file:

Error:

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Replace "weaponbuddy" with …
Thu, 11/03/2022 - 19:45

Replace "weaponbuddy" with (YourModName)ModItems. To check if you have the correct name on the left using the file browser go to "Source/net/mcreator/mod_name/init" and find the file that ends with "ModItems". That's the one you want to use.

Last seen on 03:37, 10. Dec 2022
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Okay cool I've got that…
Thu, 11/03/2022 - 19:55

Okay cool I've got that sorted now, but in game I don't see the sequence of textures that were added. However, this has made the arrows I've shot a collectable item which is amazing. Do I need to make a custom model of each texture within block bench to fix this? I don't see any errors in console during runtime so I'm not sure what to try next.

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
You're sure you did the json…
Thu, 11/03/2022 - 20:08

You're sure you did the json files right?

Last seen on 03:37, 10. Dec 2022
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I believe so, attached are…
Thu, 11/03/2022 - 21:07

I believe so, attached are my 

  • Iron_bow.json, 
  • iron_bow_pulling_0.json,
  • iron_bow_pulling_1.json, 
  • iron_bow_pulling_2.json

files in that order. 

 

Iron_bow.json

 

Iron_Bow_Pulling_0.json

 

iron_Bow_Pulling_1.json

 

Iron_Bow_Pulling_2.json

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

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Can you show me the log when…
Fri, 11/04/2022 - 18:55

Can you show me the log when you run the client?

Last seen on 03:37, 10. Dec 2022
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Here are my latest logs…
Sat, 11/05/2022 - 18:17

Here are my latest logs which after some fiddling I've found this collection of errors.

11:12.36 [Worker-Main-11/WARN] [minecraft/ModelBakery]: Unable to load model: 'weapon_buddy:iron_bow' referenced from: weapon_buddy:iron_bow#inventory: java.io.FileNotFoundException: weapon_buddy:models/iron_bow.json
11:12.37 [Worker-Main-11/WARN] [minecraft/ModelBakery]: Unable to resolve texture reference: #missingno in weapon_buddy:item/iron_bow_pulling_0
11:12.37 [Worker-Main-11/WARN] [minecraft/ModelBakery]: Unable to resolve texture reference: #missingno in weapon_buddy:item/iron_bow_pulling_1
11:12.37 [Worker-Main-11/WARN] [minecraft/ModelBakery]: Unable to resolve texture reference: #missingno in weapon_buddy:item/iron_bow_pulling_2

 

Latest Log:

https://www.dropbox.com/s/4jsliwkmsp4xugh/latest.log?dl=0