I am trying to make a paintbrush to assist me and my friends build a city. My idea for the paintbrush is when held, it uses raycasting to place blocks where the entity is looking. I can't use scripting because one of my friends is on Xbox and can't use scripting for some reason. For the raycasting, I'm using a mcfunction. How do I run a slash command or function when a player holds a specific item in Minecraft bedrock? I think it's possible because it says in the Minecraft addon documentation entity events can call slash commands, other entity events, and MoLang. I'm attaching a picture of that section of the documentation so you can see what I mean. Here is what the image says in case the image fails to load.
Events consist of three categories, all represented by a string:
- Entity events
- Slash Commands
- MoLang Expressions
Entity Events: Server side (behavior packs) only. Currently, we only support entity events to self, and these take the form "@s event". These are events declared in the events section of the entity definition file. For example, in the cat.json, "minecraft:ageable_grow_up" event causes the kitten to grow up. This would take the form of "@s minecraft:ageable_grow_up"
Slash commands: Server side (behavior packs) only. Any slash command can be invoked, such as
/particle minecraft:example_smoke_puff ~ ~ ~. The assumed entity for the slash command is the invoking entity, so this particular slash command will spawn a smoke puff effect at the entity's location.
MoLang Expressions: This executes a MoLang expression. The primary usage is to set MoLang variables that can be used later. For example, a state transition might be looking at a particluar MoLang variable, and this expression could change that variable. A particle effect on the entity might change color due to MoLang variables that the effect uses for color tints. An animation to move an arm might use a MoLang variable that was set by an animation event.
// entity event (behavior packs only), put the particular event name` after the @s "@s minecraft:entity_event" // slash command (behavior packs only), can be any server-side slash command // is invoked from the entity, so a teleport, for example, will teleport the entity by default "/tell @a this is a message"` // MoLang Expressions, executes a molang expression on the entity "variable.something_to_set = 3;"
Am I misunderstanding? If not, how do I do this? If any of this is unclear to you please ask questions in the comments. Thanks!