Add "action prevented by easyPlace" message

This commit is contained in:
ForestOfLight
2025-04-13 13:36:16 -07:00
Unverified
parent 77994b26dd
commit 516f26e2b2
+9 -1
View File
@@ -33,7 +33,8 @@ function hasActionItemInCorrectSlot(player) {
} }
function tryPlaceBlock(event, player, block, structureBlock) { function tryPlaceBlock(event, player, block, structureBlock) {
if (isBannedBlock(player, structureBlock)) return; if (isBannedBlock(player, structureBlock))
preventAction(event, player);
structureBlock = tryConvertBannedToValidBlock(structureBlock); structureBlock = tryConvertBannedToValidBlock(structureBlock);
if (player.getGameMode() === GameMode.creative) { if (player.getGameMode() === GameMode.creative) {
placeBlock(block, structureBlock); placeBlock(block, structureBlock);
@@ -43,6 +44,13 @@ function tryPlaceBlock(event, player, block, structureBlock) {
} }
} }
function preventAction(event, player) {
event.cancel = true;
system.run(() => {
player.onScreenDisplay.setActionBar('§cAction prevented by easyPlace.');
});
}
function isBannedBlock(player, structureBlock) { function isBannedBlock(player, structureBlock) {
const blockId = structureBlock.type.id.replace('minecraft:', ''); const blockId = structureBlock.type.id.replace('minecraft:', '');
if (bannedBlocks.includes(blockId)) if (bannedBlocks.includes(blockId))