Overview
The IrisData class manages loading and caching of all dimension resources including biomes, regions, objects, structures, and more.
Getting IrisData
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.framework.Engine;
import java.io.File;
// From engine
Engine engine = IrisToolbelt.access(world).getEngine();
IrisData data = engine.getData();
// From dimension folder
File packFolder = new File("Iris/packs/overworld");
IrisData data = IrisData.get(packFolder);
Resource Loaders
Location: core/src/main/java/com/volmit/iris/core/loader/IrisData.java
Each loader provides access to a specific resource type:
Biome Loader
getBiomeLoader()
ResourceLoader<IrisBiome>
Loads biome configurationsIrisBiome plains = data.getBiomeLoader().load("plains");
System.out.println("Biome: " + plains.getName());
Region Loader
getRegionLoader()
ResourceLoader<IrisRegion>
Loads region configurationsIrisRegion region = data.getRegionLoader().load("tropical");
Dimension Loader
getDimensionLoader()
ResourceLoader<IrisDimension>
Loads dimension configurationsIrisDimension dimension = data.getDimensionLoader().load("overworld");
Object Loader
getObjectLoader()
ResourceLoader<IrisObject>
Loads structure objects (.iob files)IrisObject tree = data.getObjectLoader().load("trees/oak");
Structure Loaders
getJigsawStructureLoader()
ResourceLoader<IrisJigsawStructure>
Loads jigsaw structure definitions
getJigsawPoolLoader()
ResourceLoader<IrisJigsawPool>
Loads jigsaw template pools
getJigsawPieceLoader()
ResourceLoader<IrisJigsawPiece>
Loads individual jigsaw pieces
Additional Loaders
getLootLoader()
ResourceLoader<IrisLootTable>
Loads loot table definitions
getEntityLoader()
ResourceLoader<IrisEntity>
Loads entity configurations
getSpawnerLoader()
ResourceLoader<IrisSpawner>
Loads spawner configurations
getBlockLoader()
ResourceLoader<IrisBlockData>
Loads custom block data
Loads cave generation configs
getRavineLoader()
ResourceLoader<IrisRavine>
Loads ravine generation configs
Static Utility Methods
Cross-Pack Loading
Load resources from any pack, not just the current one:
loadAnyBiome(String, IrisData)
Searches all packs for a biomeParameters:
key - Biome load key
nearest - Starting pack (can be null)
IrisBiome biome = IrisData.loadAnyBiome("desert", data);
loadAnyObject(String, IrisData)
Searches all packs for an object
loadAnyRegion(String, IrisData)
Searches all packs for a region
loadAnyDimension(String, IrisData)
Searches all packs for a dimension
Additional loadAny* methods exist for all resource types.
Core Methods
Generic Loading
load(Class<T>, String, boolean)
Generic method to load any resource typeParameters:
type - Resource class (e.g., IrisBiome.class)
key - Resource load key
warn - Show warnings if not found
Returns: Resource instance or nullIrisBiome biome = data.load(IrisBiome.class, "plains", true);
Loader Access
Gets the loader for a specific resource typeResourceLoader<IrisBiome> loader = data.getLoader(IrisBiome.class);
getLoaders()
KMap<Class, ResourceLoader>
Returns all registered resource loaders
Data Management
Clears all cached resourcesdata.dump(); // Clear cache
Clears cached resource lists
Closes the data loader and removes it from cache
Prefetch System
Loads frequently-used resources from cache to speed up startupdata.loadPrefetch(engine);
Saves access patterns to optimize future loads
Environment
Returns the script execution environment for this pack
Returns the root folder for this dimension pack
Returns unique ID for this data loader instance
Returns true if the loader has been closed
Usage Examples
Load All Resources
public void loadDimensionResources(IrisData data) {
// Load biomes
List<IrisBiome> biomes = data.getBiomeLoader()
.loadAll()
.collect(Collectors.toList());
// Load regions
List<IrisRegion> regions = data.getRegionLoader()
.loadAll()
.collect(Collectors.toList());
// Load objects
List<IrisObject> objects = data.getObjectLoader()
.loadAll()
.collect(Collectors.toList());
System.out.println(String.format(
"Loaded %d biomes, %d regions, %d objects",
biomes.size(), regions.size(), objects.size()
));
}
Search Across Packs
public IrisBiome findBiomeAnywhere(String name) {
// Search current pack first
IrisBiome biome = IrisData.loadAnyBiome(name, null);
if (biome != null) {
System.out.println("Found " + name + " in " +
biome.getLoadFile().getParentFile().getName());
}
return biome;
}
Cache Management
public void optimizeMemory(Engine engine) {
IrisData data = engine.getData();
// Save frequently-used resources
data.savePrefetch(engine);
// Clear unused resources
data.dump();
// Reload prefetch on next startup
data.loadPrefetch(engine);
}
Custom Resource Loading
public void loadCustomResources(IrisData data) {
// Load specific loot table
IrisLootTable loot = data.getLootLoader().load("chests/dungeon");
// Load cave configuration
IrisCave cave = data.getCaveLoader().load("limestone_caves");
// Load entity spawner
IrisSpawner spawner = data.getSpawnerLoader().load("hostile_mobs");
}
List All Resources
public void listAllBiomes(IrisData data) {
ResourceLoader<IrisBiome> loader = data.getBiomeLoader();
// Get all biome keys
List<String> biomeKeys = loader.getPossibleKeys();
System.out.println("Available biomes:");
for (String key : biomeKeys) {
IrisBiome biome = loader.load(key);
System.out.println(" - " + key + ": " + biome.getName());
}
}
Resource Caching
IrisData automatically caches loaded resources for performance:
- First Load: Reads from disk, parses JSON, caches result
- Subsequent Loads: Returns cached instance
- Cache Clear: Call
dump() to free memory
- Prefetch: Automatically loads common resources on startup
See Also