#How to make a block open a form
1 messages · Page 1 of 1 (latest)
its not possible currently but if you're okay with players requiring an item on their hand to click on a block then we can implement that
or if you are using a custom block
im using a custom block
/scriptevent
Just run /scriptevent in a command in a block event
search it on #1067535608660107284 i've read something like that earlier about block events
it does not get the entity that interacted and the block at the same time.
you can only get either sourceEntity or sourceBlock
i will try, thank u
I got home not long ago and decided to test it, it didn't work.
send block file
system.events.scriptEventReceive.subscribe((eventData)=>{
const player = eventData.sourceEntity
const block = eventData.sourceBlock;
const blockLocation = block.location;
const { x, y, z } = blockLocation
if (eventData.id == "way:open_form") {
try {
if (block.hasTag('ender_altar') && block.hasTag('active') == true && !player.isSneaking) {
ender_altarScreen(player, player.dimension.id, player.level, x, y, z)
}
} catch { }
}
})```
errors?
you cant get both the block and the player
only getting this one
idk either
there is a way to get the block and the player?
i was using getViewBlockDirection
two events
like this?
system.events.scriptEventReceive.subscribe((eventData) => {
const player = eventData.sourceEntity
if (eventData.id == "way:open_form") {
system.events.scriptEventReceive.subscribe((eventData) => {
const block = eventData.sourceBlock;
const blockLocation = block.location;
const { x, y, z } = blockLocation
if (eventData.id == "way:open_form2") {
try {
if (block.hasTag('ender_altar') && block.hasTag('active') == true && !player.isSneaking) {
ender_altarScreen(player, player.dimension.id, player.level, x, y, z)
}
} catch { }
}
})
}
})```
maby you might unsubscribe the secound one but you have trigger the event for the block and the player
how can i do that?
{
"events": {
"test": {
"run_command": {
"command": [
"scriptevent"
],
"target": "other"
},
"trigger": {
"event": "block"
}
},
"block": {
"run_command": {
"command": [
"scriptevent"
],
"target": "self"
}
}
}
}```
so i need 2 scriptevents to get the block and the player, right?
player then block yes
how would i do that?
^
oh
but ```js
const callback = (eventData) => {
const block = eventData.sourceBlock;
const blockLocation = block.location;
const { x, y, z } = blockLocation
if (eventData.id == "way:open_form2") {
try {
if (block.hasTag('ender_altar') && block.hasTag('active') == true && !player.isSneaking) {
ender_altarScreen(player, player.dimension.id, player.level, x, y, z)
}
} catch { }
}
system.events.scriptEventReceive.unsubscribe(callback);
};
system.events.scriptEventReceive.subscribe(callback);
like this?
system.events.scriptEventReceive.subscribe((eventData) => {
const player = eventData.sourceEntity
if (eventData.id == "way:open_form") {
const callback = (eventData) => {
const block = eventData.sourceBlock;
const blockLocation = block.location;
const { x, y, z } = blockLocation
if (eventData.id == "way:open_form2") {
try {
if (block.hasTag('ender_altar') && block.hasTag('active') == true && !player.isSneaking) {
ender_altarScreen(player, player.dimension.id, player.level, x, y, z)
}
} catch { }
}
system.events.scriptEventReceive.unsubscribe(callback);
};
system.events.scriptEventReceive.subscribe(callback);
}
})```
still getting this error but it seens to work normally
if (!block) return
where?