#How to make a arrow explode from a specific named bow

1 messages · Page 1 of 1 (latest)

flat citrusBOT
#

Hello there, i am a really beginner scripter, basically just finished the datapack blog and i was just trying to challange myself. How can i make the arrow explode from a specific named bow? i dont want them to explode from every shot arrow
this is my code for context

execute as @e[type=arrow,nbt={inGround:1b }] at @s run summon tnt
execute as @e[type=arrow,nbt={inGround:1b}] at @s run kill @s
gray sorrelBOT
#

<@&1201956957406109788>

Someone will come and help soon!

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

                        🙇 After a while, hit the Summon Helpers button to ping the helper team. They'll be happy to help you


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

I'm pretty sure @hybrid breach has a tutorial on exactly this, hang on

hexed willow
#

oh sorry didnt know what the summon helpers button meant

thorn panther
#

You're fine, you didn't press it

#

We get pinged when threads are created; it's what we're here for!

hexed willow
#

is it on youtube or on a forum

thorn panther
#

I don't actually know, I just know they've mentioned it

#

Trying to hunt it down for you

hexed willow
#

lol thanks

thorn panther
hexed willow
#

oh really

#

i really am blind

primal lodge
thorn panther
#

Well it looks like the blog just goes as far as you've got

primal lodge
#

tho it should be in /resources

primal lodge
hexed willow
#

where is it though?

primal lodge
#

rune talked abt it earlier and sent the same link

thorn panther
#

It sounds like you have the explosions down, but now you want to make it only work for specific bows, is that correct?

hexed willow
#

yeah that is correct

thorn panther
#

Gotcha, so to do that, you'll need to create that specific bow. You can give it a custom name, but what's more important/easier to work with is it's custom data. What Minecraft version are you developing in?

hexed willow
#

prettu sure 1.20.4

#

ill check

#

yep

#

1.20.4

thorn panther
#

OK, so then you can do a command like this
/give @s bow{exploding_bow:1b}

Then, you'll follow these steps:

  1. Run a command in your tick function as and at all players holding that bow, that adds a tag to all nearby arrows, such as exploding_arrow
  2. Change the commands you currently have that run as and at all arrows, to also check if they have that exploding_arrow tag.

There are small things you can do in a couple different ways for both of these steps, and it's not a detailed tutorial, just explaining what the steps are

hexed willow
#

OK, thanks ill try to add the nbt tag and then test for it. How do i add the tag exploding_arow to the arrow?

thorn panther
#

With the tag command 🙂

coarse owlBOT
#
📜 /tag

tag <targets> add <name>

Adds a tag to the targets.

tag <targets> list

Lists all tags on the targets.

tag <targets> remove <name>

Removes a tag from the targets.

hexed willow
#

ill try to do it and then ill ask if i get stuck

flat citrusBOT
#
execute as <player> at @s run tag @e[type=arrow,distance=0..10] add exploding_arrow
hexed willow
#

thank you

#

Hey! i was coding and this is what i have made :


execute as @a[nbt={SelectedItem:{id:"minecraft:bow", tag:{display:{Name:'{"text": "Boom Bow"}'}}},}] run tag @e[type=arrow,distance=..10] add exploding_arrow

execute as @e[type=arrow,nbt={inGround:1b,item:{tag:{exploding_arrow:1b}}}] at @s run summon tnt

execute as @e[type=arrow,nbt={inGround:1b,item:{tag:{exploding_arrow:1b}}}] at @s run kill @s

and it doesnt seem to work. Doesnt explode with named bow neither with unnamed

#

also how do u add the mcfunction syntax to the code

primal lodge
#

```mcf
<code>
```

hexed willow
#

oh ty

gray sorrelBOT
# gray sorrel <@&1201956957406109788>

<@&935561184806060073> <@&1202694677766348840>

**🙇 Helpers Arise!**

Please note that you still might not immediately get a response since all helpers are human beings and volunteers (and also might be sleeping right now)

primal lodge
#

it's not the item tag you have to check

#

it's the entity tag

flat citrusBOT
#
kill @e[type=arrow,tag=exploding_arrow,nbt={inGround:1b}]
primal lodge
#

(idk if inGround is correct)

hexed willow
#

It has to be

#

It was working before

primal lodge
#

well then

#

yeah

primal lodge
#

idk I feel it should be OnGround but if it worked before sure

hexed willow
#

I mean i will fix that but the tnt isnt spawning at all

primal lodge
#

maybe it's specifically for arrows

hexed willow
#

Could the problem be that i didnt say where it should run?

primal lodge
#

no, you did say at @s

hexed willow
#

Not at the first line

#

so can anybody help?

flat citrusBOT
#

execute as @a[nbt={SelectedItem:{id:"minecraft:bow", tag:{display:{Name:'{"text": "Boom Bow"}'}}},}] at @s run tag @e[type=arrow,distance=..10] add exploding_arrow
execute as @e[type=arrow,nbt={inGround:1b,item:{tag:{exploding_arrow:1b}}}] at @s run summon tnt
execute as @e[type=arrow,nbt={inGround:1b,item:{tag:{exploding_arrow:1b}}}] at @s run kill @s
winter onyx
winter onyx
hexed willow
#

i finished the guide

#

i have said what i wanted to do at the top

#

^^^

winter onyx
#

ohh only for specific bow

hexed willow
#

yep loop.mcfunction

#

which is valued as tick

#

in tick.json

winter onyx
#

ew, is that what the blog on datapack hub pmc had?

hexed willow
#

what exactly ;D

winter onyx
#

ok nevermind

winter onyx
hexed willow
#

alright no problem

winter onyx
#

ok so the sequence of actions should go like

#
  1. check when player shoot from a bow
  2. check if that bow is special
  3. make the arrow go boom
hexed willow
#

ooh

#

so this whole time i was doing it wrong

winter onyx
#

well sort of, yeah

hexed willow
#

pretty sad

winter onyx
#

now if you just erase alll the code you have in tick and load functions (i assume you dont have any other functions, right? )

hexed willow
#

riiiight

#

i do have the function where it gives the bow

winter onyx
#

can you just paste it in here

hexed willow
#

ok ill just paste everything

winter onyx
#

so i can see whats inside

#

so erase everything except the give function ig

#

we'll start from blank tick and load functions

flat citrusBOT
#

load.mcfunction

tellraw @a {"text": "My code is big fat load", "color": "#0000FF"}

loop.mcfunction

i erased everything

test.mcfuntion

give @s bow{display:{Name:'{"text": "Boom Bow"}'}}

tick.mcf
nothing

hexed willow
#

same as loop

winter onyx
#

why would you have two loops

hexed willow
#

no idea bro

winter onyx
#

nah remove one of them ok

hexed willow
#

i was lazy to delete it ig

#

alright ill write the code in tick.mcf

#

cause its the same as loop

winter onyx
#

also what version are you on?

hexed willow
#

1.20.4

winter onyx
#

ok thats nice

flat citrusBOT
#
give @s bow{display:{Name:'{"text": "Boom Bow"}'}, boombow:1b}
winter onyx
#

first i want you to add this little custom data in the give function

hexed willow
#

the mcf highlight doesnt work on me :(

#

alright done

flat citrusBOT
#

now in the load function we should create a new scoreboard, should be like this

scoreboard objectives add shoot_bow used:bow
hexed willow
#

oh no

winter onyx
#

what

hexed willow
#

i dont know anything about scoreboards

#

should i just learn that instead?

winter onyx
hexed willow
#

alright

#

pasted btw

winter onyx
#

im gonna explain it really briefly, when you shoot from a bow this scoreboard will increment for the player who used the bow, thats how we know you shot an arrow

flat citrusBOT
#

so now in tick function you go
tick

execute as @a if score @s shoot_bow matches 1.. at @s run namespace:shoot_bow
winter onyx
#

this will check if a player has one or more points in the shoot_bow scoreboard, which would mean he shot an arrow

hexed willow
#

namespace shootbow is red forsamreaosn

winter onyx
hexed willow
winter onyx
hexed willow
#

oh

#

it is called shoot_bow tho

winter onyx
#

what is

hexed willow
#

the scoreboard objective

#

that we added

winter onyx
#

yeah

#

namespace is a folder under the data folder

#

ownera

#

so you shoudl call instead function ownera:shoot_bow

hexed willow
#

OH

winter onyx
#

yeah

hexed willow
#

i was changing the shoot_bow to ownera 🤦‍♂️

#

is this something i gotta worry about?

winter onyx
#

not at all

#

its good

hexed willow
#

alright

winter onyx
hexed willow
#

which is

winter onyx
#

just add if data entity @s SelectedItem.tag.boombow before the run keyword in the execute command you just pasted

winter onyx
#

you there

hexed willow
#

like this?

winter onyx
#

yes!

#

ok now in ownera/functions/ create a shoot_bow.mcfunction

hexed willow
#

alright

#

done

winter onyx
hexed willow
#

yess

#

but why stop there

#

create a nuke and bombard the whole serrver

flat citrusBOT
#

in the shoot_bow function type this

execute as @e[type=arrow, distance=..2, limit=1, sort=nearest] run tag @s add boom_arrow
winter onyx
#

that will put a tag on the arrow that was shoot from the specific boom bow

hexed willow
#

what does sort-nearest do

winter onyx
#

it basically gives a tag to one arrow that is within 2 blocks and the nearest / closest to the player

hexed willow
#

oh

#

nice

flat citrusBOT
#

if we put tag on it, we can track the arrow later on, so now go back to tick function, and go

execute as @e[type=arrow,tag=boom_arrow,nbt={inGround:1b}] at @s run function ownera:boom

and this will track arrow that was shot from our boombow, and if the arrow got stuck in a block then we run the boom function, now in boom function you go
boom

summon tnt
kill
winter onyx
#

next step, save all files, type /reload in game, give yourself a brand new bow via the give function AGAIN, then pray and hopefully everything works first try

hexed willow
#

i dont have a boom function lol

winter onyx
hexed willow
#

makes sense

winter onyx
#

just like the last time, in ownera/functions add boom.mcfunction

hexed willow
#

ooop

#

it dont worke

winter onyx
#

so

#

what happens

hexed willow
#

nothing

#

ill send the mcfs

#

boom.mcf

summon tnt
kill

load.mcf

tellraw @a {"text": "My code is big fat load", "color": "#0000FF"}

scoreboard objectives add shoot_bow used:bow

shoot.mcf

execute as @e[type=arrow, distance=..2, limit=1, sort=nearest] run tag @s add boom_arrow

test.mcf

give @s bow{display:{Name:'{"text": "Boom Bow"}'}, boombow:1b}

tick.msf

execute as @a if score @s shoot_bow matches 1.. at @s if data entity @s SelectedItem.tag.boombow run function ownera:shoot_bow
execute as @e[type=arrow,tag=boom_arrow,nbt={inGround:1b}] at @s run function ownera:boom
winter onyx
#

uh okay

#

are you sure you gave yourself the bow via the function again? because we changed that function

hexed willow
#

oh

#

i gave myself the bow but it still doenst work 🤔

winter onyx
#

oh, thats weird, what comes up when you type /data get entity @s SelectedItem.tag in chat while holding the special bow

hexed willow
winter onyx
#

oooh i think i know what happened

hexed willow
#

im listerin

winter onyx
#

basically, in shoot.mcf add this on a new line: scoreboard players reset @s shoot_bow, so that it resets itself

and also change SelectedItem.tag.boombow in the tick function to SelectedItem.tag{boombow:1b}

hexed willow
#

where exactly do i add those

#

in the code

winter onyx
#

does that seem more clear

hexed willow
#

yes

#

well

#

it

#

is

#

not

#

working

#

i seriously drained you today

#

i think i should learn to do something easier

winter onyx
#

fudge no we invested too much time in this lets put this to end, can you put say hello on a new line in shoot.mcf and then send all the mcfs

#

we're almost there

hexed willow
#

ok

#

nothing when i shoot the bow

#

oh send all mcfs

#

ownera:shoot made it say hello

#

ownera:boom made me die in creative

winter onyx
#

WAIT REALLY?

#

ok thats cool

#

ok thats

hexed willow
#

the bow is too powerful to be made

winter onyx
#

impossible

hexed willow
#

wel

#

i guess

#

it is

winter onyx
#

you cant die because the function can only be ran from arrow... lol

hexed willow
#

i ran it myself

winter onyx
#

oh, ok

#

why

#

ok so if you just shoot the bow, nothing happens, right?

hexed willow
#

yep

winter onyx
#

what if you just run
execute if data entity @s SelectedItem.tag{boombow:1b} in chat while holding the special bow

hexed willow
#

ill try

#

Test passed

winter onyx
hexed willow
#

count : 1

winter onyx
#

OOHHHHHH

#

I GET IT NOW

#

give me a moment

hexed willow
#

i already gave this challanage 2.5 hours i have nothing to lose 🫡

winter onyx
#

whoaaaaaa

hexed willow
#

havent even been alive for that long

winter onyx
#

can you just send all of the functions in here in discord

hexed willow
#

alright

#

boom

#

summon tnt
kill

#

load

#

tellraw @a {"text": "My code is big fat load", "color": "#0000FF"}

scoreboard objectives add shoot_bow used:bow

#

shoot

#

execute as @e[type=arrow, distance=..2, limit=1, sort=nearest] run tag @s add boom_arrow
scoreboard players reset @s shoot_bow
say hello

#

test
give @s bow{display:{Name:'{"text": "Boom Bow"}'}, boombow:1b}

#

tick
execute as @a if score @s shoot_bow matches 1.. at @s if data entity @s SelectedItem.tag{boombow:1b} run function ownera:shoot_bow
execute as @e[type=arrow,tag=boom_arrow,nbt={inGround:1b}] at @s run function ownera:boom

winter onyx
#

alright

#

ill try to debug it myself ig

hexed willow
#

not me doing my angular project while doing this 🗿

winter onyx
#

lol

winter onyx
hexed willow
#

shoot

#

oh no

#

IOT WORLS

#

IT WORKS

#

but it doesnt kill creative players :>

#

jk

#

but thank you bro

#

we've been doing this for 2 hours now

#

or 1.5

#

eah 1.6

#

1.5

#

hours

#

damn

#

i can finally close this case

winter onyx
#

wait

#

also

#

to understand scoreboards, heres a good video on it!
https://youtu.be/-5EmWJguggA

In this video, I'll show you the best things to do with the /scoreboard command! How to make a deaths/kills counter, how to count all entities, or how to make a health display! This tutorial is working in Minecraft 1.18! If you have any questions about the scoreboard command, feel free to ask in the comments!

Scoreboard Criteria List [ https://...

▶ Play video
#

now you can close it

hexed willow
#

thank you

winter onyx
#

happy coding ig, pay more attention to everything please, naming a function differetn name is crazy lol

gray sorrelBOT
# gray sorrel <@&1201956957406109788>
Question Closed

Your question, #1233813319199101089 (How to make a arrow explode from a specific named bow), was resolved!

Original Message

#1233813319199101089 message

Duration open

2h34m

hexed willow
#

2.5 hours 😭

gray sorrelBOT
hexed willow
#

NO