While adding a sound event using a resource pack allows it to be played in-game, attempting to set the new sound event as the sound in the consumable component in a command causes an error.
Here is the problematic command:
/give @s poisonous_potato[use_cooldown={seconds:1.5,cooldown_group:"soul:spell"},consumable={consume_seconds:1,animation:"bow",has_consume_particles:false,sound:"soul:player.prepare_cast",on_consume_effects:[{type:"play_sound",sound:"soul:player.cast_spell"}]},use_remainder={id:"poisonous_potato",count:1,components:{custom_data:{spell:1},item_model:"soul:sculk_book",item_name:"Mage Bullet","!food":{},"!consumable":{},rarity:rare,lore:["Error"]}},custom_data={spell:1},item_name="Mage Bullet",item_model="soul:sculk_book",lore=[{"text":"Cost: 5","color":"gray","italic":false},"",{"text":"Fires a bolt of magic that","color":"gold","italic":false},{"text":"deals 12 points of damage.","color":"gold","italic":false}],rarity=rare,!food,max_stack_size=1]
But these ones do function:
/playsound soul:player.prepare_cast
/playsound soul:player.cast_spell
Here is an example of the error:
Failed to load function soul:give/spell1
java.util.concurrent.CompletionException: java.lang.IllegalArgumentException: Whilst parsing command on line 1: Malformed 'minecraft:consumable' component: 'Failed to get element ResourceKey[minecraft:sound_event / soul:player.cast_spell]; Failed to get element ResourceKey[minecraft:sound_event / soul:player.prepare_cast]' at position 91: ...onsumable=<--[HERE]
at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:315)
at java.base/java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:320)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1770)
at avl.b(SourceFile:52)
at java.base/java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1423)
at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:387)
at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1312)
at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1843)
at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1808)
at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:188)
Caused by: java.lang.IllegalArgumentException: Whilst parsing command on line 1: Malformed 'minecraft:consumable' component: 'Failed to get element ResourceKey[minecraft:sound_event / soul:player.cast_spell]; Failed to get element ResourceKey[minecraft:sound_event / soul:player.prepare_cast]' at position 91: ...onsumable=<--[HERE]
at hx.a(SourceFile:80)
at alw.a(SourceFile:87)
at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1768)
... 7 more
The datapack and resourcepack Iām using are attached.
The two instances of
sound
in your command are malformed. For custom sounds, you need to specify an object with asound_id
tag. For example:Please see MC-276371 for details.