## Instruments ## By: princil ## Configuration: instruments_config: type: data # Can players use instruments to craft items? [default=false] can_craft: false # Can players hurt entities using instruments? [default=true] can_damage: true # Can players break blocks using instruments? [default=true] can_break: true ## To add your own items, copy-paste the commented (green) text below the other items, remove each # from the copied text, and fill in the {item_name}, {material}, {sound} and {item_display_name} values. #{item_name}: # type: item # material: {material} # mechanisms: # nbt: sound/{sound} # display name: <&r>{item_display_name} # debug: false ## Items basedrum: type: item material: leather mechanisms: nbt: sound/block_note_block_basedrum display name: <&r>Drum recipes: 1: type: shaped input: - leather|leather|leather - leather|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|leather - oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks debug: false bell: type: item material: gold_ingot mechanisms: nbt: sound/block_note_block_bell display name: <&r>Bell recipes: 1: type: shaped input: - air|gold_nugget|air - gold_ingot|gold_ingot|gold_ingot - gold_ingot|gold_nugget|gold_ingot debug: false flute: type: item material: stick mechanisms: nbt: sound/block_note_block_flute display name: <&r>Flute recipes: 1: type: shaped input: - air|air|dark_oak_planks - air|dark_oak_planks|air - birch_planks|air|air debug: false guitar: type: item material: stick mechanisms: nbt: sound/block_note_block_guitar display name: <&r>Guitar recipes: 1: type: shaped input: - air|string|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks - oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|string - oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|string debug: false harp: type: item material: gold_ingot mechanisms: nbt: sound/block_note_block_harp display name: <&r>Harp recipes: 1: type: shaped input: - gold_ingot|gold_ingot|gold_ingot - gold_ingot|string|gold_ingot - gold_ingot|string|gold_ingot debug: false xylophone: type: item material: bone mechanisms: nbt: sound/block_note_block_xylophone display name: <&r>Bone Xylophone recipes: 1: type: shaped input: - bone|air|bone - bone|bone|air - air|bone|bone debug: false snare: type: item material: leather mechanisms: nbt: sound/sound/block_note_block_snare display name: <&r>Short Drum recipes: 1: type: shaped input: - leather|leather - oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks|oak_planks/birch_planks/spruce_planks/jungle_planks/acacia_planks/dark_oak_planks debug: false ## Handlers instrument_handler: type: world debug: false events: on player breaks block: - if && !: - determine passively cancelled on item recipe formed: - if : - stop - foreach : - if <[value].has_nbt[sound]>: - determine cancelled after player right clicks entity with item: - flag player pitches_r d:2t - inject instrument_task after player left clicks with item: - flag player pitches_l d:2t - inject instrument_task after player right clicks with item: - flag player pitches_r d:2t - inject instrument_task after player damages entity: - if && !: - determine passively cancelled - flag player pitches_l d:2t - inject instrument_task instrument_task: type: task debug: false script: - if !: - stop - if != CRAFTING: - stop - if : - stop - flag player instrument_cooldown d:1t - if : - define pitch ].round>].div[2]> - else if : - define pitch ].round.add[12]>].div[2]> - determine passively cancelled - if : - playsound sound: pitch:<[pitch]> custom sound_category:records - else: - playsound sound: pitch:<[pitch]> sound_category:records - playeffect effect:NOTE at:,,]> offset:<[pitch]>,0,0 quantity:0 data:1 # By - BasedUser sheet_music_handler: type: world debug: false events: after player left clicks with stick: - if ! && : - flag player playingSheetMusic: - flag player playedSheetMusic: - foreach as:note: - if : - if <[note].split[,].size> == 4: - define pause <[note].split[,].get[1]> - define pitch <[note].split[,].get[2]> - define sound <[note].split[,].get[3]> - define volume <[note].split[,].get[4]> - if ].has_nbt[custom]>: - playsound sound:].nbt[sound]> custom volume:<[volume]> pitch:].div[2]> sound_category:records - else: - playsound sound:].nbt[sound]> volume:<[volume]> pitch:].div[2]> sound_category:records - playeffect effect:NOTE at:,,]> offset:].div[2]> quantity:0 data:1 - wait <[pause]>t - else: - flag player playingSheetMusic:! - flag player playedSheetMusic:! - determine cancelled - else: - queue clear - flag player playingSheetMusic:! - flag player playedSheetMusic:!