forked from Foghrye4/Substrate
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathModule1.vb
More file actions
103 lines (84 loc) · 3.64 KB
/
Copy pathModule1.vb
File metadata and controls
103 lines (84 loc) · 3.64 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
Imports Substrate
' FlatMap is an example of generating worlds from scratch with Substrate.
' It will produce a completely flat, solid map with grass, dirt, stone,
' and bedrock layers. On a powerful workstation, creating 400 of these
' chunks only takes a few seconds.
Module Module1
Sub Main()
Dim dest As String = "F:\Minecraft\test"
Dim xmin As Integer = -20
Dim xmax As Integer = 20
Dim zmin As Integer = -20
Dim zmaz As Integer = 20
' This will instantly create any necessary directory structure
Dim world As BetaWorld = BetaWorld.Create(dest)
Dim cm As BetaChunkManager = world.GetChunkManager()
' We can set different world parameters
world.Level.LevelName = "Flatlands"
world.Level.Spawn = New SpawnPoint(20, 20, 70)
' world.Level.SetDefaultPlayer();
' We'll let MC create the player for us, but you could use the above
' line to create the SSP player entry in level.dat.
' We'll create chunks at chunk coordinates xmin,zmin to xmax,zmax
For xi As Integer = xmin To xmax - 1
For zi As Integer = zmin To zmaz - 1
' This line will create a default empty chunk, and create a
' backing region file if necessary (which will immediately be
' written to disk)
Dim chunk As ChunkRef = cm.CreateChunk(xi, zi)
' This will suppress generating caves, ores, and all those
' other goodies.
chunk.IsTerrainPopulated = True
' Auto light recalculation is horrifically bad for creating
' chunks from scratch, because we're placing thousands
' of blocks. Turn it off.
chunk.Blocks.AutoLight = False
' Set the blocks
FlatChunk(chunk, 64)
' Reset and rebuild the lighting for the entire chunk at once
chunk.Blocks.RebuildBlockLight()
chunk.Blocks.RebuildSkyLight()
Console.WriteLine("Built Chunk {0},{1}", chunk.X, chunk.Z)
' Save the chunk to disk so it doesn't hang around in RAM
cm.Save()
Next
Next
' Save all remaining data (including a default level.dat)
' If we didn't save chunks earlier, they would be saved here
world.Save()
End Sub
Private Sub FlatChunk(chunk As ChunkRef, height As Integer)
' Create bedrock
For y As Integer = 0 To 1
For x As Integer = 0 To 15
For z As Integer = 0 To 15
chunk.Blocks.SetID(x, y, z, CInt(BlockType.BEDROCK))
Next
Next
Next
' Create stone
For y As Integer = 2 To height - 6
For x As Integer = 0 To 15
For z As Integer = 0 To 15
chunk.Blocks.SetID(x, y, z, CInt(BlockType.STONE))
Next
Next
Next
' Create dirt
For y As Integer = height - 5 To height - 2
For x As Integer = 0 To 15
For z As Integer = 0 To 15
chunk.Blocks.SetID(x, y, z, CInt(BlockType.DIRT))
Next
Next
Next
' Create grass
For y As Integer = height - 1 To height - 1
For x As Integer = 0 To 15
For z As Integer = 0 To 15
chunk.Blocks.SetID(x, y, z, CInt(BlockType.GRASS))
Next
Next
Next
End Sub
End Module