Minecraft Data Packs / Weapons and Armor

Custom Arrows (MAP MAKING TOOL)

  • check_circle Functions
  • check_circle Predicates
  • 1,116 views, 12 today
  • 66 downloads, 0 today
  • 2
  • 0
  • 7
Croesus avatar Croesus
Level 41 : Master Architect
56
A custom arrow datapack with customizable arrow hit events, arrow kill events, including death messages! Meant for a PvP environment, will not work on mobs.

This datapack was created for Arqade user EarthToAccess.

HOW TO ADD CUSTOM ARROWS?

In this datapack, there are 2 custom arrow examples. You will need to edit the datapack to add your own.

The relevant files are located in:EarthToAccess Custom Arrows/data/custom_arrows/functions/You will see 2 example arrows: the sniper arrow, and the silverfish arrow.

Custom arrows all use tipped arrows of Luck. To differentiate each arrow, you need to change the Luck amplifier (I, II, III, IV, etc.). The sniper arrow uses Luck I, and the silverfish arrow uses Luck II.

Each new arrow you add, you must add the new arrow into arrow_hit.mcfunction and arrow_kill.mcfunction. You must also create 2 new .mcfunction files, one for the actions that occur when the arrow hits a player and one for the actions that occur when the arrow kills a player.
CompatibilityMinecraft 1.17
Tags

Create an account or sign in to comment.

1
07/07/2021 12:45 pm
Level 1 : New Miner
EarthToXIV
EarthToXIV avatar
Thank you so much for the datapack! Seeing such a fleshed out answer threw me off-guard at first, lmao

so as I'd mentioned in the Arqade post (you can find that here if you want), there were a few things I wanted to talk about here that I couldn't necessarily do there. They're primarily nitpicks that can either cause misconception or issues, for myself or others, so I wanted to at least bring them up.

First thing; in Issue 4, you mentioned my motion scores. I did include those scores in my commands, as I said with "scoreboards (vx, vy, vz) to find". There's no real reason for me to point this out other than transparency, but I figured I'd mention it regardless just to cover everything.

Next, I'm not quite sure how the datapack is finding the arrow's "owner". I'm assuming it involves the scoreboard values of deaths and player_kills, but I'm not entirely sure -- and if that is the case, that sounds very error-prone for what is supposed to be a multiplayer PvP map. Could there be a way to, potentially, apply a dummy NBT tag to the "marker" that matches even only one UUID integer (as you said, likely UUID and Owner's fourth value) for comparison's sake? I don't know if that would potentially break other parts of the pack, though.

Finally, I have a concern about the marker's ability to scan for players. In the passenger detection video you linked, using it with finding a snowball's placement was simple, as it was just getting the effect cloud center's location and setting a block at it. In this event, wouldn't the area effect cloud detect players if the arrow simply hits the ground? Or would the "kill if neither _hit nor _kill fire" function stop that? Or, regardless of all that, do I have the way the marker cloud works wrong and that's a non-issue entirely?

Regardless, I really do appreciate the work you did on this; you can't possibly imagine how grateful me and my ADHD brain are for this all!
1
07/07/2021 2:15 pm
Level 41 : Master Architect
Croesus
Croesus avatar
No thanks necessary, I like to help others out :D


Next, I'm not quite sure how the datapack is finding the arrow's "owner". I'm assuming it involves the scoreboard values of deaths and player_kills, but I'm not entirely sure -- and if that is the case, that sounds very error-prone for what is supposed to be a multiplayer PvP map. Could there be a way to, potentially, apply a dummy NBT tag to the "marker" that matches even only one UUID integer (as you said, likely UUID and Owner's fourth value) for comparison's sake? I don't know if that would potentially break other parts of the pack, though.

The datapack finds the arrow's owner by checking for any player with a score of 1.. in objective player_kills. This somewhat reliably finds the killer and the victim, because at the end of the tick, the scores are reset. This means that it is ready to detect a new killer and a new victim. But you are right, this is quite error-prone, as if 2 players are killed in the exact same tick (1/20th of a second), the killers/victims could get mixed up.

I am aware that the fired arrow does carry an Owner tag, and that could be used to find the killer with 100% accuracy. Why didn't I do this? Well, not for any good reason... it was just easier to use the scores. I took the easy way out lol. If I have some time, I might update the datapack to utilize the Owner tag.

Finally, I have a concern about the marker's ability to scan for players. In the passenger detection video you linked, using it with finding a snowball's placement was simple, as it was just getting the effect cloud center's location and setting a block at it. In this event, wouldn't the area effect cloud detect players if the arrow simply hits the ground? Or would the "kill if neither _hit nor _kill fire" function stop that? Or, regardless of all that, do I have the way the marker cloud works wrong and that's a non-issue entirely?

When the arrow hits the ground, unlike a snowball, the arrow does not disappear. The arrow only disappears when it hits an entity or despawns; this will cause the marker entity to dismount. This is checked for in both line 2 and line 4, where the predicate check is used to see if any marker entities are not riding an arrow. But in line 2, there is another check that executes if there was a player who died in the same tick:execute as @e[type=marker,tag=arrow_rider,predicate=!custom_arrows:is_riding_arrow] if entity @a[scores={deaths=1..,killed_by_player=1..}] at @s run function custom_arrows:arrow_killIf there was another player who died in the same tick, the marker entity assumes the player who died was the one who was hit by the arrow. Then, the marker entity is killed.

Line 4 performs the same check, checking for any dismounted marker entities. But, it doesn't check for any dead players. This is because line 4 correctly assumes that if line 2 was successfully run, then the marker entity should have been killed. But if it survived to reach line 4, then the only explanation is that the arrow hit a block and despawned, which is the only other reason for a dismount. If this happens, then the marker entity is killed anyways to prevent trouble:
execute as @e[type=marker,tag=arrow_rider,predicate=!custom_arrows:is_riding_arrow] run kill @s
Hope you understand a little better now! If you have any other questions, ask away :)
1
07/07/2021 7:52 pm
Level 1 : New Miner
EarthToXIV
EarthToXIV avatar
I do have one last question, specifically about the silverfish arrow. In its hit file, you specify "this will spawn a ton so make its duration short". How would one do that?
1
07/07/2021 8:12 pm
Level 41 : Master Architect
Croesus
Croesus avatar
You can just use a command generator like https://mcstacker.net/. Keep in mind that you need to modify CustomPotionEffects, not Potion. This is also where you set the arrow's luck amplifier.
1
07/07/2021 9:55 pm
Level 1 : New Miner
EarthToXIV
EarthToXIV avatar
I'm not sure if I follow; are you saying the duration of CustomPotionEffect is what determines how long the summon command fires for?
1
07/08/2021 9:57 am
Level 41 : Master Architect
Croesus
Croesus avatar
Yes. Take a look at this line in main.mcfunction:
execute as @a[nbt={ActiveEffects:[{Id:26b}]}] at @s run function custom_arrows:arrow_hitAs long as the player has the effect, they will activate the arrow_hit function every tick. You can avoid this and only have it activate once by clearing the Luck effect from the player in the arrow's sub function.
Planet Minecraft

Website

© 2010 - 2021
www.planetminecraft.com

Welcome