Jump to content

Strings and NBTs


sfxworks

Recommended Posts

I've successfully decoded an NBT file. Now, I am trying to convert it to a bo2 file. I am...ofcourse...running into multible issues with this. So far, I have been able to print the entire nbt into text. I can convert this to a string relatively easy I assume. From there...how do I get certain values? I guess what im saying is, how would I get a string after another string?

 

For instance, the Length, Width, and Height. I need those, and I need to be able to get the data values and put them into an array. Well, I don't really have to but it would make things a lot easier.

 

In the types of NBT files I am working with, they are easy to find with my HANDY DANDY cntrl F.

[3] => Array ( [type] => 2 [name] => Height [value] => 2 )
[11] => Array ( [type] => 2 [name] => Length [value] => 3 )
[12] => Array ( [type] => 2 [name] => Width [value] => 3 )
[8] => Array ( [type] => 7 [name] => Data [value] => Array (
                [0] => 0
                [1] => 0
                [2] => 0
                [3] => 0
                [4] => 0
                [5] => 0
                [6] => 0
                [7] => 0
                [8] => 0
                [9] => 0
                [10] => 0
                [11] => 0
                [12] => 0
                [13] => 0
                [14] => 5
                [15] => 0
                [16] => 0
	[17] => 0 

[13] => Array ( [type] => 7 [name] => Blocks [value] => Array ( 
                [0] => 4
                [1] => 4
                [2] => 20
                [3] => 4
                [4] => 1
                [5] => 57
                [6] => 4
                [7] => 4
                [8] => 4
                [9] => 0
                [10] => 0
                [11] => 0
                [12] => 0
                [13] => 0
                [14] => 76
                [15] => 48
                [16] => 0
                [17] => 0 

As you can see, they are always marked as [3],[8],[11],[12],and [13]. So what I am trying to do is get those datavalues and...basically, re arrange the text while getting rid of the rest. 11 contains the length, 12 contains the width, 3 contains the height, 13 contains the block data, and 8 contains additional data for the block data (if any).

For that example, a bo2 would look something like this.

[META]
version=2.0
spawnOnBlockType=2
spawnSunlight=False
spawnDarkness=True
spawnWater=False
spawnLava=False
underFill=True
randomRotation=True
dig=True
tree=False
branch=False
needsFoundation=False
rarity=1
collisionPercentage=1
spawnElevationMin=0
spawnElevationMax=64
spawnInBiome=Forest,Plains,Rain Forest,Savanna,Seasonal Forest,Shrubland,Swampland,Taiga,Tundra

//All of the variables above would be specified in an html form.

[DATA]
1,0,0:4
1,1,0:4
0,1,0:4
-1,1,0:4
-1,0,0:4
-1,-1,0:4
0,-1,0:57
1,-1,0:20
0,0,0:1
-1,1,1:48
0,-1,1:76.1

//This is the important part. This is where the main data is stored. Format (X,Y,Z,:BlockData.AdditionalBlockData)

Given the length, width, and height, I suppose setting up coordinates would be somewhat simple. Yet im still left with the issue on how to capture the data from the GIANT string. Any tips? Help? I am SO close to breaking this.

 

I am using Php 5 with the GMP extension. Windows 7x64. Find what I have so far here http://mcserver1337.servegame.com/_usr/sfxworks/Sandbox/NBTDecodePHP/test.php.

Link to comment
https://forums.phpfreaks.com/topic/244654-strings-and-nbts/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.