forked from minecraft-dotnet/Substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule1.vb
More file actions
53 lines (42 loc) · 1.65 KB
/
Copy pathModule1.vb
File metadata and controls
53 lines (42 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
Imports Substrate
Imports Substrate.Core
Imports Substrate.Nbt
' This example will convert worlds between alpha and beta format.
' This will convert chunks to and from region format, and copy level.dat
' Other data, like players and other dims, will not be handled.
Module Module1
Sub Main(args As String())
If args.Length <> 3 Then
Console.WriteLine("Usage: Convert <world> <dest> <a|b>")
Return
End If
Dim src As String = args(0)
Dim dst As String = args(1)
Dim srctype As String = args(2)
' Open source and destrination worlds depending on conversion type
Dim srcWorld As NbtWorld
Dim dstWorld As NbtWorld
If srctype = "a" Then
srcWorld = AlphaWorld.Open(src)
dstWorld = BetaWorld.Create(dst)
Else
srcWorld = BetaWorld.Open(src)
dstWorld = AlphaWorld.Create(dst)
End If
' Grab chunk managers to copy chunks
Dim cmsrc As IChunkManager = srcWorld.GetChunkManager()
Dim cmdst As IChunkManager = dstWorld.GetChunkManager()
' Copy each chunk from source to dest
For Each chunk As ChunkRef In cmsrc
cmdst.SetChunk(chunk.X, chunk.Z, chunk.GetChunkRef())
Next
' Copy level data from source to dest
dstWorld.Level.LoadTreeSafe(srcWorld.Level.BuildTree())
' If we're creating an alpha world, get rid of the version field
If srctype = "b" Then
dstWorld.Level.Version = 0
End If
' Save level.dat
dstWorld.Level.Save()
End Sub
End Module