#crate

1 messages · Page 1 of 1 (latest)

gaunt cairn
#

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;
    }
})```
covert siren
#

that can be a lot of efforts to do,you should solve it by yourself and learn some basics

gaunt cairn
#

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

static trail
#

how should it work?

gaunt cairn
#

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

gaunt cairn
static trail
#

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

gaunt cairn
#

Ok

#

I‘m Bad at scripting a friend helped me with the script

static trail
#

how do u want to create the key?

gaunt cairn
#

Wdym?

static trail
#

how should a chest be a private chest

gaunt cairn
#

Idk

static trail
#

is it to open any chest?

gaunt cairn
#

Ig?

gaunt cairn
#

To open one crate

#

Like rare crate

#

When u mean this

static trail
#

ok, how do u create the rare crate?

gaunt cairn
#

Buy a key

#

?

#

I don’t understand

static trail
#

oh, so thats how

#

ok, after buying that key, how does the crate come?

gaunt cairn
#

A shulker stand at the spawn

static trail
#

like is it setblock infront ?

#

hmm, u need to identify what a crate key is 1st

gaunt cairn
#

?

covert siren
#

I tested the playerHitBlock,and its when you're attempting to break a block (on touch)