BlockEvents.rightClicked(event => {
const heldItem = event.player.getMainHandItem()
const blockId=event.block.id
if (blockId === 'artifality:upgrading_pedestal') {
for (let [a, b] in upgradingPedestalUpgrades) {
if (heldItem.id != a)
return
if (event.block.properties.charges != b.charges)
return
if (heldItem.nbt.artifactTier >= b.tier)
continue
heldItem.nbt.artifactTier=b.charges
event.player.mainHandItem=heldItem.withNBT(b.nbt);
}
}
return
});
#edit blockstate/property of existing block in the world
44 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
at the bottom i need to set the block properties
i tried with
event.block.properties.charges=0
but it doesn't change
you have to use
event.block.set(block.id, {age:'0'})
@rotund inlet would this work with shulkers or would it overwrite the contents
and also it seems to not work for me?
i think the contents are saved in nbt so this wouldn't work
send code
but it needs to be event.block.id instead of block.id
i had destructered everything and forgot to place the event back in that part
oh sry for late response
il get on my computer
if (blockId === 'artifality:upgrading_pedestal') {
for (let [a, b] in upgradingPedestalUpgrades) {
if (heldItem.id != a)
continue
if (event.block.properties.charges != b.charges)
continue
if (b.tier!=0) {
if (heldItem.nbt.artifactTier >= b.tier)
continue
heldItem.nbt.artifactTier=b.charges
}
//event.player.tell(heldItem.nbt)
event.player.mainHandItem=heldItem.withNBT(b.nbt);
event.block.set(blockId,{charges:0})
//change tooltip if its not auto
//event.player.tell(heldItem.nbt)
break
}
}
i also tried some testing with shulker boxes but it seems it doesn't change the properties
do you get any error?
the block.set works it just doesn't pass the properties
i can check again in the log to see if it errors
try {charges:'0'} lol
wow
that worked
i saw that in log there was some shenangins about the value not working
and for some reason that works
neat
well i need some help with something else then
yeah, sometimes you have this simples things that makes a lot of difference, lol
nbt makes no sense lol
well how would i make something like this work with shulker boxes
go for it. maybe i can help
i was looking into making player-only shulker boxes
by storing the uuid in the properties then checking when shulker boxes are interacted with then cancelling the event if its not the same name
would it be possible to get the placed shulker boxes nbt then in the same way set the block then re-add the nbt
you want the player that placed the shulker box be only one that can open it?
yeah
why would you need to re-add the data?
well i tried event.block.set('minecraft:shulker_box',{uuidLock:uuid}) with shulker boxes but it wipes the contents
yeah, set doesn't accept nbt, just properties
so how would i transfer the nbt
id guess getting the nbt beforehand then just setting it after the set
but maybe there is a better method off block for this
i will test somethings here, idk if you can put random nbt data to existing blocks. you can edit them but adding something that doesn't exist i'm not sure