#click on a block to open a form

1 messages · Page 1 of 1 (latest)

north jolt
#

entityHit event. Works with blocks too.

rain mountain
#

I just have no idea how to use it.

#

Can you give an example of how to use

north jolt
#
const form = new ActionFormData()
    .title("Test")
    .body("Description")
    .button("§aHola");

world.events.entityHit.subscribe(({hitBlock, entity}) => {
    if (hitBlock.typeId === "minecraft:block") {
        form.show(entity)//...
    }
});```
gritty current
#

I do it in two ways: the 1st is the one that is sampled, the top the 2nd is to add an event when interacting with the block, this event adds a tag to those who interact with the block, the API script detects and removes the tag and opens the form;

  "minecraft:on_interact":{
    "event" : "modedrna:open_window",
    "target": "self"
  }
},
"events": {
  "modedrna:open_window": {
    "run_command": {
      "command": ["tag @p[tag=!window_open,tag=!open_window,r=5] add open_window"]
    }
  }
}```
#
system.runInterval(data=>{
    for(const player of world.getPlayers()) {
        if (player.hasTag('open_window')){
            player.removeTag('open_window');
            ModernaLoja(player,'','j');
            break
        }
    }
},3)```
#

@rain mountain

craggy barn
#

why tf would you do that

#

world.events.beforeItemUseOn

valid estuary