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({
|
const menuCmd = new Command({
|
||||||
name: 'construct',
|
name: 'construct',
|
||||||
description: { text: 'Gives you the Construct item. Use it to open the Construct menu.' },
|
description: { text: 'Opens the Construct menu.' },
|
||||||
usage: 'construct',
|
usage: 'construct',
|
||||||
callback: (sender) => openMenu(sender)
|
callback: (sender) => openMenu(sender)
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ function tryPlaceBlockSurvival(event, player, block, structureBlock) {
|
|||||||
const itemSlotToUse = fetchMatchingItemSlot(player, placeableItemStack?.typeId);
|
const itemSlotToUse = fetchMatchingItemSlot(player, placeableItemStack?.typeId);
|
||||||
if (itemSlotToUse) {
|
if (itemSlotToUse) {
|
||||||
event.cancel = true;
|
event.cancel = true;
|
||||||
placeBlock(block, structureBlock, itemSlotToUse);
|
placeBlock(player, block, structureBlock, itemSlotToUse);
|
||||||
} else {
|
} else {
|
||||||
preventAction(event, player);
|
preventAction(event, player);
|
||||||
}
|
}
|
||||||
@@ -136,12 +136,12 @@ function getPlaceableItemStack(structureBlock) {
|
|||||||
return newItemId ? new ItemStack(newItemId) : structureBlock.getItemStack();
|
return newItemId ? new ItemStack(newItemId) : structureBlock.getItemStack();
|
||||||
}
|
}
|
||||||
|
|
||||||
function placeBlock(block, structureBlock, itemSlot) {
|
function placeBlock(player, block, structureBlock, itemSlot) {
|
||||||
system.run(() => {
|
system.run(() => {
|
||||||
if (itemSlot) {
|
if (itemSlot)
|
||||||
consumeItem(itemSlot);
|
consumeItem(itemSlot);
|
||||||
}
|
|
||||||
block.setPermutation(structureBlock);
|
block.setPermutation(structureBlock);
|
||||||
|
playSoundEffect(player, block, structureBlock);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,3 +159,10 @@ function consumeItem(itemSlot) {
|
|||||||
function consumeSpecial(itemSlot) {
|
function consumeSpecial(itemSlot) {
|
||||||
itemSlot.setItem(new ItemStack(specialItemPlacementConversions[itemSlot.typeId.replace('minecraft:', '')]));
|
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)
|
if (itemSlot)
|
||||||
consumeItem(itemSlot);
|
consumeItem(itemSlot);
|
||||||
block.setPermutation(structureBlock);
|
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:', '')]));
|
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 blockId = structureBlock.type.id.replace('minecraft:', '');
|
||||||
const blockData = blocks[blockId];
|
const blockData = blocks[blockId];
|
||||||
const blockSound = blockData['sound'] || 'stone';
|
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