#What is the function to edit nbt of a block entity in a level? Also, how do you add a new data tag?
86 messages · Page 1 of 1 (latest)
Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!
level.getBlock(pos).entityData / .mergeEntityData(nbt)
oh right that's all from mc itself
oh the BlockContainerJS stuff?
oh i see
Sorry it's taking me so long
I'm being dumb
BlockEvents.rightClicked('kubejs:portal_totem', e => {
e.level.getBlock(e.block.getPos()).entityData
console.log(entityData)
})```
Server is hiting me with that [ERROR] ! gateway_block.js#3: Error in 'BlockEvents.rightClicked': ReferenceError: "entityData" is not defined.
Paste version of server.log from @remote musk
WAIT
IM SO DUMB
fuckin ned a constant saOFDIHLAFG
dAMN
BlockEvents.rightClicked('kubejs:portal_totem', e => {
let blockData = e.level.getBlock(e.block.getPos()).entityData =
console.log(blockData)
})```
[INFO] gateway_block.js#2: undefined
Block registry:
StartupEvents.registry('block', e =>{
e.create('portal_totem')
.blockEntity(portalTotem =>{
portalTotem.initialData('{active: 1}')
})
})```
well yeah
trying to see what it says
look at your code
= at end
I saw that
Im about to remove it but my pc is giving me shit
Yes
I know
It was not put there on purpose
was a typeo on my end which is my bad
again sorry for the wait, my gpu just hates modded mc
we are so back
[INFO] gateway_block.js#4: {ForgeCaps:{},data:{active:1},id:"kubejs:portal_totem",placer:[I;748692735,826950754,-2105760280,107573356],x:-25,y:-60,z:58} [net.minecraft.nbt.CompoundTag]
Problably made another typo here
BlockEvents.rightClicked('kubejs:portal_totem', e => {
let blockData = e.level.getBlock(e.block.getPos()).entityData
blockData
e.level.getBlock(e.block.getPos()).mergeEntityData({active: 100})
console.log(blockData)
})```
Sorry if im not processing everything right
Im in a situation
oh yeah logs
Paste version of server.log from @remote musk
isnt active a boolean
so its either 0 or 1
actually its a byte so 100 should work
I suggest using string for nbt
so try .mergeEntityData('{active: 100b}')

I mean, I've tried merge entity data before
Found it through probe
Couldn't get it to work, and it is still not working
Nothing interesting has changed in the logs from what I can tell
Paste version of server.log from @remote musk
StartupEvents.registry('block', e =>{
e.create('portal_totem')
.blockEntity(portalTotem =>{
portalTotem.initialData('{active: 1}')
})
})```
Maybe initial data is fucking with things
I dont know
Also, why did I send that here
no initial data shouldnt change anything, weird
Im gonna load this up in a new pack without any other mods or scripts
And if it doesn't work
Ill uuuuuh
idk
Yeah shit is still fucked
You know, at least me screaming your name (saying it in all caps) was validated
( In all seriousness, thank you for your help and making this tool but PLEASE set up a volunteer system for the documentation or something)
(ur great)
Okay, not even /data merge is editing this thing
Something is afoot
if thats the entity data, then it should be
.mergeEntityData({data:{active:100}})
i guess
something like this work for chests:
BlockEvents.rightClicked(e => {
const {block} = e;
if(e.hand == 'off_hand') return;
e.server.tell(block.entityData)
block.mergeEntityData({Items:[{Count:1,Slot:11,id:"minecraft:coal_ore"}]})
e.server.tell(block.entityData)
})
try this
block.entityData.data.active```

