Custom arrows in 2024.3 - Tutorial

Started by DerpPickles on

Topic category: User side tutorials

Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Custom arrows in 2024.3 - Tutorial
Sun, 01/26/2025 - 20:00 (edited)

(Used and tested for MCreator 2024.3 only, no guarantees it will work in the future)

This tutorial was largely based off of https://mcreator.net/forum/102341/how-make-custom-arrows-tutorial, with some tweaks for 2024.3 and some additional info

 

1. Create an Item game element. Set its properties, triggers, and whatnot now, because changing it later will be more difficult.

2. Create a Projectile game element. If you want the vanilla arrow model, set the model to something that's not Default anyways as this will generate the Renderer file for the element.

3. Lock the item element by using Right Click -> Lock/unlock mod element or the sixth (bottom-most) button in the workspace (it looks like a lock)

4. Go into the Item element's java file

4a. Add these imports, if they're not there already:

https://pastebin.com/dV62dFKJ 

Note that naming will differ, so use your mod / item / projectile's name when necessary.
If you're unaware of java syntax, anything starting with // is a comment, so you can leave those out.

4b. Add this method to the same file

https://pastebin.com/iG2HsZGW 
EDIT: the stack  should really be firedFromWeapon. You should have something like
return new TestProjectileEntity(CombatAddonsModEntities.TEST_PROJECTILE.get(), shooter, world, firedFromWeapon);

Explanation: this method is called by BowItem.java and CrossbowItem.java when accessing the entity to shoot. If invalid or not given, the entity will default to a vanilla arrow.

4c. Change the parent class from Item to ArrowItem.

public class TestItem extends ArrowItem

Explanation: BowItem.java and CrossbowItem.java will check if the given item stack is an child of ArrowItem. If not, the arrow entity will be default to a vanilla arrow.

Your item code should now look something like this:

https://pastebin.com/xYbfSBNT 

EDIT: see above edit

5. Go to Element Tags and add the item and projectile elements to their respective arrow tags. If the tags aren't already there, click on Add common tags -> Items / Entities -> minecraft:arrows. Also add the projectile to minecraft:impact_projectiles if applicable.
Explanation: (I think) this tells minecraft that the item element can be consumed as an arrow. I'm not sure what the entity tag does though.

6 (optional). To make the item able to be picked up from the ground, lock the projectile element and open its Entity java file. Delete the lines

if (this.inGround)
    this.discard();

from the tick method.

7 (optional). If you want a vanilla arrow model, lock the projectile element (if you haven't already) and go to the Renderer java file. Add

import net.minecraft.client.renderer.entity.ArrowRenderer;

and then change the parent class from EntityRenderer<> to ArrowRenderer<>

public class TestProjectileRenderer extends ArrowRenderer<TestProjectileEntity>

Then, delete the render method and the model variable. Free free to delete any unused imports. Your Renderer file should now look something like this:

https://pastebin.com/T9Y6nExQ 

Explanation: (I think) removing the render method lets minecraft use the default arrow model.

Make sure your custom texture matches the arrow model.

 

This should work? If it doesn't the issue is probably:
1. The names aren't changed to that of your mod elements
2. There is some missing import
3. I forgot something (very likely)

hopefully this was helpful!

Edited by DerpPickles on Sun, 01/26/2025 - 20:00
Joined Jul 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
THANK YOU SO MUCH!You saved…
Wed, 01/08/2025 - 01:35

THANK YOU SO MUCH!
You saved my project as I was planning to implement many custom arrows and I was completely lost on what to do.

I found a couple of other guides like this that all provided broken, janky, and incomplete code. They were trying their best, but either the update cycles got to them or something else.

This finally worked for me, in 1.21.1 NeoForge on Version 2024.4. I sincerely appreciate the time you took to form this post. I would not be able to finish my project without it.

Joined Oct 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It seems like your…
Sun, 01/26/2025 - 20:06

It seems like your FireworkarrowpjEntity class has no constructor with the types EntityType ,LivingEntity,Level,ItemStack. The issue could be that you're using a different version of MCreator where that constructor isn't supported, or that the file doesn't have the up-to-date code. I would suggest a few fixes:

1. Try switching to 2024.3 (or 2024.4) or higher and do the tutorial again (you have to regenerate the files, so that the code will update)
2. Remove the stack parameter, so that the line looks something like this:
return new FireworkarrowpjEntity(CrossbowModEntities.FIREWORKARROWPJ.get(), shooter, world);

If neither of those work, I could help you further if you gave me the version of MCreator that your version is running on. Also this has made me realize that stack should really be firedFromWeapon, and I've made the correction in the tutorial, though this shouldn't be the cause of your issue.