make item names non-case-and-whitespace-sensitive
This commit is contained in:
@@ -11,7 +11,7 @@ const builderOption = new BuilderOption({
|
|||||||
identifier: 'easyPlace',
|
identifier: 'easyPlace',
|
||||||
displayName: 'Easy Place',
|
displayName: 'Easy Place',
|
||||||
description: 'Always place the correct structure block.',
|
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);
|
world.beforeEvents.playerPlaceBlock.subscribe(onPlayerPlaceBlock);
|
||||||
@@ -30,7 +30,10 @@ function hasActionItemInCorrectSlot(player) {
|
|||||||
if (!inventory)
|
if (!inventory)
|
||||||
return false;
|
return false;
|
||||||
const actionSlot = inventory.getSlot(ACTION_SLOT);
|
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) {
|
function tryPlaceBlock(event, player, block, structureBlock) {
|
||||||
@@ -52,7 +55,7 @@ function shouldPreventAction(player, structureBlock) {
|
|||||||
function preventAction(event, player) {
|
function preventAction(event, player) {
|
||||||
event.cancel = true;
|
event.cancel = true;
|
||||||
system.run(() => {
|
system.run(() => {
|
||||||
player.onScreenDisplay.setActionBar('§cAction prevented by easyPlace.');
|
player.onScreenDisplay.setActionBar('§cAction prevented by Easy Place.');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const builderOption = new BuilderOption({
|
|||||||
identifier: 'fastEasyPlace',
|
identifier: 'fastEasyPlace',
|
||||||
displayName: 'Fast Easy Place',
|
displayName: 'Fast Easy Place',
|
||||||
description: 'Place correct structure blocks just by looking at them.',
|
description: 'Place correct structure blocks just by looking at them.',
|
||||||
howToUse: "Look at structure blocks with a paper named 'Easy Place' in your hand to place them.",
|
howToUse: "Hold a paper named 'Easy Place' in your hand and look at blocks in a structure to place them."
|
||||||
});
|
});
|
||||||
|
|
||||||
system.runInterval(onTick, PROCESS_INTERVAL);
|
system.runInterval(onTick, PROCESS_INTERVAL);
|
||||||
@@ -37,7 +37,9 @@ function isHoldingActionItem(player) {
|
|||||||
const mainhandItemStack = player.getComponent(EntityComponentTypes.Equippable).getEquipment(EquipmentSlot.Mainhand);
|
const mainhandItemStack = player.getComponent(EntityComponentTypes.Equippable).getEquipment(EquipmentSlot.Mainhand);
|
||||||
if (!mainhandItemStack)
|
if (!mainhandItemStack)
|
||||||
return false;
|
return false;
|
||||||
return mainhandItemStack.typeId === 'minecraft:paper' && mainhandItemStack.nameTag === 'Easy Place';
|
return mainhandItemStack.typeId === 'minecraft:paper'
|
||||||
|
&& mainhandItemStack.nameTag?.toLowerCase().includes('easy')
|
||||||
|
&& mainhandItemStack.nameTag?.toLowerCase().includes('place');
|
||||||
}
|
}
|
||||||
|
|
||||||
function tryPlaceBlock(player, worldBlock, structureBlock) {
|
function tryPlaceBlock(player, worldBlock, structureBlock) {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const builderOption = new BuilderOption({
|
|||||||
identifier: 'materialGrabber',
|
identifier: 'materialGrabber',
|
||||||
displayName: 'Material Grabber',
|
displayName: 'Material Grabber',
|
||||||
description: 'Pulls structure items from inventories.',
|
description: 'Pulls structure items from inventories.',
|
||||||
howToUse: "Interact with inventories using an item named 'Material Grabber' to pull structure items from them.",
|
howToUse: "Interact with inventories using an item named 'Material Grabber' to pull structure items from them."
|
||||||
});
|
});
|
||||||
|
|
||||||
world.beforeEvents.itemUse.subscribe(onItemUse);
|
world.beforeEvents.itemUse.subscribe(onItemUse);
|
||||||
@@ -40,7 +40,8 @@ function onPlayerInteract(event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function isActionItem(itemStack) {
|
function isActionItem(itemStack) {
|
||||||
return itemStack?.nameTag === 'Material Grabber';
|
return itemStack?.nameTag?.toLowerCase().includes('material')
|
||||||
|
&& itemStack?.nameTag?.toLowerCase().includes('grabber');
|
||||||
}
|
}
|
||||||
|
|
||||||
function getActiveMaterials(player) {
|
function getActiveMaterials(player) {
|
||||||
|
|||||||
Reference in New Issue
Block a user