world.afterEvents.itemUse.subscribe((d) => {
const source = d.source;
const item = d.itemStack;
if(item.typeId === "minecraft:paper"){
source.setDynamicProperty("myKey",`${item.nameTag}`)
}
})
world.beforeEvents.playerInteractWithBlock.subscribe((e) => {
const player = e.player;
const key = e.itemStack;
if(e.block.typeId !== "minecraft:chest") return;
if(key === undefined || key.typeId !== "minecraft:paper"){
e.cancel = true
} else if(key.nameTag !== player.getDynamicProperty("myKey")){
e.cancel = true;
} else {
e.cancel = false;
}
})```
#crate
1 messages · Page 1 of 1 (latest)
that can be a lot of efforts to do,you should solve it by yourself and learn some basics
world.afterEvents.itemUse.subscribe((d) => {
const source = d.source;
const item = d.itemStack;
if(item.typeId === "minecraft:paper"){
source.setDynamicProperty("myKey",`${item.nameTag}`)
}
})
world.beforeEvents.playerInteractWithBlock.subscribe((e) => {
const player = e.player;
const key = e.itemStack;
if(e.block.typeId !== "minecraft:chest") return;
if(key === undefined || key.typeId !== "minecraft:paper"){
e.cancel = true
} else if(key.nameTag !== player.getDynamicProperty("myKey")){
e.cancel = true;
} else {
e.cancel = false;
}
})```
@static trail
Here was a test
how should it work?
Ur get a tripwire with id like 2 and then there is a shulker (and when ur click it long u see the reward) when it click it once it opens the crate
The items should show and then the item ur get is the reward
And ur get it in the inv
The () only if it’s possible yk
i see ur trying to make a key for a block
since it's not possible to save dynamicproperty on block
use world and location as key
and item details as the value
how do u want to create the key?
Wdym?
how should a chest be a private chest
Idk
is it to open any chest?
Ig?
No
To open one crate
Like rare crate
When u mean this
ok, how do u create the rare crate?
A shulker stand at the spawn
?
For long,player hit block,for touch player Interact with block event
I tested the playerHitBlock,and its when you're attempting to break a block (on touch)