mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Drop feature classes
This commit is contained in:
parent
ccbd5b17d3
commit
1250c94600
@ -34,7 +34,6 @@ import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisEntity;
|
||||
import com.volmit.iris.engine.object.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.IrisGenerator;
|
||||
import com.volmit.iris.engine.object.IrisInterpolator;
|
||||
import com.volmit.iris.engine.object.IrisLootTable;
|
||||
|
@ -26,7 +26,6 @@ import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineTarget;
|
||||
import com.volmit.iris.engine.object.IObjectPlacer;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.IrisPosition;
|
||||
import com.volmit.iris.engine.object.TileData;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
@ -248,56 +247,6 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
}
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default List<IrisFeaturePositional> getFeaturesInChunk(Chunk c) {
|
||||
return getFeaturesInChunk(c.getX(), c.getZ());
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
default List<IrisFeaturePositional> getFeaturesInChunk(int x, int z) {
|
||||
return getMantle().getChunk(x, z).getFeatures();
|
||||
}
|
||||
|
||||
|
||||
@ChunkCoordinates
|
||||
default KList<IrisFeaturePositional> forEachFeature(Chunk c) {
|
||||
return forEachFeature((c.getX() << 4) + 8, (c.getZ() << 4) + 8);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default KList<IrisFeaturePositional> forEachFeature(double x, double z) {
|
||||
KList<IrisFeaturePositional> pos = new KList<>();
|
||||
|
||||
for (IrisFeaturePositional i : getEngine().getDimension().getSpecificFeatures()) {
|
||||
if (i.shouldFilter(x, z, getEngine().getComplex().getRng(), getData())) {
|
||||
pos.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
int s = getRealRadius();
|
||||
int i, j;
|
||||
int cx = (int) x >> 4;
|
||||
int cz = (int) z >> 4;
|
||||
|
||||
for (i = -s; i <= s; i++) {
|
||||
for (j = -s; j <= s; j++) {
|
||||
try {
|
||||
for (IrisFeaturePositional k : getFeaturesInChunk(i + cx, j + cz)) {
|
||||
if (k.shouldFilter(x, z, getEngine().getComplex().getRng(), getData())) {
|
||||
pos.add(k);
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Iris.error("FILTER ERROR" + " AT " + (cx + i) + " " + (j + cz));
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pos;
|
||||
}
|
||||
|
||||
default boolean queueRegenerate(int x, int z) {
|
||||
return false; // TODO:
|
||||
}
|
||||
|
@ -1,121 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
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.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.interpolation.InterpolationMethod;
|
||||
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@Snippet("feature")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Desc("Represents an Iris zone")
|
||||
public class IrisFeature {
|
||||
@Required
|
||||
@Desc("The block radius of this zone")
|
||||
private double blockRadius = 32;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("The chance an object that should be place actually will place. Set to below 1 to affect objects in this zone")
|
||||
private double objectChance = 1;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Apply a custom biome here")
|
||||
private String customBiome = null;
|
||||
|
||||
@MinNumber(0)
|
||||
@MaxNumber(1)
|
||||
@Desc("How much strength before the biome is applied.")
|
||||
private double biomeStrengthThreshold = 0.75;
|
||||
|
||||
@Desc("The interpolation radius of this zone")
|
||||
private double interpolationRadius = 7;
|
||||
|
||||
@MaxNumber(1)
|
||||
@MinNumber(0)
|
||||
@Desc("The strength of this effect")
|
||||
private double strength = 1;
|
||||
|
||||
@Desc("The interpolator to use for smoothing the strength")
|
||||
private InterpolationMethod interpolator = InterpolationMethod.BILINEAR_STARCAST_9;
|
||||
|
||||
@Desc("If set, this will shift the terrain height in blocks (up or down)")
|
||||
private double shiftHeight = 0;
|
||||
|
||||
@Desc("If set, this will force the terrain closer to the specified height.")
|
||||
private double convergeToHeight = -1;
|
||||
|
||||
@Desc("Multiplies the input noise")
|
||||
private double multiplyHeight = 1;
|
||||
|
||||
@Desc("Invert the zone so that anything outside this zone is affected.")
|
||||
private boolean invertZone = false;
|
||||
|
||||
@Desc("Fracture the radius ring with additional noise")
|
||||
private IrisGeneratorStyle fractureRadius = null;
|
||||
|
||||
@RegistryListResource(IrisSpawner.class)
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("Within this noise feature, use the following spawners")
|
||||
private KList<String> entitySpawners = new KList<>();
|
||||
|
||||
private transient AtomicCache<Double> actualRadius = new AtomicCache<>();
|
||||
|
||||
public static IrisFeature read(DataInputStream s) throws IOException {
|
||||
return new Gson().fromJson(s.readUTF(), IrisFeature.class);
|
||||
}
|
||||
|
||||
public double getActualRadius() {
|
||||
return actualRadius.aquire(() -> {
|
||||
double o = 0;
|
||||
|
||||
if (fractureRadius != null) {
|
||||
o += fractureRadius.getMaxFractureDistance();
|
||||
}
|
||||
|
||||
return o + IrisInterpolation.getRealRadius(getInterpolator(), getInterpolationRadius());
|
||||
});
|
||||
}
|
||||
|
||||
public void write(DataOutputStream s) throws IOException {
|
||||
s.writeUTF(new Gson().toJson(this));
|
||||
}
|
||||
|
||||
public int getRealSize() {
|
||||
return (int) Math.ceil((getActualRadius() + blockRadius) * 2);
|
||||
}
|
||||
}
|
@ -1,187 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.function.NoiseProvider;
|
||||
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.util.math.M;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
@Snippet("positional-feature")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@Desc("Represents an Iris zone")
|
||||
public class IrisFeaturePositional {
|
||||
private static double BLOCK = 1D / 256D; // TODO: WARNING HEIGHT
|
||||
@Required
|
||||
@Desc("The x coordinate of this zone")
|
||||
private int x;
|
||||
|
||||
@Required
|
||||
@Desc("The z coordinate of this zone")
|
||||
private int z;
|
||||
|
||||
@Required
|
||||
@Desc("The Terrain Feature to apply")
|
||||
private IrisFeature feature;
|
||||
|
||||
private transient AtomicCache<NoiseProvider> provider = new AtomicCache<>();
|
||||
|
||||
public IrisFeaturePositional(int x, int z, IrisFeature feature) {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
this.feature = feature;
|
||||
}
|
||||
|
||||
public static IrisFeaturePositional read(DataInputStream s) throws IOException {
|
||||
String sx = s.readUTF();
|
||||
try {
|
||||
return new Gson().fromJson(sx, IrisFeaturePositional.class);
|
||||
} catch (Throwable e) {
|
||||
Iris.error(sx);
|
||||
e.printStackTrace();
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void write(DataOutputStream s) throws IOException {
|
||||
s.writeUTF(new Gson().toJson(this));
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
public boolean shouldFilter(double x, double z, RNG rng, IrisData data) {
|
||||
double actualRadius = getFeature().getActualRadius();
|
||||
double dist2 = distance2(x, z, rng, data);
|
||||
|
||||
if (getFeature().isInvertZone()) {
|
||||
if (dist2 < Math.pow(getFeature().getBlockRadius() - actualRadius, 2)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return !(dist2 > Math.pow(getFeature().getBlockRadius() + actualRadius, 2));
|
||||
}
|
||||
|
||||
public double getStrength(double x, double z, RNG rng, IrisData data) {
|
||||
double actualRadius = getFeature().getActualRadius();
|
||||
double dist2 = distance2(x, z, rng, data);
|
||||
|
||||
if (getFeature().isInvertZone()) {
|
||||
if (dist2 < Math.pow(getFeature().getBlockRadius() - actualRadius, 2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NoiseProvider d = provider.aquire(() -> getNoiseProvider(rng, data));
|
||||
double s = IrisInterpolation.getNoise(getFeature().getInterpolator(), (int) x, (int) z, getFeature().getInterpolationRadius(), d);
|
||||
|
||||
if (s <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return getFeature().getStrength() * s;
|
||||
} else {
|
||||
if (dist2 > Math.pow(getFeature().getBlockRadius() + actualRadius, 2)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
NoiseProvider d = provider.aquire(() -> getNoiseProvider(rng, data));
|
||||
double s = IrisInterpolation.getNoise(getFeature().getInterpolator(), (int) x, (int) z, getFeature().getInterpolationRadius(), d);
|
||||
|
||||
if (s <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return getFeature().getStrength() * s;
|
||||
}
|
||||
}
|
||||
|
||||
public double getObjectChanceModifier(double x, double z, RNG rng, IrisData data) {
|
||||
if (getFeature().getObjectChance() >= 1) {
|
||||
return getFeature().getObjectChance();
|
||||
}
|
||||
|
||||
return M.lerp(1, getFeature().getObjectChance(), getStrength(x, z, rng, data));
|
||||
}
|
||||
|
||||
public IrisBiome filter(double x, double z, IrisBiome biome, RNG rng) {
|
||||
if (getFeature().getCustomBiome() != null) {
|
||||
if (getStrength(x, z, rng, biome.getLoader()) >= getFeature().getBiomeStrengthThreshold()) {
|
||||
IrisBiome b = biome.getLoader().getBiomeLoader().load(getFeature().getCustomBiome());
|
||||
b.setInferredType(biome.getInferredType());
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public double filter(double x, double z, double noise, RNG rng, IrisData data) {
|
||||
double s = getStrength(x, z, rng, data);
|
||||
|
||||
if (s <= 0) {
|
||||
return noise;
|
||||
}
|
||||
|
||||
double fx = noise;
|
||||
|
||||
if (getFeature().getConvergeToHeight() >= 0) {
|
||||
fx = getFeature().getConvergeToHeight();
|
||||
}
|
||||
|
||||
fx *= getFeature().getMultiplyHeight();
|
||||
fx += getFeature().getShiftHeight();
|
||||
|
||||
return M.lerp(noise, fx, s);
|
||||
}
|
||||
|
||||
public double distance(double x, double z, RNG rng, IrisData data) {
|
||||
double mul = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().getMultiplier() / 2 : 1;
|
||||
double mod = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().create(rng, data).fitDouble(-mul, mul, x, z) : 0;
|
||||
return Math.sqrt(Math.pow(this.x - (x + mod), 2) + Math.pow(this.z - (z + mod), 2));
|
||||
}
|
||||
|
||||
public double distance2(double x, double z, RNG rng, IrisData data) {
|
||||
double mul = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().getMultiplier() / 2 : 1;
|
||||
double mod = getFeature().getFractureRadius() != null ? getFeature().getFractureRadius().create(rng, data).fitDouble(-mul, mul, x, z) : 0;
|
||||
|
||||
return Math.pow(this.x - (x + mod), 2) + Math.pow(this.z - (z + mod), 2);
|
||||
}
|
||||
|
||||
private NoiseProvider getNoiseProvider(RNG rng, IrisData data) {
|
||||
if (getFeature().isInvertZone()) {
|
||||
return (x, z) -> distance(x, z, rng, data) > getFeature().getBlockRadius() ? 1D : 0D;
|
||||
} else {
|
||||
return (x, z) -> distance(x, z, rng, data) < getFeature().getBlockRadius() ? 1D : 0D;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2021 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.Data;
|
||||
|
||||
@Snippet("potential-feature")
|
||||
@Data
|
||||
@Desc("Represents a potential Iris zone")
|
||||
public class IrisFeaturePotential {
|
||||
@MinNumber(0)
|
||||
@Required
|
||||
@Desc("The rarity is 1 in X chance per chunk")
|
||||
private int rarity = 100;
|
||||
|
||||
@Required
|
||||
@Desc("")
|
||||
private IrisFeature zone = new IrisFeature();
|
||||
|
||||
@ChunkCoordinates
|
||||
public boolean hasZone(RNG rng, int cx, int cz) {
|
||||
return rng.nextInt(rarity) == 0;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user