Added OreGeneration, New generation mode

This commit is contained in:
Brian Fopiano 2021-12-29 18:31:56 -08:00
parent 824f74a4ce
commit 44beeec1d7
7 changed files with 149 additions and 2 deletions

View File

@ -21,6 +21,8 @@ package com.volmit.iris.engine.actuator;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedActuator;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.hunk.Hunk;
@ -76,16 +78,20 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
*/
@BlockCoordinates
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h) {
//
int zf, realX, realZ, hf, he;
IrisBiome biome;
IrisRegion region;
for (zf = 0; zf < h.getDepth(); zf++) {
realX = xf + x;
realZ = zf + z;
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
region = getComplex().getRegionStream().get(realX, realZ);
he = (int) Math.round(Math.min(h.getHeight(), getComplex().getHeightStream().get(realX, realZ)));
hf = Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he));
// this 0 is where we are going to need to modify the world base height, the Zero, not this instance...
if (hf < 0) {
continue;
}
@ -94,11 +100,13 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
KList<BlockData> fblocks = null;
int depth, fdepth;
// Fluid height and lower
for (int i = hf; i >= 0; i--) {
if (i >= h.getHeight()) {
if (i >= h.getHeight()) { // h.getheight is terrain height
continue;
}
// will need to change
if (i == 0) {
if (getDimension().isBedrock()) {
h.set(xf, i, zf, BEDROCK);
@ -123,6 +131,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
continue;
}
// top of surface
if (i <= he) {
depth = he - i;
if (blocks == null) {
@ -133,13 +142,23 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
getComplex());
}
if (blocks.hasIndex(depth)) {
h.set(xf, i, zf, blocks.get(depth));
continue;
}
BlockData ore = biome.generateOres(realX, i, realZ, rng, getData());
ore = ore == null ? region.generateOres(realX, i, realZ, rng, getData()) : ore;
ore = ore == null ? getDimension().generateOres(realX, i, realZ, rng, getData()) : ore;
if (ore != null) {
h.set(xf, i, zf, ore);
} else {
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
}
}
}
}
}

View File

@ -30,6 +30,7 @@ import com.volmit.iris.engine.modifier.IrisPerfectionModifier;
import com.volmit.iris.engine.modifier.IrisPostModifier;
import org.bukkit.block.data.BlockData;
public class ModeOverworld extends IrisEngineMode implements EngineMode {
public ModeOverworld(Engine engine) {
super(engine);

View File

@ -83,6 +83,8 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
positions.computeIfAbsent(Cache.key(rx, rz), (k) -> new KList<>()).qadd(yy);
//todo: Fix chunk decoration not working on chunk's border
if (rz < 15 && mantle.get(xx, yy, zz + 1, MatterCavern.class) == null) {
walls.put(new IrisPosition(rx, yy, rz + 1), c);
}

View File

@ -178,6 +178,24 @@ public class IrisBiome extends IrisRegistrant implements IRare {
@Desc("Define biome deposit generators that add onto the existing regional and global deposit generators")
private KList<IrisDepositGenerator> deposits = new KList<>();
private transient InferredType inferredType;
@Desc("Collection of ores to be generated")
@ArrayType(type = IrisOreGenerator.class, min = 1)
private KList<IrisOreGenerator> ores = new KList<>();
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
if (ores.isEmpty()) {
return null;
}
BlockData b = null;
for (IrisOreGenerator i : ores) {
b = i.generate(x,y,z,rng,data);
if(b != null ){
return b;
}
}
return null;
}
public Biome getVanillaDerivative() {
return vanillaDerivative == null ? derivative : vanillaDerivative;

View File

@ -221,6 +221,24 @@ public class IrisDimension extends IrisRegistrant {
private IrisMaterialPalette fluidPalette = new IrisMaterialPalette().qclear().qadd("water");
@Desc("Cartographer map trade overrides")
private IrisVillagerOverride patchCartographers = new IrisVillagerOverride().setDisableTrade(false);
@Desc("Collection of ores to be generated")
@ArrayType(type = IrisOreGenerator.class, min = 1)
private KList<IrisOreGenerator> ores = new KList<>();
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
if (ores.isEmpty()) {
return null;
}
BlockData b = null;
for (IrisOreGenerator i : ores) {
b = i.generate(x,y,z,rng,data);
if(b != null ){
return b;
}
}
return null;
}
public KList<Position2> getStrongholds(long seed) {
return strongholdsCache.aquire(() -> {

View File

@ -0,0 +1,70 @@
/*
* 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.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.noise.CNG;
import jdk.jfr.Description;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Ore Layer")
@Data
public class IrisOreGenerator {
@Desc("The palette of 'ore' generated")
private IrisMaterialPalette palette = new IrisMaterialPalette().qclear();
@Desc("The generator style for the 'ore'")
private IrisGeneratorStyle chanceStyle = new IrisGeneratorStyle(NoiseStyle.STATIC);
@Desc("Will ores generate on the surface of the terrain layer")
private boolean generateSurface = false;
@Desc("Threshold for rate of generation")
private double threshold = 0.5;
@Desc("Height limit (min, max)")
private IrisRange range = new IrisRange(30, 80);
private transient AtomicCache<CNG> chanceCache = new AtomicCache<>();
public BlockData generate(int x, int y, int z, RNG rng, IrisData data){
if(palette.getPalette().isEmpty()){
return null;
}
if(!range.contains(y)){
return null;
}
CNG chance = chanceCache.aquire(() -> chanceStyle.create(rng, data));
if (chance.noise(x,y,z ) > threshold){
return null;
}
return palette.get( rng, x,y,z, data);
}
}

View File

@ -44,6 +44,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import org.bukkit.block.data.BlockData;
import java.awt.Color;
import java.util.Random;
@ -176,6 +177,24 @@ public class IrisRegion extends IrisRegistrant implements IRare {
private double riverThickness = 0.1;
@Desc("A color for visualizing this region with a color. I.e. #F13AF5. This will show up on the map.")
private String color = null;
@Desc("Collection of ores to be generated")
@ArrayType(type = IrisOreGenerator.class, min = 1)
private KList<IrisOreGenerator> ores = new KList<>();
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
if (ores.isEmpty()) {
return null;
}
BlockData b = null;
for (IrisOreGenerator i : ores) {
b = i.generate(x,y,z,rng,data);
if(b != null ){
return b;
}
}
return null;
}
public String getName() {
return name;