jaquadro / NBTExplorer

A graphical NBT editor for all Minecraft NBT data sources
http://www.minecraftforum.net/topic/840677-nbtexplorer-nbt-editor-for-windows-and-mac/
MIT License
2.25k stars 278 forks source link

[Feature Request] Basic find command through CLI #13

Open Meems33 opened 10 years ago

Meems33 commented 10 years ago

Hello,

I'm working on a project to attempt to migrate my world between modpacks. I'm looking for a way to set item NBT information to it's "default" value should the particular block cause problems. I have already made progress on a utility I made to help me determine what the item's "default" NBT (in particular the TileEntity tags) would be. I just need a way to find the particular block and set it's TileEntity values through scripts.

I looked through the NBTUtil tool but as far as I can tell this feature isn't present through the command line (minus creating a dump from printtree, parsing the text, extracting locations, and then setting NBT values). Is a find feature feasible for the CLI (at least in a basic form i.e. print x,y,z location and the NBT path of every itemId:dammage at the given path)?

Also, is there documentation on the setvalue/setlist command? How would I, for example, set some info on a Tile Entity with 3 ints, a double, and some string tags all at once?

Thanks, Mark

jaquadro commented 10 years ago

Advanced search is on my feature list. I started writing the implementation for it a while ago, but I got sidetracked by forge modding in preparation for starting a new MC server (what? play MC again?)

Based on your description, I can't quite tell if what you want would be possible now or not. Maybe you could provide a concrete example of a replacement?

You couldn't set all the data values on a TileEntity at once, since there is no syntax to set key-value pairs of a compound tag. You'd have to do it individually, but without conditionals, I don't think you could discriminate the tags the way you want to. The current CLI capabilities are somewhat limited to what was needed by the person who originally requested them.

LB-- commented 10 years ago

@Meems33 you may want to consider writing your own conversion script using one of the many Minecraft libraries there are. You're asking to do a specific task in a generic tool.

Meems33 commented 10 years ago

I see what you mean by generic toolkit. I would have to use some kind of context aware program to find blocks. Is this project still active? https://github.com/jaquadro/NBToolkit. So long as I found the path to the item in the tree modification could be done using the CLI.

I'm wondering if something that translated xml or json into memory before applying it to the tree could be possible?

For example, to set the contents of a sign at 5, 5, 5 would be something like

nbtutil.exe --path .../world/region/r.0.0.mca/Chunk [0, 0]/Level/TileEntities/ --addvalue < { "TAG_COMPOUND": { "TAG_INT[x]": 5, "TAG_INT[y]": 5, "TAG_INT[z]": 5, "TAG_STRING[id]": "Sign", "TAG_STRING[Text1]": "This is a sign" "TAG_STRING[Text2]": "" "TAG_STRING[Text3]": "" "TAG_STRING[Text4]": "" } }

Aliases could exist for TAG_XXX. Command could take a file as input.

jaquadro commented 10 years ago

I haven't done anything with NBToolkit in a long time. NBTUtil is actually the better candidate for this kind of thing; it already has all the machinery for a unified NBT namespace. NBToolkit is all about chunks and blocks.

I think the surest way to get your results though is to use http://github,com/jaquadro/Substrate to write a custom utility. You can start with one of the provided examples like BlockReplace and instead use it to modify NBT data. Iterating over all the chunks in a world is a few lines of code, and each chunk exposes a list of all the TileEntities within it, each of which exposes NBT objects.