From 8691eff5db90d2e54a693381817779601f0b3f2c Mon Sep 17 00:00:00 2001 From: runcows Date: Mon, 8 Dec 2025 12:04:35 +0900 Subject: [PATCH] Fix torch place sound when place fails --- .../gm4_crossbow_cartridges/function/init.mcfunction | 1 + .../function/projectile/copper_torch/check.mcfunction | 11 ++++++----- .../function/projectile/copper_torch/place.mcfunction | 3 +++ .../projectile/redstone_torch/check.mcfunction | 11 ++++++----- .../projectile/redstone_torch/place.mcfunction | 3 +++ .../function/projectile/soul_torch/check.mcfunction | 11 ++++++----- .../function/projectile/soul_torch/place.mcfunction | 3 +++ .../function/projectile/torch/check.mcfunction | 11 ++++++----- .../function/projectile/torch/place.mcfunction | 3 +++ 9 files changed, 37 insertions(+), 20 deletions(-) diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/init.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/init.mcfunction index 6570a42575..a0196d5c34 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/init.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/init.mcfunction @@ -1,6 +1,7 @@ scoreboard objectives add gm4_cb_string dummy scoreboard objectives add gm4_cb_tw_hook dummy scoreboard objectives add gm4_cb_tw_length dummy +scoreboard objectives add gm4_cb_misc dummy execute unless score crossbow_cartridges gm4_modules matches 1 run data modify storage gm4:log queue append value {type:"install",module:"Crossbow Cartridges"} execute unless score crossbow_cartridges gm4_earliest_version < crossbow_cartridges gm4_modules run scoreboard players operation crossbow_cartridges gm4_earliest_version = crossbow_cartridges gm4_modules diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/copper_torch/check.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/copper_torch/check.mcfunction index 44ce788df3..196fc6680c 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/copper_torch/check.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/copper_torch/check.mcfunction @@ -4,16 +4,17 @@ # run from projectile/copper_torch/loop # summon torch item if torch already exists at this block -execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch run loot spawn ~ ~ ~ loot minecraft:blocks/copper_torch +execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch store success score $dropped_item gm4_cb_misc run loot spawn ~ ~ ~ loot minecraft:blocks/copper_torch # place torch if possible execute if block ~ ~ ~ #gm4:replaceable run function gm4_crossbow_cartridges:projectile/copper_torch/place # summon torch item if placing torch failed -execute unless block ~ ~ ~ #gm4_crossbow_cartridges:torch run loot spawn ~ ~ ~ loot minecraft:blocks/copper_torch +execute unless block ~ ~ ~ #gm4_crossbow_cartridges:torch store success score $dropped_item gm4_cb_misc run loot spawn ~ ~ ~ loot minecraft:blocks/copper_torch -# place block sound -playsound minecraft:block.wood.place block @a[distance=..15] +# item drop sound +execute if score $dropped_item gm4_cb_misc matches 1 run playsound minecraft:entity.item.pickup block @a[distance=..15] -# kill arrow +# clean up +scoreboard players reset $dropped_item gm4_cb_misc kill @s diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/copper_torch/place.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/copper_torch/place.mcfunction index 844f3d744f..a9542a8018 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/copper_torch/place.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/copper_torch/place.mcfunction @@ -8,3 +8,6 @@ execute positioned ~ ~ ~.1 if predicate gm4_crossbow_cartridges:check_block/sout execute positioned ~-.1 ~ ~ if predicate gm4_crossbow_cartridges:check_block/west run setblock ~.15 ~ ~ minecraft:copper_wall_torch[facing=east] execute positioned ~ ~ ~-.1 if predicate gm4_crossbow_cartridges:check_block/north run setblock ~ ~ ~.15 minecraft:copper_wall_torch[facing=south] execute positioned ~ ~-.1 ~ if predicate gm4_crossbow_cartridges:check_block/below run setblock ~ ~.15 ~ minecraft:copper_torch + +# place block sound +execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch run playsound minecraft:block.wood.place block @a[distance=..15] diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/redstone_torch/check.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/redstone_torch/check.mcfunction index 7fa822b777..bbed4a1c30 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/redstone_torch/check.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/redstone_torch/check.mcfunction @@ -4,16 +4,17 @@ # run from projectile/redstone_torch/loop # summon torch item if torch already exists at this block -execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch run loot spawn ~ ~ ~ loot minecraft:blocks/redstone_torch +execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch store success score $dropped_item gm4_cb_misc run loot spawn ~ ~ ~ loot minecraft:blocks/redstone_torch # place torch if possible execute if block ~ ~ ~ #gm4:replaceable run function gm4_crossbow_cartridges:projectile/redstone_torch/place # summon torch item if placing torch failed -execute unless block ~ ~ ~ #gm4_crossbow_cartridges:torch run loot spawn ~ ~ ~ loot minecraft:blocks/redstone_torch +execute unless block ~ ~ ~ #gm4_crossbow_cartridges:torch store success score $dropped_item gm4_cb_misc run loot spawn ~ ~ ~ loot minecraft:blocks/redstone_torch -# place block sound -playsound minecraft:block.wood.place block @a[distance=..15] +# item drop sound +execute if score $dropped_item gm4_cb_misc matches 1 run playsound minecraft:entity.item.pickup block @a[distance=..15] -# kill arrow +# clean up +scoreboard players reset $dropped_item gm4_cb_misc kill @s diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/redstone_torch/place.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/redstone_torch/place.mcfunction index fe3a12294a..ff4fa1dc5a 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/redstone_torch/place.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/redstone_torch/place.mcfunction @@ -8,3 +8,6 @@ execute positioned ~ ~ ~.1 if predicate gm4_crossbow_cartridges:check_block/sout execute positioned ~-.1 ~ ~ if predicate gm4_crossbow_cartridges:check_block/west run setblock ~.15 ~ ~ minecraft:redstone_wall_torch[facing=east] execute positioned ~ ~ ~-.1 if predicate gm4_crossbow_cartridges:check_block/north run setblock ~ ~ ~.15 minecraft:redstone_wall_torch[facing=south] execute positioned ~ ~-.1 ~ if predicate gm4_crossbow_cartridges:check_block/below run setblock ~ ~.15 ~ minecraft:redstone_torch + +# place block sound +execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch run playsound minecraft:block.wood.place block @a[distance=..15] diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/soul_torch/check.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/soul_torch/check.mcfunction index a5fd071af9..e051e98b55 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/soul_torch/check.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/soul_torch/check.mcfunction @@ -4,16 +4,17 @@ # run from projectile/soul_torch/loop # summon torch item if torch already exists at this block -execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch run loot spawn ~ ~ ~ loot minecraft:blocks/soul_torch +execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch store success score $dropped_item gm4_cb_misc run loot spawn ~ ~ ~ loot minecraft:blocks/soul_torch # place torch if possible execute if block ~ ~ ~ #gm4:replaceable run function gm4_crossbow_cartridges:projectile/soul_torch/place # summon torch item if placing torch failed -execute unless block ~ ~ ~ #gm4_crossbow_cartridges:torch run loot spawn ~ ~ ~ loot minecraft:blocks/soul_torch +execute unless block ~ ~ ~ #gm4_crossbow_cartridges:torch store success score $dropped_item gm4_cb_misc run loot spawn ~ ~ ~ loot minecraft:blocks/soul_torch -# place block sound -playsound minecraft:block.wood.place block @a[distance=..15] +# item drop sound +execute if score $dropped_item gm4_cb_misc matches 1 run playsound minecraft:entity.item.pickup block @a[distance=..15] -# kill arrow +# clean up +scoreboard players reset $dropped_item gm4_cb_misc kill @s diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/soul_torch/place.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/soul_torch/place.mcfunction index c47539ef8b..7ec5408805 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/soul_torch/place.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/soul_torch/place.mcfunction @@ -8,3 +8,6 @@ execute positioned ~ ~ ~.1 if predicate gm4_crossbow_cartridges:check_block/sout execute positioned ~-.1 ~ ~ if predicate gm4_crossbow_cartridges:check_block/west run setblock ~.15 ~ ~ minecraft:soul_wall_torch[facing=east] execute positioned ~ ~ ~-.1 if predicate gm4_crossbow_cartridges:check_block/north run setblock ~ ~ ~.15 minecraft:soul_wall_torch[facing=south] execute positioned ~ ~-.1 ~ if predicate gm4_crossbow_cartridges:check_block/below run setblock ~ ~.15 ~ minecraft:soul_torch + +# place block sound +execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch run playsound minecraft:block.wood.place block @a[distance=..15] diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/torch/check.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/torch/check.mcfunction index 3a1bd4efb3..2537fad61e 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/torch/check.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/torch/check.mcfunction @@ -4,16 +4,17 @@ # run from projectile/torch/loop # summon torch item if torch already exists at this block -execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch run loot spawn ~ ~ ~ loot minecraft:blocks/torch +execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch store success score $dropped_item gm4_cb_misc run loot spawn ~ ~ ~ loot minecraft:blocks/torch # place torch if possible execute if block ~ ~ ~ #gm4:replaceable run function gm4_crossbow_cartridges:projectile/torch/place # summon torch item if placing torch failed -execute unless block ~ ~ ~ #gm4_crossbow_cartridges:torch run loot spawn ~ ~ ~ loot minecraft:blocks/torch +execute unless block ~ ~ ~ #gm4_crossbow_cartridges:torch store success score $dropped_item gm4_cb_misc run loot spawn ~ ~ ~ loot minecraft:blocks/torch -# place block sound -playsound minecraft:block.wood.place block @a[distance=..15] +# item drop sound +execute if score $dropped_item gm4_cb_misc matches 1 run playsound minecraft:entity.item.pickup block @a[distance=..15] -# kill arrow +# clean up +scoreboard players reset $dropped_item gm4_cb_misc kill @s diff --git a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/torch/place.mcfunction b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/torch/place.mcfunction index 3db58db7b6..550c297b4f 100644 --- a/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/torch/place.mcfunction +++ b/gm4_crossbow_cartridges/data/gm4_crossbow_cartridges/function/projectile/torch/place.mcfunction @@ -8,3 +8,6 @@ execute positioned ~ ~ ~.1 if predicate gm4_crossbow_cartridges:check_block/sout execute positioned ~-.1 ~ ~ if predicate gm4_crossbow_cartridges:check_block/west run setblock ~.15 ~ ~ minecraft:wall_torch[facing=east] execute positioned ~ ~ ~-.1 if predicate gm4_crossbow_cartridges:check_block/north run setblock ~ ~ ~.15 minecraft:wall_torch[facing=south] execute positioned ~ ~-.1 ~ if predicate gm4_crossbow_cartridges:check_block/below run setblock ~ ~.15 ~ minecraft:torch + +# place block sound +execute if block ~ ~ ~ #gm4_crossbow_cartridges:torch run playsound minecraft:block.wood.place block @a[distance=..15]