Skip to main content

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 configurations
IrisBiome plains = data.getBiomeLoader().load("plains");
System.out.println("Biome: " + plains.getName());

Region Loader

getRegionLoader()
ResourceLoader<IrisRegion>
Loads region configurations
IrisRegion region = data.getRegionLoader().load("tropical");

Dimension Loader

getDimensionLoader()
ResourceLoader<IrisDimension>
Loads dimension configurations
IrisDimension 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
getCaveLoader()
ResourceLoader<IrisCave>
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)
IrisBiome
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)
IrisObject
Searches all packs for an object
loadAnyRegion(String, IrisData)
IrisRegion
Searches all packs for a region
loadAnyDimension(String, IrisData)
IrisDimension
Searches all packs for a dimension
Additional loadAny* methods exist for all resource types.

Core Methods

Generic Loading

load(Class<T>, String, boolean)
T
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 null
IrisBiome biome = data.load(IrisBiome.class, "plains", true);

Loader Access

getLoader(Class<T>)
ResourceLoader<T>
Gets the loader for a specific resource type
ResourceLoader<IrisBiome> loader = data.getLoader(IrisBiome.class);
getLoaders()
KMap<Class, ResourceLoader>
Returns all registered resource loaders

Data Management

dump()
void
Clears all cached resources
data.dump();  // Clear cache
clearLists()
void
Clears cached resource lists
close()
void
Closes the data loader and removes it from cache

Prefetch System

loadPrefetch(Engine)
void
Loads frequently-used resources from cache to speed up startup
data.loadPrefetch(engine);
savePrefetch(Engine)
void
Saves access patterns to optimize future loads

Environment

getEnvironment()
PackEnvironment
Returns the script execution environment for this pack

Metadata

getDataFolder()
File
Returns the root folder for this dimension pack
getId()
int
Returns unique ID for this data loader instance
isClosed()
boolean
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

Build docs developers (and LLMs) love