mojira.dev
MCPE-183957

ScriptAPI's ItemCustomComponent's onUseOn conflicts with tool tags

Hello! This is my first time using this site, so please forgive me if the text is confusing.

I'm making an add-on for the Bedrock Edition, and I'm trying to use ItemCustomComponent's onUseOn to trigger additional events for my homemade items such as shovels, axes, and hoes that are activated by right-clicking, but the onUseOn event itself doesn't occur for blocks that can be used because they are tagged as shovels, axes, or hoes.

Is this by design? Or is it a bug?

I'll show you the code just in case (some names have been hidden)

Please let me know if there is any other information you would like to know.

 

world.beforeEvents.worldInitialize.subscribe((event) => {
    // Example Hoe
    event.itemComponentRegistry.registerCustomComponent("test:hoe", {
        // Right_Click_On_Block
        onUseOn(e) {
            const { block, blockFace, source, itemStack } = e;
            if (!(source instanceof Player)) return;
            // Playsound
            source.playSound("use.gravel");
            // No durability loss in creative mode
            if (source.getGameMode() !== GameMode.creative && block.hasTag("grass") && blockFace == Direction.Up) {
                let item = itemStack.getComponent("durability");
                item.damage += 1;
                source.getComponent("equippable").setEquipment(EquipmentSlot.Mainhand, itemStack);
            }
        }
    });
});

 

Added 2024/10/24

I'm sorry for the late response.
I'll add a comment.
Using "world.afterEvents.playerInteractWithBlock.subscribe" got me closer to the behavior I expected, but I'll send you a file and a video to show you what happens when you use OnUseOn just to solve the problem.

This is a simplified add-on made using only tools to send to Mojang. There may be some issues, but I believe I can reproduce them, so thank you for your cooperation.

Don't mind the "Error" in the name... it's just a name.

Linked issues

Attachments

Comments 4

[media][media][media][media][media][media][media][media][media]

We do not have enough information to reproduce this issue.

Please include the following information to help us understand your problem:

Steps to Reproduce:
1. (Explain what needs to be done for the issue to happen)
2.
3.

Observed Results:
(Briefly describe what happens)

Expected Results:
(Briefly describe what should happen)

Please also attach any needed commands, add-ons/behavior packs, data packs, resource packs, screenshots, videos, or worlds needed to help reproduce this issue.

Refer to the Bug Tracker Guidelines for more information about how to write helpful bug reports. Bug reports with insufficient information may be closed as Incomplete.

This issue is being temporarily resolved as Awaiting Response. Once the requested information has been delivered, the report will be reopened automatically.

Quick Links:
📓 Bug Tracker Guidelines – 💬 Community Support – 📧 Mojang Support (Technical Issues) – 📧 Microsoft Support (Account Issues)
📓 Project Summary – ✍️ Feedback and Suggestions – 📖 Game Wiki

I support it, it is an unpleasant problem.

My post: MCPE-188501

I noticed that the onUseOn trigger (class ItemComponentUseOnEvent) conflicts with tags representing «minecraft:is_axe{}», «minecraft:is_hoe{}» and «minecraft:is_shovel{}».

If a Custom Item contains, for example, the «minecraft:is_axe»{} tag, then the onUseOn event will be ignored when interacting with some blocks.

Steps to Reproduce:

1. Create any Custom Item with tag «minecraft:is_axe{
2. Add any Custom Component with trigger onUseOn (class ItemComponentUseOnEvent) or initialize an world event (world.afterEvents.itemUseOn)
3. Add «world.sendMessage('Hello, World!')»

Observed Results:

The game ignores the event when trying to interact with logs and stems using Custom Item with tag «minecraft:is_axe{}».

Expected Results:

We can see World Message «Hello, World!»

Custom Component Trigger example:

[media]

Tag «minecraft:is_axe» from custom_item.json:

[media]

I support it, it is an unpleasant problem.

My post: MCPE-188501

I noticed that the onUseOn trigger (class ItemComponentUseOnEvent) conflicts with tags representing «minecraft:is_axe{}», «minecraft:is_hoe{}» and «minecraft:is_shovel{}».

If a Custom Item contains, for example, the «minecraft:is_axe»{} tag, then the onUseOn event will be ignored when interacting with some blocks.

Steps to Reproduce:

1. Create any Custom Item with tag «minecraft:is_axe{
2. Add any Custom Component with trigger onUseOn (class ItemComponentUseOnEvent) or initialize an world event (world.afterEvents.itemUseOn)
3. Add «world.sendMessage('Hello, World!')»

Observed Results:

The game ignores the event when trying to interact with logs and stems using Custom Item with tag «minecraft:is_axe{}».

Expected Results:

We can see World Message «Hello, World!»

Custom Component Trigger example:

[media]

Tag «minecraft:is_axe» from custom_item.json:

[media]

Yon4800

(Unassigned)

1430403

Confirmed

Windows

Windows 11 Home 23H2

1.21.20.21 Preview, 1.21.2 Hotfix, 1.21.41 Hotfix, 1.21.44 Hotfix

Retrieved