mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Biome ceiling floor wall & decorator support for caves
This commit is contained in:
parent
d2806c7ec0
commit
dd5f55f4fc
@ -18,11 +18,14 @@
|
|||||||
|
|
||||||
package com.volmit.iris.engine.modifier;
|
package com.volmit.iris.engine.modifier;
|
||||||
|
|
||||||
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.engine.IrisEngine;
|
import com.volmit.iris.engine.IrisEngine;
|
||||||
import com.volmit.iris.engine.actuator.IrisDecorantActuator;
|
import com.volmit.iris.engine.actuator.IrisDecorantActuator;
|
||||||
import com.volmit.iris.engine.data.cache.Cache;
|
import com.volmit.iris.engine.data.cache.Cache;
|
||||||
import com.volmit.iris.engine.framework.Engine;
|
import com.volmit.iris.engine.framework.Engine;
|
||||||
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
||||||
|
import com.volmit.iris.engine.object.basic.IrisPosition;
|
||||||
|
import com.volmit.iris.engine.object.biome.InferredType;
|
||||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||||
import com.volmit.iris.engine.object.decoration.IrisDecorationPart;
|
import com.volmit.iris.engine.object.decoration.IrisDecorationPart;
|
||||||
import com.volmit.iris.engine.object.decoration.IrisDecorator;
|
import com.volmit.iris.engine.object.decoration.IrisDecorator;
|
||||||
@ -33,8 +36,10 @@ import com.volmit.iris.util.format.Form;
|
|||||||
import com.volmit.iris.util.hunk.Hunk;
|
import com.volmit.iris.util.hunk.Hunk;
|
||||||
import com.volmit.iris.util.mantle.Mantle;
|
import com.volmit.iris.util.mantle.Mantle;
|
||||||
import com.volmit.iris.util.mantle.MantleChunk;
|
import com.volmit.iris.util.mantle.MantleChunk;
|
||||||
|
import com.volmit.iris.util.math.M;
|
||||||
import com.volmit.iris.util.math.RNG;
|
import com.volmit.iris.util.math.RNG;
|
||||||
import com.volmit.iris.util.matter.MatterCavern;
|
import com.volmit.iris.util.matter.MatterCavern;
|
||||||
|
import com.volmit.iris.util.scheduling.J;
|
||||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -58,6 +63,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
Mantle mantle = getEngine().getMantle().getMantle();
|
Mantle mantle = getEngine().getMantle().getMantle();
|
||||||
MantleChunk mc = getEngine().getMantle().getMantle().getChunk(x, z);
|
MantleChunk mc = getEngine().getMantle().getMantle().getChunk(x, z);
|
||||||
KMap<Long, KList<Integer>> positions = new KMap<>();
|
KMap<Long, KList<Integer>> positions = new KMap<>();
|
||||||
|
KMap<IrisPosition, MatterCavern> walls = new KMap<>();
|
||||||
|
|
||||||
mc.iterate(MatterCavern.class, (xx, yy, zz, c) -> {
|
mc.iterate(MatterCavern.class, (xx, yy, zz, c) -> {
|
||||||
if(yy > 256 || yy < 0)
|
if(yy > 256 || yy < 0)
|
||||||
@ -76,6 +82,18 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
|
|
||||||
positions.compute(Cache.key(rx, rz), (k,v) -> Objects.requireNonNullElseGet(v, (Supplier<KList<Integer>>) KList::new).qadd(yy));
|
positions.compute(Cache.key(rx, rz), (k,v) -> Objects.requireNonNullElseGet(v, (Supplier<KList<Integer>>) KList::new).qadd(yy));
|
||||||
|
|
||||||
|
if(rz < 15 && mantle.get(xx, yy, zz + 1, MatterCavern.class) == null)
|
||||||
|
{walls.put(new IrisPosition(rx, yy, rz + 1), c);}
|
||||||
|
|
||||||
|
if(rx < 15 && mantle.get(xx + 1, yy, zz, MatterCavern.class) == null)
|
||||||
|
{walls.put(new IrisPosition(rx + 1, yy, rz), c);}
|
||||||
|
|
||||||
|
if(rz > 0 && mantle.get(xx, yy, zz - 1, MatterCavern.class) == null)
|
||||||
|
{walls.put(new IrisPosition(rx, yy, rz - 1), c);}
|
||||||
|
|
||||||
|
if(rx > 0 && mantle.get(xx - 1, yy, zz, MatterCavern.class) == null)
|
||||||
|
{walls.put(new IrisPosition(rx - 1, yy, rz), c);}
|
||||||
|
|
||||||
if(current.getMaterial().isAir())
|
if(current.getMaterial().isAir())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -84,6 +102,22 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
output.set(rx, yy, rz, AIR);
|
output.set(rx, yy, rz, AIR);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
walls.forEach((i, v) -> {
|
||||||
|
IrisBiome biome = v.getCustomBiome().isEmpty()
|
||||||
|
? getEngine().getCaveBiome(i.getX() + (x << 4), i.getZ() + (z << 4))
|
||||||
|
: getEngine().getData().getBiomeLoader().load(v.getCustomBiome());
|
||||||
|
|
||||||
|
if(biome != null)
|
||||||
|
{
|
||||||
|
biome.setInferredType(InferredType.CAVE);
|
||||||
|
BlockData d = biome.getWall().get(rng, i.getX() + (x << 4), i.getY(), i.getZ() + (z << 4), getData());
|
||||||
|
|
||||||
|
if(d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ()))) {
|
||||||
|
output.set(i.getX(), i.getY(), i.getZ(), d);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
positions.forEach((k, v) -> {
|
positions.forEach((k, v) -> {
|
||||||
if(v.isEmpty())
|
if(v.isEmpty())
|
||||||
{
|
{
|
||||||
@ -96,6 +130,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
CaveZone zone = new CaveZone();
|
CaveZone zone = new CaveZone();
|
||||||
zone.setFloor(v.get(0));
|
zone.setFloor(v.get(0));
|
||||||
int buf = v.get(0) - 1;
|
int buf = v.get(0) - 1;
|
||||||
|
|
||||||
for(Integer i : v) {
|
for(Integer i : v) {
|
||||||
if (i < 0 || i > 255) {
|
if (i < 0 || i > 255) {
|
||||||
continue;
|
continue;
|
||||||
@ -115,6 +150,11 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
buf = i;
|
buf = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(zone.isValid())
|
||||||
|
{
|
||||||
|
processZone(output, mc, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
||||||
@ -125,22 +165,37 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
boolean decCeiling = B.isSolid(output.get(rx, zone.ceiling + 1, rz));
|
boolean decCeiling = B.isSolid(output.get(rx, zone.ceiling + 1, rz));
|
||||||
int center = (zone.floor + zone.ceiling) / 2;
|
int center = (zone.floor + zone.ceiling) / 2;
|
||||||
int thickness = zone.airThickness();
|
int thickness = zone.airThickness();
|
||||||
MatterCavern cavernData = (MatterCavern) mc.getOrCreate(center >> 4).slice(MatterCavern.class)
|
String customBiome = "";
|
||||||
.get(rx, center & 15, rz);
|
|
||||||
IrisBiome biome = cavernData.getCustomBiome().isEmpty() ? getEngine().getCaveBiome(xx, zz)
|
for(int i = zone.floor; i <= zone.ceiling; i++)
|
||||||
: getEngine().getData().getBiomeLoader().load(cavernData.getCustomBiome());
|
{
|
||||||
|
MatterCavern cavernData = (MatterCavern) mc.getOrCreate(i >> 4).slice(MatterCavern.class)
|
||||||
|
.get(rx, i & 15, rz);
|
||||||
|
|
||||||
|
if(cavernData != null && !cavernData.getCustomBiome().isEmpty())
|
||||||
|
{
|
||||||
|
customBiome = cavernData.getCustomBiome();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
IrisBiome biome = customBiome.isEmpty()
|
||||||
|
? getEngine().getCaveBiome(xx, zz)
|
||||||
|
: getEngine().getData().getBiomeLoader().load(customBiome);
|
||||||
|
|
||||||
if(biome == null)
|
if(biome == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
biome.setInferredType(InferredType.CAVE);
|
||||||
|
|
||||||
IrisDecorantActuator actuator = (IrisDecorantActuator) ((IrisEngine)getEngine()).getDecorantActuator();
|
IrisDecorantActuator actuator = (IrisDecorantActuator) ((IrisEngine)getEngine()).getDecorantActuator();
|
||||||
for(IrisDecorator i : biome.getDecorators()) {
|
for(IrisDecorator i : biome.getDecorators()) {
|
||||||
if (i.getPartOf().equals(IrisDecorationPart.NONE)) {
|
if (i.getPartOf().equals(IrisDecorationPart.NONE) && B.isSolid(output.get(rx, zone.getFloor()-1, rz))) {
|
||||||
actuator.getSurfaceDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getFloor() - 1, zone.getCeiling());
|
actuator.getSurfaceDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getFloor() - 1, zone.airThickness());
|
||||||
} else if (i.getPartOf().equals(IrisDecorationPart.CEILING)) {
|
} else if (i.getPartOf().equals(IrisDecorationPart.CEILING) && B.isSolid(output.get(rx, zone.getCeiling()+1, rz))) {
|
||||||
actuator.getCeilingDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getCeiling() + 1, zone.getFloor());
|
actuator.getCeilingDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getCeiling(), zone.airThickness());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,20 +208,40 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
output.set(rx, zone.floor - i, rz, blocks.get(i));
|
if(!B.isSolid(output.get(rx, zone.floor - i - 1, rz)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// blocks = biome.generateCeilingLayers(getDimension(), xx, zz, rng, 3, zone.floor, getData(), getComplex()).reverse();
|
if(B.isOre(output.get(rx, zone.floor - i - 1, rz)))
|
||||||
//
|
{
|
||||||
// for(int i = 0; i < zone.ceiling-1; i++)
|
continue;
|
||||||
// {
|
}
|
||||||
// if(!blocks.hasIndex(i))
|
|
||||||
// {
|
output.set(rx, zone.floor - i - 1, rz, blocks.get(i));
|
||||||
// break;
|
}
|
||||||
// }
|
|
||||||
//
|
blocks = biome.generateCeilingLayers(getDimension(), xx, zz, rng, 3, zone.ceiling, getData(), getComplex());
|
||||||
// output.set(rx, zone.ceiling + i, rz, blocks.get(i));
|
|
||||||
// }
|
for(int i = 0; i < zone.ceiling+1; i++)
|
||||||
|
{
|
||||||
|
if(!blocks.hasIndex(i))
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!B.isSolid(output.get(rx, zone.ceiling + i + 1, rz)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(B.isOre(output.get(rx, zone.ceiling + i + 1, rz)))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
output.set(rx, zone.ceiling + i + 1, rz, blocks.get(i));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@ -184,5 +259,10 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
|||||||
{
|
{
|
||||||
return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= 255 && airThickness() > 0;
|
return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= 255 && airThickness() > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return floor + "-" + ceiling;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user