mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-17 01:15:52 +01:00
Natural spawn test
(without luas)
This commit is contained in:
@@ -19,6 +19,8 @@ import emu.grasscutter.data.common.ScenePointConfig;
|
||||
import emu.grasscutter.data.custom.AbilityEmbryoEntry;
|
||||
import emu.grasscutter.data.custom.OpenConfigEntry;
|
||||
import emu.grasscutter.data.custom.ScenePointEntry;
|
||||
import emu.grasscutter.game.world.SpawnDataEntry;
|
||||
import emu.grasscutter.game.world.SpawnDataEntry.SpawnGroupEntry;
|
||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||
|
||||
public class ResourceLoader {
|
||||
@@ -49,6 +51,8 @@ public class ResourceLoader {
|
||||
loadScenePoints();
|
||||
// Process into depots
|
||||
GenshinDepot.load();
|
||||
// Load spawn data
|
||||
loadSpawnData();
|
||||
// Custom - TODO move this somewhere else
|
||||
try {
|
||||
GenshinData.getAvatarSkillDepotDataMap().get(504).setAbilities(
|
||||
@@ -233,6 +237,33 @@ public class ResourceLoader {
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadSpawnData() {
|
||||
// Read from cached file if exists
|
||||
File spawnDataEntries = new File(Grasscutter.getConfig().DATA_FOLDER + "Spawns.json");
|
||||
List<SpawnGroupEntry> spawnEntryList = null;
|
||||
|
||||
if (spawnDataEntries.exists()) {
|
||||
// Load from cache
|
||||
try (FileReader fileReader = new FileReader(spawnDataEntries)) {
|
||||
spawnEntryList = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, SpawnGroupEntry.class).getType());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (spawnEntryList == null || spawnEntryList.isEmpty()) {
|
||||
Grasscutter.getLogger().error("No spawn data loaded!");
|
||||
return;
|
||||
}
|
||||
|
||||
for (SpawnGroupEntry entry : spawnEntryList) {
|
||||
entry.getSpawns().stream().forEach(s -> {
|
||||
s.setGroup(entry);
|
||||
});
|
||||
GenshinDepot.getSpawnListById(entry.getSceneId()).insert(entry, entry.getPos().getX(), entry.getPos().getZ());
|
||||
}
|
||||
}
|
||||
|
||||
private static void loadOpenConfig() {
|
||||
// Read from cached file if exists
|
||||
File openConfigCache = new File(Grasscutter.getConfig().DATA_FOLDER + "OpenConfig.json");
|
||||
|
||||
Reference in New Issue
Block a user