#help with crossbow shooting wind charges
1 messages · Page 1 of 1 (latest)
<@&1201956957406109788>
💬 While you wait, take this time to provide more context and details.
🙇 If nobody has answered you by <t:1722696222: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
What version are you on?
1.21
the first underline is because thats the old syntax for items and the second one is because fill is used for blocks and not entities (wind charges are entities)
do you already have a command to give yourself the custom crossbow? or anything else?
in a command block yes, i used the mcstacker website
but somehow /function doesnt work on the exact same command
so im getting the crossbow only trough command blocks
function commands cant have a / infront, that may be the issue
but anyway, can you send the command for the crossbow?
because thats the thing we check for - its easier to see what we have first ^^
(you could have just copy pasted it but yea)
omg sorry true
lmao
give @s crossbow[custom_name='{"bold":true,"color":"dark_aqua","text":"Kuše odfukovače"}',lore=['"Legendy praví, že tuto kuš vyrobili pradávní Breezové"'],unbreakable={},custom_model_data=1,enchantments={levels:{"minecraft:quick_charge":1,"minecraft:multishot":10}},enchantment_glint_override=true] 1
apologies :D
all g :D
you could add custom_data={my_custom_tag=1b} or something, thats better to check than the model
but you can also keep it like this if you want to
also, checking for a custom item in your hand in 1.21 can be done a lot simpler and better using execute if items
execute if items entity <entity> <slot> <item_type>[<item_predicate>] run ...
hold up i need to let all this new info sink in
im still new in datapacks, i started like 4 hours ago lol
i tried replacing the *,custom_model_data=1 * with custom_data={my_custom_tag=1b} and i got an error
oh yea, it should be custom_data={my_tag:some_value}
and you mean i should replace this execute at @a[nbt={SelectedItem:{id:"minecraft:crossbow",tag: {custom_model_data:1}}}] run tag @e[type=arrow,distance=..1] add wind_arrow with this execute if items entity <entity> <slot> <item_type>[<item_predicate>] run ...? ofc after applying the changes to make the arrow a wind arrow
the : inside of the thing since it's snbt, similar to json
oh okay thanks that fixed it
if you use ` in front and back you can make these funky code blocks
oh okay, didnt know that
yea, instead of checking nbt directly you can check the players items
named binary tags, thats the thing mc uses to store stuff
and snbt is stringified named binary tags, the representation of that stuff to be human readable (binary data is not very readable ^^)
okay thanks, ill try applying this execute if items entity <entity> <slot> <item_type>[<item_predicate>] run ...
damn funky thing didnt work
oh yeah got it
There you go
saw it
you are missing a crutial step in your current implementation aswell, checking for firing the arrow
right now you are tagging all arrows when you are holding a custom crossbow
to achieve this:
- in your load function create a scoreboard with the
used:minecraft.crossbowcriteria, this gets increased by 1 each time you shoot a crossbow - in your tick function, check if that score increases, then run a different function for all players whose score increased
- in that function reset the score
- in that function check if the player has the custom and tag all surrounding arrows
try making the command in game the auto complete is very good
you might not even need a new function actually but the idea is still the same
okay
Also the wiki page explains what all the slots do: https://minecraft.wiki/w/Slot#Command_argument
execute if items entity @a weapon minecraft:crossbow summon minecraft:arrow run tag @e[type=arrow,distance=..1] add wind_arrow
did i do it right? will it make the fired arrow tagged as a wind arrow?
That's not quite right
execute if items entity @a will just check if any players have that item
And it won't set the correct position
oh that makes sense because it just did something ingame but not what it was supposed to do
yes exactly
that happened :o
im so flabbergasted rn
What you really want is execute as @a at @s if items entity @s weapon (The rest is the same)
That executes the command as each player individually, check if @s, the current player, has that item, and also sets the execution position to that of the player
WOAH
now there are arrows spawning instantly under me and it nearly crashed my game
okay and it only happens when im holding a crossbow
i thought it is like, if crossbow summons an arrow it will be a wind arrow
Right,but at the moment you're summoning an arrow at every player who has the crossbow in their hand