#(archery datapack) Need help changing physics and damage attributes of custom arrows

1 messages · Page 1 of 1 (latest)

safe kelp
#

hello! i am new to making datapacks and new to working in java in general. as a little bit of practice i started by making a recipe tweak for arrows (crafted with cobble instead of flint) and a custom "gold arrow" (crafted with gold ingot instead of flint). I was able to get these custom recipes to work as well as adding a custom name (Gold Arrow) to the arrows crafted using gold, but thats as far as i got with it and I want to add some more unique behavior for the gold arrows

while i want the regular arrow to function the same as vanilla, my design idea and dream for this gold arrow is to:

1. do less damage than regular arrows (do maybe 4 damage with a bow compared to the vanilla arrows 6)

2. fly in a straight line when shot in the direction you are aiming so it doesnt fall/have-a-downward-trajectory when shot (similar to jester arrows in terraria how they arent affected by gravity)

this is the current file structure i have for the datapack:

<gold_arrow_test>/
├── data/
│ └── minecraft/
│ ├── recipes/
│ │ ├── arrow.json
│ │ └── gold_arrow_recipe.json
│ └── tags/
│ └── items/
│ └── gold_arrow.json
└── pack.mcmeta

(all of the included json files are in the file sections of this post)

I understand that what im trying to do is probably very complicated especially for what im qualified to do, but i would greatly appreciate some guidance on where i can start to add the proper functions/code and file structure i need for it to behave the way im envisioning. (also if u see something that looks off about my current code or file structure please tell me because im kinda going at this blind lol)

thank you so much for reading this and i will love you forever if you can help me get on the right track with this project!

sand juncoBOT
#

<@&1201956957406109788>

Someone will come and help soon!

💬 While you wait, take this time to provide more context and details.

🙇 If nobody has answered you by <t:1742696554:t>, feel free to use the Summon Helpers button to ping our helper team.

✅ Once your question has been resolved (or you no longer need it), please click Resolve Question or run /resolve

stuck merlin
#

What do you have an item tag for?

safe kelp
#

I was just about to add a little note to this because i just realised i left that in there (as well as the damage component in the recipe for the gold arrow). i honestly dont know what the tag would be used for but it was something that stupid chat gpt recommended to add. however ai obviously failed to help because the item tag as well as the tag referenced in the recipe seem to not be functional

stuck merlin
#

Yeah don't use AI for data packs

#

And the damage item component has to do with damage on the item, as in durability, not how much damage it deals

stuck merlin
safe kelp
stuck merlin
#

When it comes to what you want to do, it should be possible, but will require functions and possibly some compromises

#

Basically you'll need to run a function every tick that is executed as all arrow entities, that then checks which arrow item it was when it got shot (using execute if items) and performs the desired effects.

For reducing the damage they deal, we have somewhat limited control of this, but not no control. You'll use a data command to modify it's damage NBT, which defaults to 2.0. This isn't a strict amount of damage it deals, it's just a multiplier, but it's all we have access to.

Making an arrow fly straight without falling is easy, just need to use the data command again to set it's NoGravity NBT to 1b, aka true. It'll still have some random offset to the left, right, up, and/or down, but it won't fall or I believe even lose momentum.

safe kelp
#

i see that makes alot of sense. and a damage mulitplier is exactly what i want so that should be just fine. but if u dont mind how would i end up modifying the "data" command? as in where would these functions be located within my current file structure? and would it be a .mcfunction file?

stuck merlin
#

It is a .mcfunction file, they are put in data/<namespace>/functions in pre-1.21

#

It's good practice to not put things in the minecraft namespace (aka parent folder) unless you're specifically overwriting a vanilla file, which none of these are. You will however need a file in data/minecraft/tags/functions called tick.json, which should reference your ticking function file. That'll make it run every tick

#

And you don't modify the data command, you use the data command to modify the NBT of an entity

safe kelp
#

ok thank you so much im going to resolve this post for now, and if i need some more help ill open up another post when needed. thank you so much for the help you are the GOAT!!