Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getBlockWithNBT nbt data to be in usable form #53

Open
pumie314 opened this issue Jul 16, 2020 · 0 comments
Open

getBlockWithNBT nbt data to be in usable form #53

pumie314 opened this issue Jul 16, 2020 · 0 comments

Comments

@pumie314
Copy link

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'>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant