When I use mc.getBlockWithNBT, the data I get back (e.g. for chest contents) is not easily parsable.
I see that the nbt.py lib is included, but it will not parse 'serialized' nbt's.
I did not have good luck trying to deserialize into native Python data structures.
The data is not valid JSON (The arrays have index number "names", names are not quoted... see below)
I tried the external nbtlib, but couldn't get it to read.
Is there a recommended way of parsing and manipulating the NBT data returned from getBlockWithNBT? I'm willing to work with the project lead to make this happen.
Script
from mine import *
mc = Minecraft()
# I have placed a chest here, with some items in it
storeloc = Vec3(18,14,1)
mc.setting("include_nbt_with_data",1)
# get the storage block
blk = mc.getBlockWithNBT(storeloc)
print("found: ", blk)
print("blk is a ", blk.__class__)
print("NBT is ", blk.nbt)
print("NBT is a ", blk.nbt.__class__)
Output:
14:08:26.985
[mobi.omegacentauri.raspberryjammod.ScriptExternalCommand:func_184881_a:275]: Running mcpipy\NBTDemo.py
14:08:27.904
[CHAT] found: Block(54, 2, '{Items:[0:{Slot:11b,id:"minecraft:stone",Count:10b,Damage:3s},1:{Slot:14b,id:"minecraft:hardened_clay",Count:5b,Damage:0s},2:{Slot:25b,id:"minecraft:sapling",Count:11b,Damage:0s}],id:"Chest",Lock:""}')
14:08:27.904
[CHAT] blk is a <class 'mcpi.block.Block'>
14:08:27.904
[CHAT] NBT is {Items:[0:{Slot:11b,id:"minecraft:stone",Count:10b,Damage:3s},1:{Slot:14b,id:"minecraft:hardened_clay",Count:5b,Damage:0s},2:{Slot:25b,id:"minecraft:sapling",Count:11b,Damage:0s}],id:"Chest",Lock:""}
14:08:27.904
[CHAT] NBT is a <class 'str'>
When I use mc.getBlockWithNBT, the data I get back (e.g. for chest contents) is not easily parsable.
I see that the nbt.py lib is included, but it will not parse 'serialized' nbt's.
I did not have good luck trying to deserialize into native Python data structures.
The data is not valid JSON (The arrays have index number "names", names are not quoted... see below)
I tried the external nbtlib, but couldn't get it to read.
Is there a recommended way of parsing and manipulating the NBT data returned from getBlockWithNBT? I'm willing to work with the project lead to make this happen.
Script
Output: