Decorator Updates and Fixes - Season 2

- Added SEA_FLOOR type to decorators which will only place bellow sea level/in water
- Implemented CEILING type to decorators, which will allow stacked blocks to place from the top down
- Fixed height variance not being implemented properly. The height of stacked blocks is now correct

Dev notes: This WILL require updates to the overworld pack as fixing some of the bugs here made some workarounds in the overworld pack kinda break
This commit is contained in:
StrangeOne101 2021-07-10 03:34:11 +12:00
parent f1dfb1c952
commit 7652aca406
8 changed files with 85 additions and 29 deletions

View File

@ -52,6 +52,7 @@ public class IrisComplex implements DataProvider
private ProceduralStream<IrisDecorator> terrainCaveSurfaceDecoration; private ProceduralStream<IrisDecorator> terrainCaveSurfaceDecoration;
private ProceduralStream<IrisDecorator> terrainCaveCeilingDecoration; private ProceduralStream<IrisDecorator> terrainCaveCeilingDecoration;
private ProceduralStream<IrisDecorator> seaSurfaceDecoration; private ProceduralStream<IrisDecorator> seaSurfaceDecoration;
private ProceduralStream<IrisDecorator> seaFloorDecoration;
private ProceduralStream<IrisDecorator> shoreSurfaceDecoration; private ProceduralStream<IrisDecorator> shoreSurfaceDecoration;
private ProceduralStream<BlockData> rockStream; private ProceduralStream<BlockData> rockStream;
private ProceduralStream<BlockData> fluidStream; private ProceduralStream<BlockData> fluidStream;
@ -191,6 +192,8 @@ public class IrisComplex implements DataProvider
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SHORE_LINE)); .convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SHORE_LINE));
seaSurfaceDecoration = trueBiomeStream seaSurfaceDecoration = trueBiomeStream
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_SURFACE)); .convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_SURFACE));
seaFloorDecoration = trueBiomeStream
.convertAware2D((b, xx,zz) -> decorateFor(b, xx, zz, DecorationPart.SEA_FLOOR));
trueHeightStream = ProceduralStream.of((x, z) -> { trueHeightStream = ProceduralStream.of((x, z) -> {
int rx = (int) Math.round(engine.modifyX(x)); int rx = (int) Math.round(engine.modifyX(x));
int rz = (int) Math.round(engine.modifyZ(z)); int rz = (int) Math.round(engine.modifyZ(z));

View File

@ -1,5 +1,6 @@
package com.volmit.iris.generator.actuator; package com.volmit.iris.generator.actuator;
import com.volmit.iris.generator.decorator.IrisSeaFloorDecorator;
import com.volmit.iris.object.IrisBiome; import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.util.PrecisionStopwatch; import com.volmit.iris.util.PrecisionStopwatch;
import com.volmit.iris.util.RNG; import com.volmit.iris.util.RNG;
@ -28,6 +29,8 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
@Getter @Getter
private final EngineDecorator seaSurfaceDecorator; private final EngineDecorator seaSurfaceDecorator;
@Getter @Getter
private final EngineDecorator seaFloorDecorator;
@Getter
private final EngineDecorator shoreLineDecorator; private final EngineDecorator shoreLineDecorator;
private final boolean shouldRay; private final boolean shouldRay;
@ -39,6 +42,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
ceilingDecorator = new IrisCeilingDecorator(getEngine()); ceilingDecorator = new IrisCeilingDecorator(getEngine());
seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine()); seaSurfaceDecorator = new IrisSeaSurfaceDecorator(getEngine());
shoreLineDecorator = new IrisShoreLineDecorator(getEngine()); shoreLineDecorator = new IrisShoreLineDecorator(getEngine());
seaFloorDecorator = new IrisSeaFloorDecorator(getEngine());
} }
@Override @Override
@ -49,9 +53,7 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
} }
PrecisionStopwatch p = PrecisionStopwatch.start(); PrecisionStopwatch p = PrecisionStopwatch.start();
boolean solid;
int emptyFor = 0;
int lastSolid = 0;
int j, realX, realZ, height; int j, realX, realZ, height;
IrisBiome biome, cave; IrisBiome biome, cave;
@ -59,6 +61,9 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
{ {
for(j = 0; j < output.getDepth(); j++) for(j = 0; j < output.getDepth(); j++)
{ {
boolean solid;
int emptyFor = 0;
int lastSolid = 0;
realX = (int) Math.round(modX(x + i)); realX = (int) Math.round(modX(x + i));
realZ = (int) Math.round(modZ(z + j)); realZ = (int) Math.round(modZ(z + j));
height = (int) Math.round(getComplex().getHeightStream().get(realX, realZ)); height = (int) Math.round(getComplex().getHeightStream().get(realX, realZ));
@ -77,10 +82,16 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
realZ, (int) Math.round(modZ(z + j+1)), (int) Math.round(modZ(z + j-1)), realZ, (int) Math.round(modZ(z + j+1)), (int) Math.round(modZ(z + j-1)),
output, biome, height, getEngine().getHeight() - height); output, biome, height, getEngine().getHeight() - height);
} }
else if (height == getDimension().getFluidHeight() + 1)
{
getSeaSurfaceDecorator().decorate(i, j,
realX, (int) Math.round(modX(x + i+1)), (int) Math.round(modX(x + i-1)),
realZ, (int) Math.round(modZ(z + j+1)), (int) Math.round(modZ(z + j-1)),
output, biome, height, getEngine().getHeight() - getDimension().getFluidHeight());
}
else if(height < getDimension().getFluidHeight()) else if(height < getDimension().getFluidHeight())
{ {
getSeaSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, getDimension().getFluidHeight(), getEngine().getHeight() - getDimension().getFluidHeight()); getSeaFloorDecorator().decorate(i, j, realX, realZ, output, biome, height + 1, getDimension().getFluidHeight());
} }
getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height); getSurfaceDecorator().decorate(i, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
@ -93,18 +104,16 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData>
if(solid) if(solid)
{ {
if (emptyFor > 0) {
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid, emptyFor);
emptyFor = 0;
}
lastSolid = k; lastSolid = k;
} }
else
else {
emptyFor++;
}
if(solid && emptyFor > 0)
{ {
getCeilingDecorator().decorate(i, j, realX, realZ, output, cave, lastSolid, emptyFor); emptyFor++;
getSurfaceDecorator().decorate(i, j, realX, realZ, output, cave, k, emptyFor);
emptyFor = 0;
} }
} }
} }

View File

@ -22,16 +22,17 @@ public class IrisCeilingDecorator extends IrisEngineDecorator
{ {
if(!decorator.isStacking()) if(!decorator.isStacking())
{ {
data.set(x, height-1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
} }
else else
{ {
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
stack = Math.min(max + 1, stack);
for(int i = 0; i < stack; i++) for(int i = 0; i < stack; i++)
{ {
data.set(x, height-1-i, z, i == stack-1 ? decorator.getBlockDataForTop(biome, getRng(), realX+i, realZ-i, getData()) : decorator.getBlockData100(biome, getRng(), realX+i, realZ-i, getData())); data.set(x, height-i, z, i == 0 ? decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData()) : decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
} }
} }
} }

View File

@ -0,0 +1,45 @@
package com.volmit.iris.generator.decorator;
import com.volmit.iris.Iris;
import com.volmit.iris.object.DecorationPart;
import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.object.IrisDecorator;
import com.volmit.iris.scaffold.cache.Cache;
import com.volmit.iris.scaffold.engine.Engine;
import com.volmit.iris.scaffold.hunk.Hunk;
import org.bukkit.block.data.BlockData;
public class IrisSeaFloorDecorator extends IrisEngineDecorator
{
public IrisSeaFloorDecorator(Engine engine) {
super(engine, "Sea Floor", DecorationPart.SEA_FLOOR);
}
@Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
if(height <= getDimension().getFluidHeight()) {
IrisDecorator decorator = getDecorator(biome, realX, realZ);
if(decorator != null)
{
if(!decorator.isStacking())
{
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
}
else
{
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
stack = Math.min(stack, getDimension().getFluidHeight() - height + 2);
//Iris.info("Stack at " + realX + "," + realZ + " is " + stack);
BlockData top = decorator.getBlockDataForTop(biome, getRng(), realX, realZ, getData());
BlockData fill = decorator.getBlockData100(biome, getRng(), realX, realZ, getData());
for(int i = 0; i < stack; i++)
{
data.set(x, height+i, z, i == stack-1 ? top : fill);
}
}
}
}
}
}

View File

@ -16,7 +16,7 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator
@Override @Override
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) { public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
if(height < getDimension().getFluidHeight()) { if(height > getDimension().getFluidHeight()) {
{ {
IrisDecorator decorator = getDecorator(biome, realX, realZ); IrisDecorator decorator = getDecorator(biome, realX, realZ);
@ -26,10 +26,9 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator
{ {
data.set(x, getDimension().getFluidHeight()+1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); data.set(x, getDimension().getFluidHeight()+1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
} }
else else
{ {
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
for(int i = 0; i < stack; i++) for(int i = 0; i < stack; i++)
{ {

View File

@ -32,10 +32,9 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator
{ {
data.set(x, height+1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData())); data.set(x, height+1, z, decorator.getBlockData100(biome, getRng(), realX, realZ, getData()));
} }
else else
{ {
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
for(int i = 0; i < stack; i++) for(int i = 0; i < stack; i++)
{ {

View File

@ -62,14 +62,14 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator
data.set(x, height+1, z, bd); data.set(x, height+1, z, bd);
} }
else
else { {
if (height < getDimension().getFluidHeight()) if (height < getDimension().getFluidHeight())
{ {
max = getDimension().getFluidHeight() - height; max = getDimension().getFluidHeight() - height;
} }
int stack = Math.min(getRng().nextParallelRNG(Cache.key(realX, realZ)).i(decorator.getStackMin(), decorator.getStackMax()), max); int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
for(int i = 0; i < stack; i++) for(int i = 0; i < stack; i++)
{ {

View File

@ -85,7 +85,7 @@ public class IrisDecorator
return stackMin; return stackMin;
} }
return getHeightGenerator(rng, data).fit(stackMin, stackMax, x / heightVariance.getZoom(), z / heightVariance.getZoom()); return getHeightGenerator(rng, data).fit(stackMin, stackMax, x / heightVariance.getZoom(), z / heightVariance.getZoom()) + 1;
} }
public CNG getHeightGenerator(RNG rng, IrisDataManager data) public CNG getHeightGenerator(RNG rng, IrisDataManager data)
@ -134,7 +134,7 @@ public class IrisDecorator
return getBlockData(data).get(0); return getBlockData(data).get(0);
} }
return getVarianceGenerator(rng, data).fit(getBlockData(data), zz, xx); //X and Z must be switched return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x); //X and Z must be switched
} }
return null; return null;
@ -162,7 +162,7 @@ public class IrisDecorator
return getBlockData(data).get(0); return getBlockData(data).get(0);
} }
return getVarianceGenerator(rng, data).fit(getBlockData(data), zz, xx).clone(); //X and Z must be switched return getVarianceGenerator(rng, data).fit(getBlockData(data), z, x).clone(); //X and Z must be switched
} }
public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data) public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double z, IrisDataManager data)
@ -182,7 +182,7 @@ public class IrisDecorator
return getBlockDataTops(data).get(0); return getBlockDataTops(data).get(0);
} }
return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), zz, xx); //X and Z must be switched return getVarianceGenerator(rng, data).fit(getBlockDataTops(data), z, x); //X and Z must be switched
} }
return null; return null;