#help with crossbow shooting wind charges

1 messages · Page 1 of 1 (latest)

subtle osprey
#

guys anyone please help, im new at making datapacks and im legit STRUGGLING to do anything, WHY ARE THERE 2 THINGS UNDERLINED YELLOW? please make it work, i want to make a crossbow shoot ¨wind arrows¨ and those arrows make a wind charge on impact

hybrid remnantBOT
#

<@&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: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

native snow
#

What version are you on?

subtle osprey
#

1.21

eternal sentinel
#

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)

subtle osprey
#

oh

#

any ideas on how to solve it?

eternal sentinel
#

do you already have a command to give yourself the custom crossbow? or anything else?

subtle osprey
#

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

eternal sentinel
#

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 ^^

subtle osprey
#

it has 2 parts sry, idk how to make it one

#

the line is too long in other words

eternal sentinel
#

(you could have just copy pasted it but yea)

subtle osprey
#

omg sorry true

eternal sentinel
#

lmao

subtle osprey
#

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

eternal sentinel
#

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 ...

subtle osprey
#

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

eternal sentinel
#

oh yea, it should be custom_data={my_tag:some_value}

subtle osprey
#

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

eternal sentinel
#

the : inside of the thing since it's snbt, similar to json

subtle osprey
eternal sentinel
#

if you use ` in front and back you can make these funky code blocks

subtle osprey
#

oh okay, didnt know that

eternal sentinel
#

yea, instead of checking nbt directly you can check the players items

subtle osprey
#

okay i think i get it kinda

#

also what does nbt mean?

#

like what its short for

eternal sentinel
#

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 ^^)

subtle osprey
#

okay thanks, ill try applying this execute if items entity <entity> <slot> <item_type>[<item_predicate>] run ...

#

damn funky thing didnt work

stark heath
#

It's a backtick: `

#

Not a quote

subtle osprey
#

oh yeah got it

stark heath
#

There you go

subtle osprey
#

saw it

eternal sentinel
#

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

subtle osprey
#

im so lost rn

#

what to put in <slot>

eternal sentinel
#

to achieve this:

  1. in your load function create a scoreboard with the used:minecraft.crossbow criteria, this gets increased by 1 each time you shoot a crossbow
  2. in your tick function, check if that score increases, then run a different function for all players whose score increased
  3. in that function reset the score
  4. in that function check if the player has the custom and tag all surrounding arrows
eternal sentinel
#

you might not even need a new function actually but the idea is still the same

stark heath
subtle osprey
#

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?

stark heath
#

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

subtle osprey
#

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

stark heath
#

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

subtle osprey
#

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

stark heath
#

Wait why are you summoning an arrow?

#

That will be why

subtle osprey
#

i thought it is like, if crossbow summons an arrow it will be a wind arrow

stark heath
#

Right,but at the moment you're summoning an arrow at every player who has the crossbow in their hand

subtle osprey
#

yeah

#

can i like check if the player shot from a crossbow

stark heath
#

Yeah, in a couple of ways

#
  1. An advancement
  2. A custom enchantment
subtle osprey
#

i did this
execute as @a at @s if items entity @s weapon.mainhand minecraft:crossbow[minecraft:custom_model_data=1] run tag @e[type=arrow,distance=..1] add wind_arrow

#

and it works rn but the wind charges dont blow up

#

you have to click on them to blow up