make item names non-case-and-whitespace-sensitive

This commit is contained in:
ForestOfLight
2025-06-07 02:06:42 -07:00
Unverified
parent 9aa8e9d009
commit e4fa6d115c
3 changed files with 13 additions and 7 deletions
+6 -3
View File
@@ -11,7 +11,7 @@ const builderOption = new BuilderOption({
identifier: 'easyPlace',
displayName: 'Easy Place',
description: 'Always place the correct structure block.',
howToUse: "Place blocks in a structure with a paper named 'Easy Place' in the inventory slot above your first hotbar slot to always place the correct block."
howToUse: "Name a paper 'Easy Place', then put it in the inventory slot above your first hotbar slot to always place the correct blocks in a structure."
});
world.beforeEvents.playerPlaceBlock.subscribe(onPlayerPlaceBlock);
@@ -30,7 +30,10 @@ function hasActionItemInCorrectSlot(player) {
if (!inventory)
return false;
const actionSlot = inventory.getSlot(ACTION_SLOT);
return actionSlot.hasItem() && actionSlot.typeId === 'minecraft:paper' && actionSlot.nameTag === 'Easy Place';
return actionSlot.hasItem()
&& actionSlot.typeId === 'minecraft:paper'
&& actionSlot.nameTag?.toLowerCase().includes('easy')
&& actionSlot.nameTag?.toLowerCase().includes('place');
}
function tryPlaceBlock(event, player, block, structureBlock) {
@@ -52,7 +55,7 @@ function shouldPreventAction(player, structureBlock) {
function preventAction(event, player) {
event.cancel = true;
system.run(() => {
player.onScreenDisplay.setActionBar('§cAction prevented by easyPlace.');
player.onScreenDisplay.setActionBar('§cAction prevented by Easy Place.');
});
}