-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Turn world manager into a BackgroundService * Abstractions refactor pt.1 * Update Region.cs * Abstractions refactor pt.2 * Move world generator registering to WorldManager * abstractions pt.3 * Use packet broadcaster * Fix event parameters * Simplify ConsoleApp.Program.cs * Refactor Living.cs * A little cleanup * WE START WOOOOO * Update Player.cs * oop * Fix up some NREs and wait for worlds to be ready * Region loading does not need to be blocked * Add a direct send method that won't get processed through the queue * Just use JsonNamingPolicy.SnakeCaseLower :)) * world gen status * Fix strange chunk unloading bug * Forgot to save O_O * Improve caves & ores generation performance * Update OperatorList & IOperatorList * Last bit refactor * Make user cache a service instead * Add sealed modifier to most classes (final commit) * OKAY ACTUAL FINAL COMMIT * Tweaks to rivers, mountain heights and beaches * Fix bug loading worlds from disk * Still mucking about * interim * interim * Interim * Personal code review * fix biome reload issue * Ready for review * Interim * got it * kinda works * EEETS WORKINGGGG * Cleanup * Personal code review * Added my own tree asset * I made this --------- Co-authored-by: Tides <[email protected]> Co-authored-by: Seb-stian <[email protected]>
- Loading branch information
1 parent
058cc30
commit 25c882b
Showing
6 changed files
with
98 additions
and
1 deletion.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
using Obsidian.Nbt; | ||
using System.Diagnostics; | ||
using System.IO; | ||
|
||
namespace Obsidian.Registries; | ||
internal static class StructureRegistry | ||
{ | ||
public static readonly ConcurrentDictionary<string, Dictionary<Vector, IBlock>> storage = new(); | ||
public static void Initialize() | ||
{ | ||
var structDir = "Assets/Structures/"; | ||
var files = Directory.GetFiles(structDir, "*.nbt"); | ||
foreach (var file in files) | ||
{ | ||
var structureName = Path.GetFileNameWithoutExtension(file); | ||
storage[structureName] = new(); | ||
byte[] nbtData = File.ReadAllBytes(file); | ||
using var byteStream = new ReadOnlyStream(nbtData); | ||
var nbtReader = new NbtReader(byteStream, NbtCompression.GZip); | ||
var baseCompound = nbtReader.ReadNextTag() as NbtCompound; | ||
|
||
// Get palette | ||
List<IBlock> paletteBuffer = new(); | ||
if (baseCompound!.TryGetTag("palette", out var palette)) | ||
{ | ||
foreach (NbtCompound entry in (palette as NbtList).Cast<NbtCompound>()) | ||
{ | ||
paletteBuffer.Add(entry.ToBlock()); | ||
} | ||
} | ||
|
||
if (baseCompound.TryGetTag("blocks", out var blocks)) | ||
{ | ||
foreach (NbtCompound b in (blocks as NbtList).Cast<NbtCompound>()) | ||
{ | ||
IBlock block = paletteBuffer[b!.GetInt("state")]; | ||
if (b!.TryGetTag("pos", out var coords)) | ||
{ | ||
var c = (NbtList)coords; | ||
var offset = new Vector( | ||
((NbtTag<int>)c[0]).Value, | ||
((NbtTag<int>)c[1]).Value, | ||
((NbtTag<int>)c[2]).Value); | ||
|
||
storage[structureName][offset] = block; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters