mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Add PackBiome and PackRegion so modules can look up pack biomes and regions through PackResources
This commit is contained in:
1 parent
50f51db8b2
commit
33fc9adca9
6 files changed
+67
-3
No files matched your search
@@ -7,8 +7,11 @@ import java.util.UUID;
|
||||
|
||||
/** Immutable view of one loaded pack snapshot, safe for concurrent reads.
|
||||
* Reload produces a different snapshotId, even for the same pack. Resources must be immutable
|
||||
* or explicitly thread-safe. Unknown IDs return empty; a known ID with the wrong requested
|
||||
* type throws IllegalArgumentException. Broken resources fail loading rather than appearing absent.
|
||||
* or explicitly thread-safe. The requested type selects the kind of resource, so one ID can name
|
||||
* both a biome and a region. Hosts serve {@code GeneratedObject} (pack objects),
|
||||
* {@code PackBiome} and {@code PackRegion}; an ID the pack lacks for that kind returns empty, and a
|
||||
* type the host does not serve throws IllegalArgumentException. Broken resources fail loading
|
||||
* rather than appearing absent.
|
||||
* The host owns resolution, imports, native handles and caches; no filesystem paths escape.
|
||||
*/
|
||||
public interface PackResources {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.volmit.world;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/** A biome of the loaded pack, found through {@code PackResources} by the ids a {@link BiomeSample} gives.
|
||||
* platformBiome is the platform biome the host writes for it. children are the pack biomes that can
|
||||
* generate inside it. Rarity is relative to the biome's siblings: higher is rarer.
|
||||
*/
|
||||
public record PackBiome(ResourceId id, String name, ResourceId platformBiome, int rarity, List<ResourceId> children) {
|
||||
public PackBiome {
|
||||
Objects.requireNonNull(id, "id");
|
||||
Objects.requireNonNull(name, "name");
|
||||
Objects.requireNonNull(platformBiome, "platformBiome");
|
||||
if (rarity < 1) throw new IllegalArgumentException("Biome rarity must be at least 1: " + rarity);
|
||||
children = List.copyOf(children);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.volmit.world;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/** A region of the loaded pack, found through {@code PackResources} by the id a {@link BiomeSample} gives.
|
||||
* The biome lists name the pack biomes the region generates on land, at sea, on shores and in caves.
|
||||
* Rarity is relative to the other regions: higher is rarer.
|
||||
*/
|
||||
public record PackRegion(ResourceId id, String name, int rarity, List<ResourceId> landBiomes,
|
||||
List<ResourceId> seaBiomes, List<ResourceId> shoreBiomes, List<ResourceId> caveBiomes) {
|
||||
public PackRegion {
|
||||
Objects.requireNonNull(id, "id");
|
||||
Objects.requireNonNull(name, "name");
|
||||
if (rarity < 1) throw new IllegalArgumentException("Region rarity must be at least 1: " + rarity);
|
||||
landBiomes = List.copyOf(landBiomes);
|
||||
seaBiomes = List.copyOf(seaBiomes);
|
||||
shoreBiomes = List.copyOf(shoreBiomes);
|
||||
caveBiomes = List.copyOf(caveBiomes);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user