diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
index 82abc63ef..4f5957d06 100644
--- a/.idea/jarRepositories.xml
+++ b/.idea/jarRepositories.xml
@@ -46,5 +46,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index db584e1d5..c2de2c86e 100644
--- a/pom.xml
+++ b/pom.xml
@@ -65,7 +65,7 @@
gaea.local
- gaea
+ gaea-local
file:/home/dfsek/Documents/Gaea/repo
@@ -95,7 +95,7 @@
org.polydev
gaea
- 1.10.5
+ 1.10.17
javax.vecmath
diff --git a/src/main/java/com/dfsek/terra/TerraProfiler.java b/src/main/java/com/dfsek/terra/TerraProfiler.java
index 7d78eadd6..ddf534453 100644
--- a/src/main/java/com/dfsek/terra/TerraProfiler.java
+++ b/src/main/java/com/dfsek/terra/TerraProfiler.java
@@ -16,7 +16,7 @@ public class TerraProfiler extends WorldProfiler {
this.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "TotalChunkGenTime")
.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "ChunkBaseGenTime")
.addMeasurement(new Measurement(2000000, DataType.PERIOD_MILLISECONDS), "BiomeSetTime")
- .addMeasurement(new Measurement(25000000, DataType.PERIOD_NANOSECONDS), "TreeGenTime")
+ .addMeasurement(new Measurement(25000000, DataType.PERIOD_MILLISECONDS), "TreeGenTime")
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "FloraTime")
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveTime")
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "CaveBlockUpdate");
diff --git a/src/main/java/com/dfsek/terra/carving/UserDefinedCarver.java b/src/main/java/com/dfsek/terra/carving/UserDefinedCarver.java
index d3e19f4b8..17064be9c 100644
--- a/src/main/java/com/dfsek/terra/carving/UserDefinedCarver.java
+++ b/src/main/java/com/dfsek/terra/carving/UserDefinedCarver.java
@@ -18,7 +18,9 @@ public class UserDefinedCarver extends Carver {
private final MaxMin length;
private final MaxMin radius;
private final int hash;
- public UserDefinedCarver(MaxMin height, MaxMin radius, MaxMin length, double[] start, double[] mutate, double[] radiusMultiplier, int hash) {
+ private final int topCut;
+ private final int bottomCut;
+ public UserDefinedCarver(MaxMin height, MaxMin radius, MaxMin length, double[] start, double[] mutate, double[] radiusMultiplier, int hash, int topCut, int bottomCut) {
super(height.getMin(), height.getMax());
this.radius = radius;
this.length = length;
@@ -26,12 +28,14 @@ public class UserDefinedCarver extends Carver {
this.mutate = mutate;
this.radiusMultiplier = radiusMultiplier;
this.hash = hash;
+ this.topCut = topCut;
+ this.bottomCut = bottomCut;
}
@Override
public Worm getWorm(long l, Vector vector) {
Random r = new Random(l+hash);
- return new UserDefinedWorm(length.get(r), r, vector, radius.getMax());
+ return new UserDefinedWorm(length.get(r), r, vector, radius.getMax(), topCut, bottomCut);
}
@Override
@@ -43,8 +47,10 @@ public class UserDefinedCarver extends Carver {
private final Vector direction;
private final int maxRad;
private double runningRadius;
- public UserDefinedWorm(int length, Random r, Vector origin, int maxRad) {
+ public UserDefinedWorm(int length, Random r, Vector origin, int maxRad, int topCut, int bottomCut) {
super(length, r, origin);
+ super.setTopCut(topCut);
+ super.setBottomCut(bottomCut);
runningRadius = radius.get(r);
this.maxRad = maxRad;
direction = new Vector((r.nextDouble()-0.5D)*start[0], (r.nextDouble()-0.5D)*start[1], (r.nextDouble()-0.5D)*start[2]).normalize();
diff --git a/src/main/java/com/dfsek/terra/config/WorldConfig.java b/src/main/java/com/dfsek/terra/config/WorldConfig.java
index 16fb0ff26..14322ba58 100644
--- a/src/main/java/com/dfsek/terra/config/WorldConfig.java
+++ b/src/main/java/com/dfsek/terra/config/WorldConfig.java
@@ -71,8 +71,8 @@ public class WorldConfig {
// Get values from config.
seaLevel = config.getInt("sea-level", 63);
zoneFreq = 1f/config.getInt("frequencies.zone", 1536);
- freq1 = 1f/config.getInt("frequencies.grid-1", 256);
- freq2 = 1f/config.getInt("frequencies.grid-2", 512);
+ freq1 = 1f/config.getInt("frequencies.grid-x", 256);
+ freq2 = 1f/config.getInt("frequencies.grid-z", 512);
fromImage = config.getBoolean("image.use-image", false);
// Load image stuff
diff --git a/src/main/java/com/dfsek/terra/config/genconfig/CarverConfig.java b/src/main/java/com/dfsek/terra/config/genconfig/CarverConfig.java
index 1367b4199..b620ef9ea 100644
--- a/src/main/java/com/dfsek/terra/config/genconfig/CarverConfig.java
+++ b/src/main/java/com/dfsek/terra/config/genconfig/CarverConfig.java
@@ -28,12 +28,18 @@ public class CarverConfig extends TerraConfigObject {
private String id;
private Set replaceableInner;
private Set replaceableOuter;
+ private Set replaceableTop;
+ private Set replaceableBottom;
private Set update;
private Map> shift;
private Map> inner;
private Map> outer;
+ private Map> top;
+ private Map> bottom;
private boolean replaceIsBlacklistInner;
private boolean replaceIsBlacklistOuter;
+ private boolean replaceIsBlacklistTop;
+ private boolean replaceIsBlacklistBottom;
public CarverConfig(File file) throws IOException, InvalidConfigurationException {
super(file);
@@ -53,8 +59,14 @@ public class CarverConfig extends TerraConfigObject {
outer = getBlocks("palette.outer.blocks");
+ top = getBlocks("palette.top.blocks");
+
+ bottom = getBlocks("palette.bottom.blocks");
+
replaceableInner = new HashSet<>();
replaceableOuter = new HashSet<>();
+ replaceableTop = new HashSet<>();
+ replaceableBottom = new HashSet<>();
for(String s : getStringList("palette.inner.replace")) {
try {
@@ -72,6 +84,22 @@ public class CarverConfig extends TerraConfigObject {
throw new InvalidConfigurationException("Could not load data for " + s);
}
}
+ for(String s : getStringList("palette.top.replace")) {
+ try {
+ if(replaceableTop.contains(Bukkit.createBlockData(s).getMaterial())) Bukkit.getLogger().warning("Duplicate material in replaceable list: " + s);
+ replaceableTop.add(Bukkit.createBlockData(s).getMaterial());
+ } catch(NullPointerException | IllegalArgumentException e) {
+ throw new InvalidConfigurationException("Could not load data for " + s);
+ }
+ }
+ for(String s : getStringList("palette.bottom.replace")) {
+ try {
+ if(replaceableBottom.contains(Bukkit.createBlockData(s).getMaterial())) Bukkit.getLogger().warning("Duplicate material in replaceable list: " + s);
+ replaceableBottom.add(Bukkit.createBlockData(s).getMaterial());
+ } catch(NullPointerException | IllegalArgumentException e) {
+ throw new InvalidConfigurationException("Could not load data for " + s);
+ }
+ }
update = new HashSet<>();
for(String s : getStringList("update")) {
@@ -104,7 +132,7 @@ public class CarverConfig extends TerraConfigObject {
MaxMin height = new MaxMin(getInt("start.height.min"), getInt("start.height.max"));
id = getString("id");
if(id == null) throw new InvalidConfigurationException("No ID specified for Carver!");
- carver = new UserDefinedCarver(height, radius, length, start, mutate, radiusMultiplier, id.hashCode());
+ carver = new UserDefinedCarver(height, radius, length, start, mutate, radiusMultiplier, id.hashCode(), getInt("cut.top", 0), getInt("cut.bottom", 0));
caveConfig.put(id, this);
}
@@ -149,6 +177,20 @@ public class CarverConfig extends TerraConfigObject {
return replaceableOuter.contains(m);
}
+ public boolean isReplaceableTop(Material m) {
+ if(replaceIsBlacklistTop) {
+ return !replaceableTop.contains(m);
+ }
+ return replaceableTop.contains(m);
+ }
+
+ public boolean isReplaceableBottom(Material m) {
+ if(replaceIsBlacklistBottom) {
+ return !replaceableBottom.contains(m);
+ }
+ return replaceableBottom.contains(m);
+ }
+
public ProbabilityCollection getPaletteInner(int y) {
for(Map.Entry> e : inner.entrySet()) {
if(e.getKey() >= y ) return e.getValue();
@@ -163,6 +205,20 @@ public class CarverConfig extends TerraConfigObject {
return null;
}
+ public ProbabilityCollection getPaletteBottom(int y) {
+ for(Map.Entry> e : bottom.entrySet()) {
+ if(e.getKey() >= y ) return e.getValue();
+ }
+ return null;
+ }
+
+ public ProbabilityCollection getPaletteTop(int y) {
+ for(Map.Entry> e : top.entrySet()) {
+ if(e.getKey() >= y ) return e.getValue();
+ }
+ return null;
+ }
+
@Override
public String toString() {
return "Carver with ID " + getID();
diff --git a/src/main/java/com/dfsek/terra/generation/SlabGenerator.java b/src/main/java/com/dfsek/terra/generation/SlabGenerator.java
index 3878c4bfd..66d1ff293 100644
--- a/src/main/java/com/dfsek/terra/generation/SlabGenerator.java
+++ b/src/main/java/com/dfsek/terra/generation/SlabGenerator.java
@@ -8,6 +8,8 @@ import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.block.data.BlockData;
+import org.bukkit.block.data.Waterlogged;
+import org.bukkit.block.data.type.Slab;
import org.bukkit.block.data.type.Stairs;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.util.Vector;
@@ -21,6 +23,7 @@ import java.util.Random;
public class SlabGenerator extends GenerationPopulator {
private static final BlockData AIR = Material.AIR.createBlockData();
+ private static final BlockData WATER = Material.WATER.createBlockData();
private static final Palette AIRPALETTE = new RandomPalette(new Random(2403)).add(AIR, 1);
@Override
public ChunkGenerator.ChunkData populate(World world, ChunkGenerator.ChunkData chunk, Random random, int chunkX, int chunkZ, ChunkInterpolator interp) {
@@ -42,42 +45,48 @@ public class SlabGenerator extends GenerationPopulator {
}
private static void prepareBlockPart(ChunkInterpolator interp, ChunkGenerator.ChunkData chunk, Vector block, Map> slabs, Map> stairs, double thresh) {
BlockData down = chunk.getBlockData(block.getBlockX(), block.getBlockY()-1, block.getBlockZ());
- double _11 = interp.getNoise(block.getBlockX(), block.getBlockY() - 0.5, block.getBlockZ());
+ double _11 = interp.getNoise(block.getBlockX(), block.getBlockY() - 0.4, block.getBlockZ());
if(_11 > thresh) {
- double _00 = interp.getNoise(block.getBlockX() - 0.5, block.getBlockY(), block.getBlockZ() - 0.5);
+ BlockData orig = chunk.getBlockData(block.getBlockX(), block.getBlockY(), block.getBlockZ());
+ //double _00 = interp.getNoise(block.getBlockX() - 0.5, block.getBlockY(), block.getBlockZ() - 0.5);
double _01 = interp.getNoise(block.getBlockX() - 0.5, block.getBlockY(), block.getBlockZ());
- double _02 = interp.getNoise(block.getBlockX() - 0.5, block.getBlockY(), block.getBlockZ() + 0.5);
+ //double _02 = interp.getNoise(block.getBlockX() - 0.5, block.getBlockY(), block.getBlockZ() + 0.5);
double _10 = interp.getNoise(block.getBlockX(), block.getBlockY(), block.getBlockZ() - 0.5);
double _12 = interp.getNoise(block.getBlockX(), block.getBlockY(), block.getBlockZ() + 0.5);
- double _20 = interp.getNoise(block.getBlockX() + 0.5, block.getBlockY(), block.getBlockZ() - 0.5);
+ //double _20 = interp.getNoise(block.getBlockX() + 0.5, block.getBlockY(), block.getBlockZ() - 0.5);
double _21 = interp.getNoise(block.getBlockX() + 0.5, block.getBlockY(), block.getBlockZ());
- double _22 = interp.getNoise(block.getBlockX() + 0.5, block.getBlockY(), block.getBlockZ() + 0.5);
+ //double _22 = interp.getNoise(block.getBlockX() + 0.5, block.getBlockY(), block.getBlockZ() + 0.5);
if(stairs != null) {
Palette stairPalette = stairs.get(down.getMaterial());
if(stairPalette != null) {
BlockData stair = stairPalette.get(0, block.getBlockX(), block.getBlockZ());
- Stairs finalStair = getStair(new double[] {_00, _01, _02, _10, _12, _20, _21, _22}, (Stairs) stair, thresh);
+ Stairs finalStair = getStair(new double[] {_01, _10, _12, _21}, (Stairs) stair, thresh);
if(finalStair != null) {
+ if(orig.matches(WATER)) finalStair.setWaterlogged(true);
chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), finalStair);
return;
}
}
}
- chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), slabs.getOrDefault(down.getMaterial(), AIRPALETTE).get(0, block.getBlockX(), block.getBlockZ()));
+ BlockData slab = slabs.getOrDefault(down.getMaterial(), AIRPALETTE).get(0, block.getBlockX(), block.getBlockZ());
+ if(slab instanceof Waterlogged) {
+ ((Waterlogged) slab).setWaterlogged(orig.matches(WATER));
+ }
+ chunk.setBlock(block.getBlockX(), block.getBlockY(), block.getBlockZ(), slab);
}
}
private static Stairs getStair(double[] vals, Stairs stair, double thresh) {
- if(vals.length != 8) throw new IllegalArgumentException();
+ if(vals.length != 4) throw new IllegalArgumentException();
Stairs stairNew = (Stairs) stair.clone();
- if(vals[1] > thresh) {
+ if(vals[0] > thresh) {
stairNew.setFacing(BlockFace.WEST);
- } else if(vals[3] > thresh) {
+ } else if(vals[1] > thresh) {
stairNew.setFacing(BlockFace.NORTH);
- } else if(vals[4] > thresh) {
+ } else if(vals[2] > thresh) {
stairNew.setFacing(BlockFace.SOUTH);
- } else if(vals[6] > thresh) {
+ } else if(vals[3] > thresh) {
stairNew.setFacing(BlockFace.EAST);
} else return null;
return stairNew;
diff --git a/src/main/java/com/dfsek/terra/population/CavePopulator.java b/src/main/java/com/dfsek/terra/population/CavePopulator.java
index be4cf2332..3c4c08891 100644
--- a/src/main/java/com/dfsek/terra/population/CavePopulator.java
+++ b/src/main/java/com/dfsek/terra/population/CavePopulator.java
@@ -35,9 +35,15 @@ public class CavePopulator extends BlockPopulator {
if(e.getValue().equals(CarvingData.CarvingType.CENTER) && c.isReplaceableInner(m)) {
if(c.getShiftedBlocks().containsKey(b.getType())) shiftCandidate.put(b.getLocation(), b.getType());
b.setBlockData(c.getPaletteInner(v.getBlockY()).get(random), false);
- } else if(c.isReplaceableOuter(m)){
+ } else if(e.getValue().equals(CarvingData.CarvingType.WALL) && c.isReplaceableOuter(m)){
if(c.getShiftedBlocks().containsKey(b.getType())) shiftCandidate.put(b.getLocation(), b.getType());
b.setBlockData(c.getPaletteOuter(v.getBlockY()).get(random), false);
+ } else if(e.getValue().equals(CarvingData.CarvingType.TOP) && c.isReplaceableTop(m)){
+ if(c.getShiftedBlocks().containsKey(b.getType())) shiftCandidate.put(b.getLocation(), b.getType());
+ b.setBlockData(c.getPaletteTop(v.getBlockY()).get(random), false);
+ } else if(e.getValue().equals(CarvingData.CarvingType.BOTTOM) && c.isReplaceableBottom(m)){
+ if(c.getShiftedBlocks().containsKey(b.getType())) shiftCandidate.put(b.getLocation(), b.getType());
+ b.setBlockData(c.getPaletteBottom(v.getBlockY()).get(random), false);
}
if(c.getUpdateBlocks().contains(m)) {
updateNeeded.add(b);
diff --git a/src/main/java/com/dfsek/terra/population/TreePopulator.java b/src/main/java/com/dfsek/terra/population/TreePopulator.java
index 51e5f5123..fcabffe5a 100644
--- a/src/main/java/com/dfsek/terra/population/TreePopulator.java
+++ b/src/main/java/com/dfsek/terra/population/TreePopulator.java
@@ -25,7 +25,7 @@ public class TreePopulator extends GaeaBlockPopulator {
Biome b = TerraBiomeGrid.fromWorld(world).getBiome(origin);
if(((UserDefinedDecorator) b.getDecorator()).getTreeChance() < random.nextInt(100)) return;
int numTrees = 0;
- for(int i = 0; i < 10; i++) {
+ for(int i = 0; i < 48; i++) {
int y = WorldUtil.getHighestValidSpawnAt(chunk, x, z);
if(y <= 0) continue;
origin = chunk.getBlock(x, y, z).getLocation().add(0, 1, 0);
@@ -34,7 +34,7 @@ public class TreePopulator extends GaeaBlockPopulator {
try {
b.getDecorator().getTrees().get(random).plant(origin, random, false, Terra.getInstance());
} catch(NullPointerException ignored) {}
- if(numTrees >= b.getDecorator().getTreeDensity()) return;
+ if(numTrees >= b.getDecorator().getTreeDensity()) break;
x = random.nextInt(16); // Decrease chances of chunk-crossing trees
z = random.nextInt(16);
}