From 5c5a4d65fb4eae2e77457b8940b1ad518db88858 Mon Sep 17 00:00:00 2001 From: ForestOfLight Date: Wed, 18 Jun 2025 11:04:49 -0700 Subject: [PATCH] add placement sound for easyPlace, move sounds to block location & update Canopy cmd description --- Construct[BP]/scripts/commands/construct.js | 2 +- Construct[BP]/scripts/options/easyPlace.js | 15 +++++++++++---- Construct[BP]/scripts/options/fastEasyPlace.js | 6 +++--- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/Construct[BP]/scripts/commands/construct.js b/Construct[BP]/scripts/commands/construct.js index 8f0b75f..440fed3 100644 --- a/Construct[BP]/scripts/commands/construct.js +++ b/Construct[BP]/scripts/commands/construct.js @@ -8,7 +8,7 @@ const ACTION_ITEM = 'construct:menu'; const menuCmd = new Command({ name: 'construct', - description: { text: 'Gives you the Construct item. Use it to open the Construct menu.' }, + description: { text: 'Opens the Construct menu.' }, usage: 'construct', callback: (sender) => openMenu(sender) }); diff --git a/Construct[BP]/scripts/options/easyPlace.js b/Construct[BP]/scripts/options/easyPlace.js index b950195..869bce4 100644 --- a/Construct[BP]/scripts/options/easyPlace.js +++ b/Construct[BP]/scripts/options/easyPlace.js @@ -124,7 +124,7 @@ function tryPlaceBlockSurvival(event, player, block, structureBlock) { const itemSlotToUse = fetchMatchingItemSlot(player, placeableItemStack?.typeId); if (itemSlotToUse) { event.cancel = true; - placeBlock(block, structureBlock, itemSlotToUse); + placeBlock(player, block, structureBlock, itemSlotToUse); } else { preventAction(event, player); } @@ -136,12 +136,12 @@ function getPlaceableItemStack(structureBlock) { return newItemId ? new ItemStack(newItemId) : structureBlock.getItemStack(); } -function placeBlock(block, structureBlock, itemSlot) { +function placeBlock(player, block, structureBlock, itemSlot) { system.run(() => { - if (itemSlot) { + if (itemSlot) consumeItem(itemSlot); - } block.setPermutation(structureBlock); + playSoundEffect(player, block, structureBlock); }); } @@ -159,3 +159,10 @@ function consumeItem(itemSlot) { function consumeSpecial(itemSlot) { itemSlot.setItem(new ItemStack(specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')])); } + +function playSoundEffect(player, block, structureBlock) { + const blockId = structureBlock.type.id.replace('minecraft:', ''); + const blockData = blocks[blockId]; + const blockSound = blockData['sound'] || 'stone'; + player.dimension.playSound('dig.' + blockSound, block.location); +} \ No newline at end of file diff --git a/Construct[BP]/scripts/options/fastEasyPlace.js b/Construct[BP]/scripts/options/fastEasyPlace.js index 0b6163c..9b419b4 100644 --- a/Construct[BP]/scripts/options/fastEasyPlace.js +++ b/Construct[BP]/scripts/options/fastEasyPlace.js @@ -168,7 +168,7 @@ function placeBlock(player, block, structureBlock, itemSlot) { if (itemSlot) consumeItem(itemSlot); block.setPermutation(structureBlock); - playSoundEffect(player, structureBlock); + playSoundEffect(player, block, structureBlock); }); } @@ -187,9 +187,9 @@ function consumeSpecial(itemSlot) { itemSlot.setItem(new ItemStack(specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')])); } -function playSoundEffect(player, structureBlock) { +function playSoundEffect(player, block, structureBlock) { const blockId = structureBlock.type.id.replace('minecraft:', ''); const blockData = blocks[blockId]; const blockSound = blockData['sound'] || 'stone'; - player.dimension.playSound('dig.' + blockSound, player.location); + player.dimension.playSound('dig.' + blockSound, block.location); } \ No newline at end of file