#player block break before events
1 messages · Page 1 of 1 (latest)
can you show the script?
please dont
🤕
can you just copy and paste
I can't open the account now on the laptop
well I need to see the code atleast, but I dont want you rewriting because it might not be accurate
wait me pls, I'm going to have to open discord 
world.beforeEvents.playerBreakBlock.subscribe(({ player, block, itemStack: item }) => {
system.run(() => {
console.warn(block.typeId)
})
})
It's here @smoky otter
But is it necessary for other things it does, or how can it be fixed by removing it?
😥
well you can use afterevents
but instead of block.typeId you use .brokenBlockPermutation.type.Id
I want to change the value of a state of a block, when I break it I can no longer change it
This is my complete code, I did not send it to avoid confusion but I think it can help you understand
world.beforeEvents.playerBreakBlock.subscribe( ({ player, block, itemStack: item }) => {
system.run(() => {
const silk = item?.getComponent("enchantments").enchantments.getEnchantment("silk_touch")?.level ?? undefined
console.warn(block.typeId)
if (silk) {
const xp = mc.BlockPermutation.resolve(`${block.typeId}`, {
"test:xp": "no",
}):
block.setPermutation(xp);
}
})
})
How is that?
I said nvm.

this is weird
Ive tried to fix it but its still doing that
if thats only the issue of getting the typeId, you dont need system.run
I put it in to get the enchantments, it wouldn't let me because it said I didn't have the privileges
the console warn of the block.typeid, doesnt need system.run
you can put it above it
ah, yes
oh wait, you are still trying to get the block id
yes
no problema
this doesnt mean others dont though, im not a master at script api clearly
thanks anyways