This commit is contained in:
Daniel Mills 2021-08-02 18:36:56 -04:00
parent 4b8cfd9fdd
commit 18c70002cb
17 changed files with 52 additions and 91 deletions

View File

@ -442,10 +442,8 @@ public class IrisProject {
JSONArray schemas = new JSONArray();
IrisData dm = new IrisData(getPath());
for(ResourceLoader<?> r : dm.getLoaders().v())
{
if(r.supportsSchemas())
{
for (ResourceLoader<?> r : dm.getLoaders().v()) {
if (r.supportsSchemas()) {
schemas.put(r.buildSchema());
}
}

View File

@ -166,13 +166,11 @@ public class SchemaBuilder {
}
if(k.isAnnotationPresent(RegistryListResource.class))
{
if (k.isAnnotationPresent(RegistryListResource.class)) {
RegistryListResource rr = k.getDeclaredAnnotation(RegistryListResource.class);
ResourceLoader<?> loader = data.getLoaders().get(rr.value());
if(loader != null)
{
if (loader != null) {
String key = "erz" + loader.getFolderName();
if (!definitions.containsKey(key)) {
@ -184,15 +182,10 @@ public class SchemaBuilder {
fancyType = "Iris " + loader.getResourceTypeName();
prop.put("$ref", "#/definitions/" + key);
description.add(SYMBOL_TYPE__N + " Must be a valid " + loader.getFolderName() + " (use ctrl+space for auto complete!)");
}
else
{
} else {
Iris.error("Cannot find Registry Loader for type " + rr.value() + " used in " + k.getDeclaringClass().getCanonicalName() + " in field " + k.getName());
}
}
else if (k.isAnnotationPresent(RegistryListMythical.class)) {
} else if (k.isAnnotationPresent(RegistryListMythical.class)) {
String key = "enum-reg-mythical";
if (!definitions.containsKey(key)) {
@ -354,13 +347,11 @@ public class SchemaBuilder {
case "string" -> {
fancyType = "List of Text";
if(k.isAnnotationPresent(RegistryListResource.class))
{
if (k.isAnnotationPresent(RegistryListResource.class)) {
RegistryListResource rr = k.getDeclaredAnnotation(RegistryListResource.class);
ResourceLoader<?> loader = data.getLoaders().get(rr.value());
if(loader != null)
{
if (loader != null) {
fancyType = "List<" + loader.getResourceTypeName() + ">";
String key = "erz" + loader.getFolderName();
@ -374,14 +365,10 @@ public class SchemaBuilder {
items.put("$ref", "#/definitions/" + key);
prop.put("items", items);
description.add(SYMBOL_TYPE__N + " Must be a valid " + loader.getResourceTypeName() + " (use ctrl+space for auto complete!)");
}
else
{
} else {
Iris.error("Cannot find Registry Loader for type (list schema) " + rr.value() + " used in " + k.getDeclaringClass().getCanonicalName() + " in field " + k.getName());
}
}
else if (k.isAnnotationPresent(RegistryListMythical.class)) {
} else if (k.isAnnotationPresent(RegistryListMythical.class)) {
fancyType = "List of Mythic Mob Types";
String key = "enum-reg-mythical";

View File

@ -77,29 +77,20 @@ public class IrisData {
return new IrisData(dataFolder);
}
private <T extends IrisRegistrant> ResourceLoader<T> registerLoader(Class<T> registrant)
{
try
{
private <T extends IrisRegistrant> ResourceLoader<T> registerLoader(Class<T> registrant) {
try {
IrisRegistrant rr = registrant.getConstructor().newInstance();
ResourceLoader<T> r = null;
if(registrant.equals(IrisObject.class))
{
if (registrant.equals(IrisObject.class)) {
r = (ResourceLoader<T>) new ObjectResourceLoader(dataFolder, this, rr.getFolderName(), rr.getTypeName());
}
else
{
} else {
r = new ResourceLoader<T>(dataFolder, this, rr.getFolderName(), rr.getTypeName(), registrant);
}
loaders.put(registrant, r);
return r;
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
Iris.error("Failed to create loader! " + registrant.getCanonicalName());
}
@ -136,8 +127,7 @@ public class IrisData {
return;
}
for(ResourceLoader<?> i : loaders.values())
{
for (ResourceLoader<?> i : loaders.values()) {
i.clearCache();
}
}
@ -147,8 +137,7 @@ public class IrisData {
return;
}
for(ResourceLoader<?> i : loaders.values())
{
for (ResourceLoader<?> i : loaders.values()) {
i.clearList();
}
}

View File

@ -74,15 +74,13 @@ public class ResourceLoader<T extends IrisRegistrant> {
Iris.debug("Loader<" + C.GREEN + resourceTypeName + C.LIGHT_PURPLE + "> created in " + C.RED + "IDM/" + manager.getId() + C.LIGHT_PURPLE + " on " + C.WHITE + manager.getDataFolder().getPath());
}
public JSONObject buildSchema()
{
public JSONObject buildSchema() {
Iris.debug("Building Schema " + objectClass.getSimpleName() + " " + root.getPath());
JSONObject o = new JSONObject();
KList<String> fm = new KList<>();
for(int g = 1; g < 8; g++)
{
fm.add("/" + root.getName() + Form.repeat("/*", g) + ".json");
for (int g = 1; g < 8; g++) {
fm.add("/" + folderName + Form.repeat("/*", g) + ".json");
}
o.put("fileMatch", new JSONArray(fm.toArray()));

View File

@ -18,6 +18,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.hunk.Hunk;
public abstract class EngineAssignedBiModifier<A, B> extends EngineAssignedComponent implements EngineBiModifier<A, B> {

View File

@ -18,6 +18,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.hunk.Hunk;
public interface EngineBiModifier<A, B> extends EngineComponent {

View File

@ -21,12 +21,11 @@ package com.volmit.iris.engine.noise;
import com.volmit.iris.engine.object.IrisExpression;
import com.volmit.iris.util.math.RNG;
public class ExpressionNoise implements NoiseGenerator{
public class ExpressionNoise implements NoiseGenerator {
private final RNG rng;
private final IrisExpression expression;
public ExpressionNoise(RNG rng, IrisExpression expression)
{
public ExpressionNoise(RNG rng, IrisExpression expression) {
this.rng = rng;
this.expression = expression;
}

View File

@ -29,8 +29,7 @@ public interface NoiseGenerator {
return false;
}
default boolean isNoScale()
{
default boolean isNoScale() {
return false;
}
}

View File

@ -31,8 +31,7 @@ public class WhiteNoise implements NoiseGenerator {
return true;
}
public boolean isNoScale()
{
public boolean isNoScale() {
return true;
}

View File

@ -25,8 +25,7 @@ import com.volmit.iris.engine.stream.ProceduralStream;
import java.util.function.Function;
@Desc("Represents a stream from the engine")
public enum IrisEngineStreamType
{
public enum IrisEngineStreamType {
@Desc("Represents the given slope at the x, z coordinates")
SLOPE((f) -> f.getComplex().getSlopeStream()),
@ -57,15 +56,13 @@ public enum IrisEngineStreamType
@Desc("Represents the identity of regions. Each region has a unique number (very large numbers)")
REGION_IDENTITY((f) -> f.getComplex().getRegionIdentityStream());
private Function<EngineFramework, ProceduralStream<Double>> getter;
private final Function<EngineFramework, ProceduralStream<Double>> getter;
private IrisEngineStreamType(Function<EngineFramework, ProceduralStream<Double>> getter)
{
IrisEngineStreamType(Function<EngineFramework, ProceduralStream<Double>> getter) {
this.getter = getter;
}
public ProceduralStream<Double> get(EngineFramework engine)
{
public ProceduralStream<Double> get(EngineFramework engine) {
return getter.apply(engine);
}
}

View File

@ -24,8 +24,7 @@ import com.volmit.iris.engine.object.annotations.Desc;
import java.util.function.Function;
@Desc("Represents a value from the engine")
public enum IrisEngineValueType
{
public enum IrisEngineValueType {
@Desc("Represents actual height of the engine")
ENGINE_HEIGHT((f) -> Double.valueOf(f.getEngine().getHeight())),
@ -42,15 +41,13 @@ public enum IrisEngineValueType
FLUID_HEIGHT((f) -> Double.valueOf(f.getComplex().getFluidHeight())),
;
private Function<EngineFramework, Double> getter;
private final Function<EngineFramework, Double> getter;
private IrisEngineValueType(Function<EngineFramework, Double> getter)
{
IrisEngineValueType(Function<EngineFramework, Double> getter) {
this.getter = getter;
}
public Double get(EngineFramework engine)
{
public Double get(EngineFramework engine) {
return getter.apply(engine);
}
}

View File

@ -40,13 +40,13 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Represents Block Data")
@Desc("Represents an Iris Expression")
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisExpression extends IrisRegistrant {
private static final Parser parser = new Parser();
@ArrayType(type = IrisExpression.class, min = 1)
@ArrayType(type = IrisExpressionLoad.class, min = 1)
@Desc("Variables to use in this expression")
private KList<IrisExpressionLoad> variables = new KList<>();
@ -85,8 +85,7 @@ public class IrisExpression extends IrisRegistrant {
});
}
public ProceduralStream<Double> stream(RNG rng)
{
public ProceduralStream<Double> stream(RNG rng) {
return streamCache.aquire(() -> ProceduralStream.of((x, z) -> evaluate(rng, x, z),
(x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE));
}

View File

@ -34,12 +34,12 @@ import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Represents Block Data")
@Desc("Represents a variable to use in your expression. Do not set the name to x, y, or z, also don't duplicate names.")
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisExpressionLoad {
@Required
@Desc("The variable to assign this value to")
@Desc("The variable to assign this value to. Do not set the name to x, y, or z")
private String name = "";
@Desc("If the style value is not defined, this value will be used")
@ -58,13 +58,11 @@ public class IrisExpressionLoad {
private transient AtomicCache<Double> valueCache = new AtomicCache<>();
public double getValue(RNG rng, IrisData data, double x, double z) {
if(engineValue != null)
{
if (engineValue != null) {
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
}
if(engineStreamValue != null)
{
if (engineStreamValue != null) {
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
}
@ -76,13 +74,11 @@ public class IrisExpressionLoad {
}
public double getValue(RNG rng, IrisData data, double x, double y, double z) {
if(engineValue != null)
{
if (engineValue != null) {
return valueCache.aquire(() -> engineValue.get(data.getEngine().getFramework()));
}
if(engineStreamValue != null)
{
if (engineStreamValue != null) {
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine().getFramework())).get(x, z);
}

View File

@ -22,7 +22,10 @@ import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.cache.AtomicCache;
import com.volmit.iris.engine.noise.CNG;
import com.volmit.iris.engine.noise.ExpressionNoise;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.object.annotations.MaxNumber;
import com.volmit.iris.engine.object.annotations.MinNumber;
import com.volmit.iris.engine.object.annotations.RegistryListResource;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
@ -75,12 +78,10 @@ public class IrisGeneratorStyle {
public CNG create(RNG rng, IrisData data) {
return cng.aquire(() ->
{
if(getExpression() != null)
{
if (getExpression() != null) {
IrisExpression e = data.getExpressionLoader().load(getExpression());
if(e != null)
{
if (e != null) {
CNG cng = new CNG(rng, new ExpressionNoise(rng, e), 1D, 1)
.bake().scale(1D / zoom).pow(exponent).bake();
cng.setTrueFracturing(axialFracturing);

View File

@ -75,7 +75,6 @@ public class IrisObject extends IrisRegistrant {
private transient AtomicCache<AxisAlignedBB> aabb = new AtomicCache<>();
public IrisObject(int w, int h, int d) {
blocks = new KMap<>();
states = new KMap<>();
@ -86,7 +85,7 @@ public class IrisObject extends IrisRegistrant {
}
public IrisObject() {
this(0,0,0);
this(0, 0, 0);
}
public AxisAlignedBB getAABB() {

View File

@ -18,6 +18,7 @@
package com.volmit.iris.engine.parallel;
import com.volmit.iris.engine.hunk.Hunk;
public interface BurstedHunk<T> extends Hunk<T> {