mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Repush
This commit is contained in:
parent
a4d72eefbc
commit
bfe7cf0ed7
1
pom.xml
1
pom.xml
@ -1,4 +1,3 @@
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
@ -82,6 +82,7 @@ public class Iris extends MortarPlugin
|
||||
|
||||
public Iris()
|
||||
{
|
||||
instance = this;
|
||||
INMS.get();
|
||||
IO.delete(new File("iris"));
|
||||
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4gb
|
||||
|
@ -104,14 +104,7 @@ public abstract class ParallelTerrainProvider extends DimensionalTerrainProvider
|
||||
getMetrics().getTerrain().put(p.getMilliseconds());
|
||||
p = PrecisionStopwatch.start();
|
||||
onPostGenerate(random, x, z, terrain, height, biomeMap, map);
|
||||
return GeneratedChunk.builder()
|
||||
.biomeMap(biomeMap)
|
||||
.sliverMap(map)
|
||||
.height(height)
|
||||
.terrain(terrain)
|
||||
.x(x)
|
||||
.z(z)
|
||||
.build();
|
||||
return GeneratedChunk.builder().biomeMap(biomeMap).sliverMap(map).height(height).terrain(terrain).x(x).z(z).build();
|
||||
}
|
||||
|
||||
protected void onClose()
|
||||
|
@ -1,18 +1,131 @@
|
||||
package com.volmit.iris.generator.scaffold;
|
||||
package com.volmit.iris.generator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.generator.atomics.HeightHunk;
|
||||
import com.volmit.iris.generator.atomics.TerrainHunk;
|
||||
import com.volmit.iris.generator.scaffold.TerrainStream;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.NoiseStyle;
|
||||
import com.volmit.iris.util.RNG;
|
||||
|
||||
public class IrisTerrainStream implements TerrainStream
|
||||
{
|
||||
private CNG cng = NoiseStyle.IRIS_DOUBLE.create(new RNG(1234)).scale(0.5);
|
||||
private static final BlockData STONE = Material.STONE.createBlockData();
|
||||
|
||||
@Override
|
||||
public TerrainHunk generate(int x1, int z1, int x2, int z2)
|
||||
public long getSeed()
|
||||
{
|
||||
return null;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerrainHunk generate(int x, int z)
|
||||
public int getHeight()
|
||||
{
|
||||
return null;
|
||||
return 64;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNoise(int x, int z)
|
||||
{
|
||||
return (int) Math.round(cng.fitDouble(0, getHeight() - 1, (double) x, (double) z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public HeightHunk genNoise(int x1, int z1, int x2, int z2)
|
||||
{
|
||||
HeightHunk b = new HeightHunk(x2 - x1, z2 - z1);
|
||||
|
||||
for(int i = 0; i < b.getW(); i++)
|
||||
{
|
||||
for(int j = 0; j < b.getD(); j++)
|
||||
{
|
||||
b.setHeight(i, getNoise(i + x1, j + z1), j);
|
||||
}
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerrainHunk genCarving(int x1, int z1, int x2, int z2, HeightHunk noise)
|
||||
{
|
||||
TerrainHunk t = new TerrainHunk(noise.getW(), getHeight(), noise.getD(), noise);
|
||||
|
||||
for(int i = 0; i < t.getW(); i++)
|
||||
{
|
||||
for(int k = 0; k < t.getD(); k++)
|
||||
{
|
||||
int height = t.getHeight().getHeight(i, k);
|
||||
|
||||
for(int j = 0; j <= height; j++)
|
||||
{
|
||||
t.setBlock(i, j, k, STONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerrainHunk genTerrain(int x1, int z1, int x2, int z2, TerrainHunk t)
|
||||
{
|
||||
boolean hard = false;
|
||||
int lastHard = 255;
|
||||
|
||||
for(int i = 0; i < t.getW(); i++)
|
||||
{
|
||||
for(int k = 0; k < t.getW(); k++)
|
||||
{
|
||||
int height = t.getHeight().getHeight(i, k);
|
||||
|
||||
for(int j = height; j >= 0; j--)
|
||||
{
|
||||
boolean _hard = !t.getBlockData(i, j, k).getMaterial().equals(Material.VOID_AIR);
|
||||
|
||||
if(!hard && _hard)
|
||||
{
|
||||
lastHard = j;
|
||||
hard = true;
|
||||
}
|
||||
|
||||
else if(hard && (!_hard || j == 0))
|
||||
{
|
||||
generateSurface(x1, z1, i, lastHard, k, lastHard - j, t);
|
||||
hard = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
protected void generateSurface(int ox, int oz, int x, int y, int z, int depth, TerrainHunk t)
|
||||
{
|
||||
for(int i = y; i <= (y + depth); i++)
|
||||
{
|
||||
if(i == y)
|
||||
{
|
||||
t.setBlock(x, i, z, Material.GRASS_BLOCK.createBlockData());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerrainHunk genDecorations(int x1, int z1, int x2, int z2, TerrainHunk hunk)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return hunk;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TerrainHunk genParallax(int x1, int z1, int x2, int z2, TerrainHunk hunk)
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return hunk;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,64 @@
|
||||
package com.volmit.iris.generator.atomics;
|
||||
|
||||
public class HeightHunk extends Hunk<Byte>
|
||||
{
|
||||
public HeightHunk(int w, int d)
|
||||
{
|
||||
super(w, 1, d);
|
||||
}
|
||||
|
||||
public void setHeight(int x, int y, int z)
|
||||
{
|
||||
set(x, 0, z, (byte) (y + Byte.MIN_VALUE));
|
||||
}
|
||||
|
||||
public int getHeight(int x, int z)
|
||||
{
|
||||
return get(x, 0, z) - Byte.MIN_VALUE;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static HeightHunk combined(Byte defaultNode, HeightHunk... hunks)
|
||||
{
|
||||
int w = 0;
|
||||
int d = 0;
|
||||
|
||||
for(HeightHunk i : hunks)
|
||||
{
|
||||
w = Math.max(w, i.getW());
|
||||
d = Math.max(d, i.getD());
|
||||
}
|
||||
|
||||
HeightHunk b = new HeightHunk(w, d);
|
||||
b.fill((byte) (defaultNode + Byte.MIN_VALUE));
|
||||
|
||||
for(HeightHunk i : hunks)
|
||||
{
|
||||
b.insert(i);
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
@SafeVarargs
|
||||
public static HeightHunk combined(HeightHunk... hunks)
|
||||
{
|
||||
int w = 0;
|
||||
int d = 0;
|
||||
|
||||
for(HeightHunk i : hunks)
|
||||
{
|
||||
w = Math.max(w, i.getW());
|
||||
d = Math.max(d, i.getD());
|
||||
}
|
||||
|
||||
HeightHunk b = new HeightHunk(w, d);
|
||||
|
||||
for(HeightHunk i : hunks)
|
||||
{
|
||||
b.insert(i);
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
}
|
@ -2,6 +2,10 @@ package com.volmit.iris.generator.atomics;
|
||||
|
||||
import org.bouncycastle.util.Arrays;
|
||||
|
||||
import com.volmit.iris.util.Function3;
|
||||
import com.volmit.iris.util.Supplier2;
|
||||
import com.volmit.iris.util.Supplier3;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
@ -132,6 +136,25 @@ public class Hunk<T>
|
||||
}
|
||||
}
|
||||
|
||||
public void set(int x, int z, int y1, int y2, T t)
|
||||
{
|
||||
set(x, x, y1, y2, z, z, t);
|
||||
}
|
||||
|
||||
public void set(int x1, int y1, int z1, int x2, int y2, int z2, T t)
|
||||
{
|
||||
for(int i = x1; i <= x2; i++)
|
||||
{
|
||||
for(int j = y1; j <= y2; j++)
|
||||
{
|
||||
for(int k = z1; k <= z2; k++)
|
||||
{
|
||||
set(i, j, k, t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void set(int x, int y, int z, T t)
|
||||
{
|
||||
data[index(x, y, z)] = t;
|
||||
@ -162,6 +185,45 @@ public class Hunk<T>
|
||||
return (z * w * h) + (y * w) + x;
|
||||
}
|
||||
|
||||
public void fill(int ox, int oy, int oz, Function3<Integer, Integer, Integer, T> f)
|
||||
{
|
||||
for(int i = ox; i < ox + getW(); i++)
|
||||
{
|
||||
for(int j = oy; j < oy + getH(); j++)
|
||||
{
|
||||
for(int k = oz; k < oz + getD(); k++)
|
||||
{
|
||||
set(i - ox, j - oy, k - oz, f.apply(i, j, k));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forEach(Supplier3<Integer, Integer, Integer> t)
|
||||
{
|
||||
for(int i = 0; i < getW(); i++)
|
||||
{
|
||||
for(int j = 0; j < getH(); j++)
|
||||
{
|
||||
for(int k = 0; k < getD(); k++)
|
||||
{
|
||||
t.get(i, j, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void forEachXZ(Supplier2<Integer, Integer> t)
|
||||
{
|
||||
for(int i = 0; i < getW(); i++)
|
||||
{
|
||||
for(int k = 0; k < getD(); k++)
|
||||
{
|
||||
t.get(i, k);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void fill(T t)
|
||||
{
|
||||
Arrays.fill(data, t);
|
||||
|
@ -7,12 +7,32 @@ import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.util.KList;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public class TerrainHunk extends Hunk<TerrainNode> implements BiomeGrid, ChunkData
|
||||
{
|
||||
@Getter
|
||||
private HeightHunk height;
|
||||
|
||||
@Getter
|
||||
private Hunk<IrisBiome> biome;
|
||||
|
||||
public TerrainHunk(int w, int h, int d)
|
||||
{
|
||||
super(w, h, d);
|
||||
this.height = new HeightHunk(w, d);
|
||||
this.biome = new Hunk<IrisBiome>(w, h, d);
|
||||
}
|
||||
|
||||
public TerrainHunk(int w, int h, int d, HeightHunk hh)
|
||||
{
|
||||
super(w, h, d);
|
||||
this.height = hh;
|
||||
this.biome = new Hunk<IrisBiome>(w, h, d);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -110,7 +130,7 @@ public class TerrainHunk extends Hunk<TerrainNode> implements BiomeGrid, ChunkDa
|
||||
|
||||
if(n == null)
|
||||
{
|
||||
return Material.STONE.createBlockData();
|
||||
return Material.VOID_AIR.createBlockData();
|
||||
}
|
||||
|
||||
return n.getBlockData();
|
||||
@ -153,15 +173,21 @@ public class TerrainHunk extends Hunk<TerrainNode> implements BiomeGrid, ChunkDa
|
||||
set(x, y, z, bio);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SafeVarargs
|
||||
public static TerrainHunk combined(TerrainNode defaultNode, TerrainHunk... hunks)
|
||||
{
|
||||
KList<HeightHunk> hhunks = new KList<>();
|
||||
KList<Hunk<IrisBiome>> bhunks = new KList<>();
|
||||
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
int d = 0;
|
||||
|
||||
for(TerrainHunk i : hunks)
|
||||
{
|
||||
hhunks.add(i.getHeight());
|
||||
bhunks.add(i.getBiome());
|
||||
w = Math.max(w, i.getW());
|
||||
h = Math.max(h, i.getH());
|
||||
d = Math.max(d, i.getD());
|
||||
@ -175,18 +201,26 @@ public class TerrainHunk extends Hunk<TerrainNode> implements BiomeGrid, ChunkDa
|
||||
b.insert(i);
|
||||
}
|
||||
|
||||
b.height = HeightHunk.combined((byte) 0, hhunks.toArray(new HeightHunk[hhunks.size()]));
|
||||
b.biome = Hunk.combined(null, hhunks.toArray(new Hunk[hhunks.size()]));
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@SafeVarargs
|
||||
public static TerrainHunk combined(TerrainHunk... hunks)
|
||||
{
|
||||
KList<HeightHunk> hhunks = new KList<>();
|
||||
KList<Hunk<IrisBiome>> bhunks = new KList<>();
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
int d = 0;
|
||||
|
||||
for(TerrainHunk i : hunks)
|
||||
{
|
||||
hhunks.add(i.getHeight());
|
||||
bhunks.add(i.getBiome());
|
||||
w = Math.max(w, i.getW());
|
||||
h = Math.max(h, i.getH());
|
||||
d = Math.max(d, i.getD());
|
||||
@ -199,6 +233,9 @@ public class TerrainHunk extends Hunk<TerrainNode> implements BiomeGrid, ChunkDa
|
||||
b.insert(i);
|
||||
}
|
||||
|
||||
b.height = HeightHunk.combined((byte) 0, hhunks.toArray(new HeightHunk[hhunks.size()]));
|
||||
b.biome = Hunk.combined(null, hhunks.toArray(new Hunk[hhunks.size()]));
|
||||
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
@ -20,17 +20,17 @@ public class TerrainNode
|
||||
|
||||
public TerrainNode(Biome biome, BlockData block)
|
||||
{
|
||||
this((byte) (biome.ordinal() + Byte.MIN_VALUE), (short) (paletteOf(block) + Short.MIN_VALUE));
|
||||
this((byte) (biome.ordinal()), (short) (paletteOf(block)));
|
||||
}
|
||||
|
||||
public TerrainNode setBlockData(BlockData block)
|
||||
{
|
||||
return new TerrainNode(biome, (short) (paletteOf(block) + Short.MIN_VALUE));
|
||||
return new TerrainNode(biome, (short) (paletteOf(block)));
|
||||
}
|
||||
|
||||
public TerrainNode setBiome(Biome biome)
|
||||
{
|
||||
return new TerrainNode((byte) (biome.ordinal() + Byte.MIN_VALUE), block);
|
||||
return new TerrainNode((byte) (biome.ordinal()), block);
|
||||
}
|
||||
|
||||
public BlockData getBlockData()
|
||||
|
@ -1,10 +1,23 @@
|
||||
package com.volmit.iris.generator.scaffold;
|
||||
|
||||
import com.volmit.iris.generator.atomics.HeightHunk;
|
||||
import com.volmit.iris.generator.atomics.TerrainHunk;
|
||||
|
||||
public interface TerrainStream
|
||||
{
|
||||
public TerrainHunk generate(int x1, int z1, int x2, int z2);
|
||||
public long getSeed();
|
||||
|
||||
public TerrainHunk generate(int x, int z);
|
||||
public int getHeight();
|
||||
|
||||
public int getNoise(int x, int z);
|
||||
|
||||
public HeightHunk genNoise(int x1, int z1, int x2, int z2);
|
||||
|
||||
public TerrainHunk genTerrain(int x1, int z1, int x2, int z2, TerrainHunk noise);
|
||||
|
||||
public TerrainHunk genCarving(int x1, int z1, int x2, int z2, HeightHunk noise);
|
||||
|
||||
public TerrainHunk genDecorations(int x1, int z1, int x2, int z2, TerrainHunk hunk);
|
||||
|
||||
public TerrainHunk genParallax(int x1, int z1, int x2, int z2, TerrainHunk hunk);
|
||||
}
|
||||
|
@ -19,8 +19,8 @@ public abstract class MortarCommand implements ICommand
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* Override this with a super constructor as most commands shouldn't change these
|
||||
* parameters
|
||||
* Override this with a super constructor as most commands shouldn't change
|
||||
* these parameters
|
||||
*
|
||||
* @param node
|
||||
* the node (primary node) i.e. volume
|
||||
@ -92,6 +92,21 @@ public abstract class MortarCommand implements ICommand
|
||||
requiredPermissions.add(node);
|
||||
}
|
||||
|
||||
public void rejectAny(MortarSender sender, String[] a)
|
||||
{
|
||||
if(a.length > 0)
|
||||
{
|
||||
String m = "";
|
||||
|
||||
for(String i : a)
|
||||
{
|
||||
m += i + " ";
|
||||
}
|
||||
|
||||
sender.sendMessage("Unknown Parameters: " + m);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNode()
|
||||
{
|
||||
|
6
src/main/java/com/volmit/iris/util/Supplier2.java
Normal file
6
src/main/java/com/volmit/iris/util/Supplier2.java
Normal file
@ -0,0 +1,6 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
public interface Supplier2<T, TT>
|
||||
{
|
||||
public void get(T t, TT tt);
|
||||
}
|
6
src/main/java/com/volmit/iris/util/Supplier3.java
Normal file
6
src/main/java/com/volmit/iris/util/Supplier3.java
Normal file
@ -0,0 +1,6 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
public interface Supplier3<T, TT, TTT>
|
||||
{
|
||||
public void get(T t, TT tt, TTT ttt);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user