public BedrockResourcePack(IFilesystem archive, ResourcePack.LoadProgress progressReporter = null) { _archive = archive; Info = GetManifest(archive); Load(progressReporter); }
private void ProcessSounds(ResourcePack.LoadProgress progress, DirectoryInfo dir) { foreach (var file in dir.GetFiles()) { if (file.Name.Equals("sound_definitions.json")) { using (var fs = file.OpenRead()) { var fileContents = fs.ReadToEnd(); var json = Encoding.UTF8.GetString(fileContents); SoundDefinitions = SoundDefinitionFormat.FromJson(json); } } } }
private void Load(ResourcePack.LoadProgress progressReporter) { Dictionary <ResourceLocation, EntityDescription> entityDefinitions = new Dictionary <ResourceLocation, EntityDescription>(); Dictionary <string, EntityModel> entityModels = new Dictionary <string, EntityModel>(); if (TryLoadMobModels(entityModels)) { //Log.Info($"Loaded mobs.json: {entityModels.Count}"); } var entries = _archive.Entries.ToArray(); var total = entries.Length; int count = 0; foreach (var entry in entries) { count++; progressReporter?.Invoke((int)(((double)count / (double)total) * 100D), entry.FullName); if (IsEntityDefinition.IsMatch(entry.FullName)) { LoadEntityDefinition(entry, entityDefinitions); continue; } if (IsEntityModel.IsMatch(entry.FullName)) { LoadEntityModel(entry, entityModels); continue; } if (IsSoundDefinition.IsMatch(entry.FullName)) { ProcessSounds(progressReporter, entry); continue; } } EntityModels = ProcessEntityModels(entityModels); //Log.Info($"Processed {EntityModels.Count} entity models"); EntityDefinitions = entityDefinitions; // Log.Info($"Processed {EntityDefinitions.Count} entity definitions"); }
private void Load(ResourcePack.LoadProgress progressReporter) { DirectoryInfo entityDefinitionsDir = null; Dictionary <string, FileInfo> entityGeometry = new Dictionary <string, FileInfo>(); foreach (var dir in _workingDir.EnumerateDirectories()) { // if (entityDefinitionsDir == null && dir.Name.Equals("definitions")) // { // foreach (var d in dir.EnumerateDirectories()) // { if (dir.Name.Equals("entity")) { entityDefinitionsDir = dir; var files = dir.GetFiles(); var total = files.Length; int count = 0; foreach (var file in files) { count++; progressReporter?.Invoke((int)(((double)count / (double)total) * 100D), file.Name); if (!entityGeometry.TryAdd(file.Name, file)) { if (entityGeometry.TryGetValue(file.Name, out var current)) { if (current.LastWriteTimeUtc < file.LastWriteTimeUtc) { entityGeometry[file.Name] = file; continue; } } Log.Warn($"Failed to add to entity geo dictionary (1)! {file.Name}"); } } // break; } if (dir.Name.Equals("sounds")) { ProcessSounds(progressReporter, dir); } //} //} if (entityDefinitionsDir != null) { break; } } if (entityDefinitionsDir == null || !entityDefinitionsDir.Exists) { Log.Warn("Could not find entity definitions folder!"); return; } Dictionary <ResourceLocation, EntityDescription> entityDefinitions = new Dictionary <ResourceLocation, EntityDescription>(); foreach (var def in entityDefinitionsDir.EnumerateFiles()) { LoadEntityDefinition(def, entityDefinitions); } EntityDefinitions = entityDefinitions; Log.Info($"Processed {EntityDefinitions.Count} entity definitions"); }
public BedrockResourcePack(DirectoryInfo directory, ResourcePack.LoadProgress progressReporter = null) { _workingDir = directory; Load(progressReporter); }
public BedrockResourcePack(IFilesystem archive, ResourcePack.LoadProgress progressReporter = null) { _archive = archive; Load(progressReporter); }