mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Biome implosion
This commit is contained in:
parent
9f3e5fea38
commit
460be03a20
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>bytecode.ninja</groupId>
|
||||
<artifactId>Iris</artifactId>
|
||||
<version>1.0.25</version>
|
||||
<version>1.0.26</version>
|
||||
<name>Iris</name>
|
||||
<properties>
|
||||
<skip.copy>false</skip.copy>
|
||||
|
@ -0,0 +1,125 @@
|
||||
package com.minelazz.epicworldgenerator.structures;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.object.IrisObject;
|
||||
import com.volmit.iris.util.B;
|
||||
import com.volmit.iris.util.FastBlockData;
|
||||
|
||||
public class StructureObject implements Serializable
|
||||
{
|
||||
public static final String MESSAGE0 = "This was created from .ewg serialization files";
|
||||
public static final String MESSAGE1 = "This is not copied code, it is intended to ";
|
||||
public static final String MESSAGE2 = "be used so that people can convert EWG files";
|
||||
public static final String MESSAGE3 = "into .IOB files (iris objects)";
|
||||
|
||||
public static IrisObject convert(File so) throws IOException, ClassNotFoundException
|
||||
{
|
||||
FileInputStream fin = new FileInputStream(so);
|
||||
ObjectInputStream in = new ObjectInputStream(fin);
|
||||
StructureObject o = (StructureObject) in.readObject();
|
||||
int maxX = 0;
|
||||
int maxY = 0;
|
||||
int maxZ = 0;
|
||||
int minX = 0;
|
||||
int minY = 0;
|
||||
int minZ = 0;
|
||||
|
||||
for(SOBlock i : o.blocks)
|
||||
{
|
||||
maxX = maxX < i.x ? i.x : maxX;
|
||||
maxY = maxY < i.y ? i.y : maxY;
|
||||
maxZ = maxZ < i.z ? i.z : maxZ;
|
||||
minX = minX > i.x ? i.x : minX;
|
||||
minY = minY > i.y ? i.y : minY;
|
||||
minZ = minZ > i.z ? i.z : minZ;
|
||||
}
|
||||
|
||||
IrisObject iob = new IrisObject(maxX - minX, maxY - minY, maxZ - minZ);
|
||||
|
||||
for(SOBlock i : o.blocks)
|
||||
{
|
||||
BlockData bdx = null;
|
||||
|
||||
if(i.blockData == null)
|
||||
{
|
||||
FastBlockData f = map(i.id, i.data);
|
||||
bdx = f == null ? null : f.getBlockData();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
bdx = B.get(i.blockData).getBlockData();
|
||||
}
|
||||
|
||||
if(bdx != null)
|
||||
{
|
||||
iob.getBlocks().put(new BlockVector(i.x, i.y, i.z), FastBlockData.of(bdx));
|
||||
Iris.info("Mapped " + i.x + " " + i.y + " " + i.z + " to " + bdx.getAsString(true));
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static final FastBlockData map(int id, int dat)
|
||||
{
|
||||
for(Material i : Material.values())
|
||||
{
|
||||
if(!i.isLegacy())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if(i.getId() == id)
|
||||
{
|
||||
return FastBlockData.of(Bukkit.getUnsafe().fromLegacy(i, (byte) dat));
|
||||
}
|
||||
}
|
||||
|
||||
Iris.warn("Unknown Type " + id + ":" + dat);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -905274143366977303L;
|
||||
|
||||
public SOBlock[] blocks;
|
||||
public String name;
|
||||
|
||||
public final class SOBlock implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 2610063934261982315L;
|
||||
public final int x;
|
||||
public final int y;
|
||||
public final int z;
|
||||
public final int id;
|
||||
public final int data;
|
||||
public String meta;
|
||||
public String blockData;
|
||||
final StructureObject ref;
|
||||
|
||||
public SOBlock(StructureObject structureObject, int x, int y, int z, String string)
|
||||
{
|
||||
this.ref = structureObject;
|
||||
meta = null;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
id = -1;
|
||||
data = 0;
|
||||
blockData = string;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.volmit.iris.link.CitizensLink;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
@ -24,6 +23,7 @@ import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
||||
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||
import com.volmit.iris.link.CitizensLink;
|
||||
import com.volmit.iris.link.MultiverseCoreLink;
|
||||
import com.volmit.iris.link.MythicMobsLink;
|
||||
import com.volmit.iris.manager.EditManager;
|
||||
@ -85,7 +85,7 @@ public class Iris extends MortarPlugin
|
||||
instance = this;
|
||||
INMS.get();
|
||||
IO.delete(new File("iris"));
|
||||
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4gb
|
||||
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4g
|
||||
}
|
||||
|
||||
public static int getThreadCount()
|
||||
|
@ -4,9 +4,11 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.layer.GenLayerBiome;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.Interpolated;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.InferredType;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisBiomePaletteLayer;
|
||||
@ -22,12 +24,14 @@ import lombok.Data;
|
||||
@Data
|
||||
public class IrisComplex implements DataProvider
|
||||
{
|
||||
private RNG rng;
|
||||
private IrisDataManager data;
|
||||
private KList<IrisGenerator> generators;
|
||||
private static final BlockData AIR = Material.AIR.createBlockData();
|
||||
private ProceduralStream<IrisRegion> regionStream;
|
||||
private ProceduralStream<InferredType> bridgeStream;
|
||||
private ProceduralStream<IrisBiome> landBiomeStream;
|
||||
private ProceduralStream<IrisBiome> caveBiomeStream;
|
||||
private ProceduralStream<IrisBiome> seaBiomeStream;
|
||||
private ProceduralStream<IrisBiome> shoreBiomeStream;
|
||||
private ProceduralStream<IrisBiome> baseBiomeStream;
|
||||
@ -47,7 +51,7 @@ public class IrisComplex implements DataProvider
|
||||
switch(type)
|
||||
{
|
||||
case CAVE:
|
||||
break;
|
||||
return caveBiomeStream;
|
||||
case DEFER:
|
||||
break;
|
||||
case LAKE:
|
||||
@ -69,6 +73,7 @@ public class IrisComplex implements DataProvider
|
||||
|
||||
public void flash(long seed, IrisDimension dimension, IrisDataManager data)
|
||||
{
|
||||
this.rng = new RNG(seed);
|
||||
this.data = data;
|
||||
double fluidHeight = dimension.getFluidHeight();
|
||||
generators = new KList<>();
|
||||
@ -89,24 +94,31 @@ public class IrisComplex implements DataProvider
|
||||
.select(dimension.getRegions())
|
||||
.convertCached((s) -> data.getRegionLoader().load(s))
|
||||
.cache2D(1024);
|
||||
caveBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getCaveBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getCaveBiomeZoom())
|
||||
.selectRarity(r.getCaveBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
landBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getLandBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getLandBiomeZoom())
|
||||
.select(r.getLandBiomes())
|
||||
.selectRarity(r.getLandBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
seaBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getSeaBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getSeaBiomeZoom())
|
||||
.select(r.getSeaBiomes())
|
||||
.selectRarity(r.getSeaBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
shoreBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getShoreBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getShoreBiomeZoom())
|
||||
.select(r.getShoreBiomes())
|
||||
.selectRarity(r.getShoreBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
@ -114,6 +126,7 @@ public class IrisComplex implements DataProvider
|
||||
.convert((v) -> v >= dimension.getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
|
||||
? seaBiomeStream.get(x, z) : landBiomeStream.get(x, z))
|
||||
.convertAware2D(this::implode)
|
||||
.cache2D(1024);
|
||||
heightStream = baseBiomeStream.convertAware2D((b, x, z) -> getHeight(b, x, z, seed))
|
||||
.forceDouble().add(fluidHeight).roundDouble()
|
||||
@ -163,6 +176,36 @@ public class IrisComplex implements DataProvider
|
||||
//@done
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z)
|
||||
{
|
||||
if(b.getChildren().isEmpty())
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
return implode(b, x, z, 3);
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z, int max)
|
||||
{
|
||||
if(max < 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
if(b.getChildren().isEmpty())
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
CNG childCell = b.getChildrenGenerator(rng, 123, b.getChildShrinkFactor());
|
||||
KList<IrisBiome> chx = b.getRealChildren(this).copy();
|
||||
chx.add(b);
|
||||
IrisBiome biome = childCell.fitRarity(chx, x, z);
|
||||
biome.setInferredType(b.getInferredType());
|
||||
return implode(biome, x, z, max - 1);
|
||||
}
|
||||
|
||||
private IrisBiome fixBiomeType(Double height, IrisBiome biome, IrisRegion region, Double x, Double z, double fluidHeight)
|
||||
{
|
||||
double sh = region.getShoreHeight(x, z);
|
||||
|
@ -30,6 +30,8 @@ import com.volmit.iris.gen.v2.scaffold.stream.ZoomStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
import com.volmit.iris.util.Function4;
|
||||
import com.volmit.iris.util.IRare;
|
||||
import com.volmit.iris.util.KList;
|
||||
|
||||
public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
{
|
||||
@ -218,6 +220,26 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
return new SelectionStream<V>(this, types);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default <V> ProceduralStream<V> selectRarity(V... types)
|
||||
{
|
||||
KList<V> rarityTypes = new KList<>();
|
||||
|
||||
for(V i : types)
|
||||
{
|
||||
rarityTypes.addMultiple(i, IRare.get(i));
|
||||
}
|
||||
|
||||
return new SelectionStream<V>(this, rarityTypes);
|
||||
}
|
||||
|
||||
default <V> ProceduralStream<V> selectRarity(List<V> types)
|
||||
{
|
||||
KList<V> rarityTypes = new KList<>();
|
||||
types.forEach((i) -> rarityTypes.addMultiple(i, IRare.get(i)));
|
||||
return new SelectionStream<V>(this, rarityTypes);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> clamp(double min, double max)
|
||||
{
|
||||
return new ClampedStream<T>(this, min, max);
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.block.Biome;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.ContextualTerrainProvider;
|
||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.gen.v2.DataProvider;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.util.ArrayType;
|
||||
@ -611,7 +612,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z));
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealChildren(ContextualTerrainProvider g)
|
||||
public KList<IrisBiome> getRealChildren(DataProvider g)
|
||||
{
|
||||
return realChildren.aquire(() ->
|
||||
{
|
||||
@ -619,7 +620,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
|
||||
for(String i : getChildren())
|
||||
{
|
||||
realChildren.add(g != null ? g.loadBiome(i) : Iris.globaldata.getBiomeLoader().load(i));
|
||||
realChildren.add(g != null ? g.getData().getBiomeLoader().load(i) : Iris.globaldata.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
return realChildren;
|
||||
|
@ -1,5 +1,11 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
public interface IRare {
|
||||
public interface IRare
|
||||
{
|
||||
public int getRarity();
|
||||
|
||||
public static int get(Object v)
|
||||
{
|
||||
return v instanceof IRare ? ((IRare) v).getRarity() : 1;
|
||||
}
|
||||
}
|
||||
|
@ -51,6 +51,14 @@ public class KList<T> extends ArrayList<T> implements List<T>
|
||||
return this;
|
||||
}
|
||||
|
||||
public void addMultiple(T t, int c)
|
||||
{
|
||||
for(int i = 0; i < c; i++)
|
||||
{
|
||||
add(t);
|
||||
}
|
||||
}
|
||||
|
||||
private KList<T> add(Enumeration<T> e)
|
||||
{
|
||||
while(e.hasMoreElements())
|
||||
|
Loading…
x
Reference in New Issue
Block a user