add placement sound for easyPlace, move sounds to block location & update Canopy cmd description
This commit is contained in:
@@ -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)
|
||||
});
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user