mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 01:34:04 +00:00
Decide over vanilla structures through the structure module's vanilla structure hook: REPLACE where an Iris structure placement replaces the structure, ALSO_PLACE where a placement places it
This commit is contained in:
1 parent
f69d9128d5
commit
182fea6002
1 file changed
+22
@@ -22,14 +22,18 @@ import art.arcane.iris.builtin.IrisStages;
|
|||||||
import art.arcane.iris.core.modules.IrisMantleChunk;
|
import art.arcane.iris.core.modules.IrisMantleChunk;
|
||||||
import art.arcane.iris.core.modules.IrisPackSettings;
|
import art.arcane.iris.core.modules.IrisPackSettings;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.engine.framework.IrisStructureLocator;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureResources;
|
import art.arcane.iris.engine.framework.structure.StructureResources;
|
||||||
import art.arcane.iris.engine.framework.structure.StructureValidator;
|
import art.arcane.iris.engine.framework.structure.StructureValidator;
|
||||||
import com.volmit.FeatureRegistry;
|
import com.volmit.FeatureRegistry;
|
||||||
import com.volmit.IrisModule;
|
import com.volmit.IrisModule;
|
||||||
import com.volmit.ModuleInfo;
|
import com.volmit.ModuleInfo;
|
||||||
import com.volmit.config.PackSettings;
|
import com.volmit.config.PackSettings;
|
||||||
|
import com.volmit.resource.ResourceId;
|
||||||
import com.volmit.stage.MantleStageContext;
|
import com.volmit.stage.MantleStageContext;
|
||||||
import com.volmit.stage.StageGraph;
|
import com.volmit.stage.StageGraph;
|
||||||
|
import com.volmit.vanilla.VanillaStructureContext;
|
||||||
|
import com.volmit.vanilla.VanillaStructureRule;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module {@code iris:structure}: Iris structures, written into the mantle after objects, whose trees they clear
|
* Module {@code iris:structure}: Iris structures, written into the mantle after objects, whose trees they clear
|
||||||
@@ -39,6 +43,9 @@ import com.volmit.stage.StageGraph;
|
|||||||
* The module owns the pack's structures, jigsaw pools and jigsaw pieces as resource kinds
|
* The module owns the pack's structures, jigsaw pools and jigsaw pieces as resource kinds
|
||||||
* ({@link StructureResources}), read from the folders packs have always used, and checks them with
|
* ({@link StructureResources}), read from the folders packs have always used, and checks them with
|
||||||
* {@link StructureValidator} wherever Iris validates a pack.
|
* {@link StructureValidator} wherever Iris validates a pack.
|
||||||
|
* <p>
|
||||||
|
* It decides over the platform's own structures through its vanilla structure hook ({@link #vanillaRule}): a structure
|
||||||
|
* an Iris structure replaces is blocked, and one a structure placement of the pack places is reported as placed here.
|
||||||
*/
|
*/
|
||||||
public final class StructureModule implements IrisModule {
|
public final class StructureModule implements IrisModule {
|
||||||
private static final String VERSION = "built-in";
|
private static final String VERSION = "built-in";
|
||||||
@@ -58,6 +65,21 @@ public final class StructureModule implements IrisModule {
|
|||||||
public void register(FeatureRegistry registry) {
|
public void register(FeatureRegistry registry) {
|
||||||
StructureResources.kinds().forEach(registry::registerResourceKind);
|
StructureResources.kinds().forEach(registry::registerResourceKind);
|
||||||
registry.registerValidator(new StructureValidator());
|
registry.registerValidator(new StructureValidator());
|
||||||
|
registry.registerVanillaStructureHook(StructureModule::vanillaRule);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@link VanillaStructureRule#REPLACE} for a platform structure that an Iris structure of the world's placements
|
||||||
|
* replaces (its {@code vanillaSource} with native suppression), {@link VanillaStructureRule#ALSO_PLACE} for one
|
||||||
|
* a placement of the world places itself, {@link VanillaStructureRule#GENERATE} otherwise.
|
||||||
|
*/
|
||||||
|
static VanillaStructureRule vanillaRule(ResourceId structure, VanillaStructureContext context) {
|
||||||
|
Engine engine = IrisPackSettings.of(context.settings()).engine();
|
||||||
|
String key = structure.toString();
|
||||||
|
if (IrisStructureLocator.suppressesVanilla(engine, key)) {
|
||||||
|
return VanillaStructureRule.REPLACE;
|
||||||
|
}
|
||||||
|
return IrisStructureLocator.isPlaced(engine, key) ? VanillaStructureRule.ALSO_PLACE : VanillaStructureRule.GENERATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void place(MantleStageContext context) {
|
private static void place(MantleStageContext context) {
|
||||||
|
|||||||
Reference in new issue
Block a user