mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Batch 2 of the API review: settings stacks, chunk helpers, pack context
- SettingsStack<F> replaces List<Entry<F>> wherever settings stack: entries in level order, values(), dimension(), level(Level) and mostSpecific(). - com.volmit.config.Level replaces FeatureAttachment.Target; FeatureAttachment folds into FeatureDescriptor.targets(). - FeatureSettings.declaredInChunk answers every entry any column of a chunk declares, each once. - ChunkContext gives chunkX/chunkZ, centreX/centreZ and area(). - registerSettings takes several types at once. - ModuleLifecycle.packLoaded(PackContext) carries resources, settings and the module's log. - TerrainSampler.surfaceHeight gives the surface in whole blocks. - Stage contexts drop worldSeed() and resources(); world() always answers. The scoped world is kept per world and module. - Javadoc fixes; README, DESIGN and CONTRACTS updated.
This commit is contained in:
1 parent
1677f4414b
commit
7143908d4b
67 files changed
+870
-423
No files matched your search
@@ -0,0 +1,31 @@
|
||||
package com.volmit.host;
|
||||
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.world.PackWorld;
|
||||
import java.util.Objects;
|
||||
|
||||
/** The views of worlds one module's stages get, whose log is the module's own ({@link PackWorld#withLog}). It keeps
|
||||
* the view of the world it was last asked for, so the stages of a host that generates one world per resolved graph
|
||||
* get it without a new view per invocation; a host that alternates worlds on one graph asks the world each time.
|
||||
* The kept world is released when the next one is asked for or the graph is dropped. Safe for concurrent use.
|
||||
*/
|
||||
final class ScopedWorlds {
|
||||
private final ModuleLog log;
|
||||
private volatile Scoped last;
|
||||
|
||||
ScopedWorlds(ModuleLog log) {
|
||||
this.log = Objects.requireNonNull(log, "log");
|
||||
}
|
||||
|
||||
PackWorld of(PackWorld world) {
|
||||
var scoped = last;
|
||||
if (scoped != null && scoped.world() == world) {
|
||||
return scoped.view();
|
||||
}
|
||||
var view = world.withLog(log);
|
||||
last = new Scoped(world, view);
|
||||
return view;
|
||||
}
|
||||
|
||||
private record Scoped(PackWorld world, PackWorld view) {}
|
||||
}
|
||||
Reference in new issue
Block a user