TransWikia.com

Replace empty crossbow with custom firwork loaded crossbow?

Arqade Asked by Someaznprsn on August 26, 2021

I’ve made a repeating command block that replaces an empty crossbow in your hand with one loaded with a rocket. Thus, when you shoot the crossbow it instantly replaces it and “loads” the crossbow for you.

/replaceitem entity @p[nbt={SelectedItem:{id:"minecraft:crossbow",tag:{Charged:0b}}}] weapon.mainhand crossbow{ChargedProjectiles:[{id:"minecraft:firework_rocket",Count:1b}],Charged:1b}

However I would like to replace the firework rocket with a custom one that explodes and not one that just fizzles out but I can’t seem to figure out how I would do that. Here is the firework I would like to charge the crossbow with:

minecraft:firework_rocket{Fireworks:{Flight:2,Explosions:[{Type:3,Flicker:1,Trail:1,Colors:[I;11743532],FadeColors:[I;15790320]},{Type:4,Flicker:1,Trail:1,Colors:[I;4312372,15790320]}]}}

I am not sure how to do this at all and any help would be appreciated.

One Answer

Like I wrote in my comment, the process is pretty similar to putting the item NBT into anything else. Except that in this case you already did most of the work. The only thing left is putting it into the "tag" tag:

/replaceitem entity @p[nbt={SelectedItem:{id:"minecraft:crossbow",tag:{Charged:0b}}}] weapon.mainhand crossbow{ChargedProjectiles:[{id:"minecraft:firework_rocket",Count:1b,tag:{Fireworks:{Flight:2,Explosions:[{Type:3,Flicker:1,Trail:1,Colors:[I;11743532],FadeColors:[I;15790320]},{Type:4,Flicker:1,Trail:1,Colors:[I;4312372,15790320]}]}}}],Charged:1b}

Also note that this command does not work before the first usage of the crossbow, because the Charged tag does not exist at all. To fix this, you can replace the selector with this one:

@p[nbt={SelectedItem:{id:"minecraft:crossbow"}},nbt=!{SelectedItem:{tag:{Charged:1b}}}]

Correct answer by Fabian Röling on August 26, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP