mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
add global preprocessor setting
This commit is contained in:
parent
73787e21d2
commit
b6f9f68b9f
@ -250,9 +250,19 @@ public class IrisData implements ExclusionStrategy, TypeAdapterFactory {
|
||||
}
|
||||
}
|
||||
|
||||
if (engine != null && t.getPreprocessors().isNotEmpty()) {
|
||||
if (engine == null) return;
|
||||
var global = engine.getDimension().getPreProcessors(t.getFolderName());
|
||||
var local = t.getPreprocessors();
|
||||
if ((global != null && global.isNotEmpty()) || local.isNotEmpty()) {
|
||||
synchronized (this) {
|
||||
for (String i : t.getPreprocessors()) {
|
||||
if (global != null) {
|
||||
for (String i : global) {
|
||||
engine.getExecution().preprocessObject(i, t);
|
||||
Iris.debug("Loader<" + C.GREEN + t.getTypeName() + C.LIGHT_PURPLE + "> iprocess " + C.YELLOW + t.getLoadKey() + C.LIGHT_PURPLE + " in <rainbow>" + i);
|
||||
}
|
||||
}
|
||||
|
||||
for (String i : local) {
|
||||
engine.getExecution().preprocessObject(i, t);
|
||||
Iris.debug("Loader<" + C.GREEN + t.getTypeName() + C.LIGHT_PURPLE + "> iprocess " + C.YELLOW + t.getLoadKey() + C.LIGHT_PURPLE + " in <rainbow>" + i);
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ import com.volmit.iris.core.nms.datapack.IDataFixer;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.collection.KSet;
|
||||
import com.volmit.iris.util.data.DataProvider;
|
||||
import com.volmit.iris.util.io.IO;
|
||||
@ -66,6 +67,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private final transient AtomicCache<Double> rad = new AtomicCache<>();
|
||||
private final transient AtomicCache<Boolean> featuresUsed = new AtomicCache<>();
|
||||
private final transient AtomicCache<KList<Position2>> strongholdsCache = new AtomicCache<>();
|
||||
private final transient AtomicCache<KMap<String, KList<String>>> cachedPreProcessors = new AtomicCache<>();
|
||||
@MinNumber(2)
|
||||
@Required
|
||||
@Desc("The human readable name of this dimension")
|
||||
@ -244,6 +246,10 @@ public class IrisDimension extends IrisRegistrant {
|
||||
@MaxNumber(318)
|
||||
@Desc("The Subterrain Fluid Layer Height")
|
||||
private int caveLavaHeight = 8;
|
||||
@MinNumber(1)
|
||||
@Desc("A list of globally applied pre-processors")
|
||||
@ArrayType(type = IrisPreProcessors.class)
|
||||
private KList<IrisPreProcessors> globalPreProcessors = new KList<>();
|
||||
|
||||
public int getMaxHeight() {
|
||||
return (int) getDimensionHeight().getMax();
|
||||
@ -362,6 +368,17 @@ public class IrisDimension extends IrisRegistrant {
|
||||
return r;
|
||||
}
|
||||
|
||||
public KList<String> getPreProcessors(String type) {
|
||||
return cachedPreProcessors.aquire(() -> {
|
||||
KMap<String, KList<String>> preProcessors = new KMap<>();
|
||||
for (var entry : globalPreProcessors) {
|
||||
preProcessors.computeIfAbsent(entry.getType(), k -> new KList<>())
|
||||
.addAll(entry.getScripts());
|
||||
}
|
||||
return preProcessors;
|
||||
}).get(type);
|
||||
}
|
||||
|
||||
public IrisGeneratorStyle getBiomeStyle(InferredType type) {
|
||||
switch (type) {
|
||||
case CAVE:
|
||||
|
@ -0,0 +1,25 @@
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.*;
|
||||
import com.volmit.iris.engine.object.annotations.functions.ResourceLoadersFunction;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Desc("Represents global preprocessors")
|
||||
public class IrisPreProcessors {
|
||||
@Required
|
||||
@Desc("The preprocessor type")
|
||||
@RegistryListFunction(ResourceLoadersFunction.class)
|
||||
private String type = "dimension";
|
||||
|
||||
@Required
|
||||
@Desc("The preprocessor scripts")
|
||||
@RegistryListResource(IrisScript.class)
|
||||
@ArrayType(type = String.class, min = 1)
|
||||
private KList<String> scripts = new KList<>();
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package com.volmit.iris.engine.object.annotations.functions;
|
||||
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.loader.ResourceLoader;
|
||||
import com.volmit.iris.engine.framework.ListFunction;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
|
||||
public class ResourceLoadersFunction implements ListFunction<KList<String>> {
|
||||
@Override
|
||||
public String key() {
|
||||
return "resource-loader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String fancyName() {
|
||||
return "Resource Loader";
|
||||
}
|
||||
|
||||
@Override
|
||||
public KList<String> apply(IrisData data) {
|
||||
return data.getLoaders()
|
||||
.values()
|
||||
.stream()
|
||||
.filter(rl -> ResourceLoader.class.equals(rl.getClass()))
|
||||
.map(ResourceLoader::getFolderName)
|
||||
.collect(KList.collector());
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user