mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-12 10:46:25 +00:00
Config refactoring, work on caverns, multi-level tree gen
This commit is contained in:
@@ -2,8 +2,7 @@ package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.carving.SimplexCarver;
|
||||
import com.dfsek.terra.config.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||
import org.bukkit.Chunk;
|
||||
@@ -80,10 +79,10 @@ public class CavePopulator extends BlockPopulator {
|
||||
b.setBlockData(orig, true);
|
||||
}
|
||||
}
|
||||
for(Map.Entry<Vector, CarvingData.CarvingType> e : new SimplexCarver(chunk.getX(), chunk.getZ()).carve(chunk.getX(), chunk.getZ(), world).getCarvedBlocks().entrySet()) {
|
||||
/*for(Map.Entry<Vector, CarvingData.CarvingType> e : new SimplexCarver(chunk.getX(), chunk.getZ()).carve(chunk.getX(), chunk.getZ(), world).getCarvedBlocks().entrySet()) {
|
||||
Vector v = e.getKey();
|
||||
chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ()).setBlockData(AIR, false);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.config.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import org.polydev.gaea.math.Range;
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
|
||||
15
src/main/java/com/dfsek/terra/population/SnowPopulator.java
Normal file
15
src/main/java/com/dfsek/terra/population/SnowPopulator.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class SnowPopulator extends GaeaBlockPopulator {
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.StructureConfig;
|
||||
import com.dfsek.terra.structure.GaeaStructure;
|
||||
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
||||
|
||||
@@ -4,18 +4,24 @@ import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.TerraBiomeGrid;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.base.WorldConfig;
|
||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.biome.Biome;
|
||||
import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.math.Range;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
import org.polydev.gaea.profiler.ProfileFuture;
|
||||
import org.polydev.gaea.tree.Tree;
|
||||
import org.polydev.gaea.util.WorldUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class TreePopulator extends GaeaBlockPopulator {
|
||||
@@ -26,8 +32,9 @@ public class TreePopulator extends GaeaBlockPopulator {
|
||||
TerraBiomeGrid grid = tw.getGrid();;
|
||||
int x = random.nextInt(16); // Decrease chances of chunk-crossing trees
|
||||
int z = random.nextInt(16);
|
||||
Location origin = chunk.getBlock(x, 0, z).getLocation();
|
||||
Biome b = grid.getBiome(origin, GenerationPhase.POPULATE);
|
||||
int origX = chunk.getX() << 4;
|
||||
int origZ = chunk.getZ() << 4;
|
||||
Biome b = grid.getBiome(x+origX, z+origZ, GenerationPhase.POPULATE);
|
||||
if(((UserDefinedDecorator) b.getDecorator()).getTreeChance() < random.nextInt(100)) return;
|
||||
int max = 50;
|
||||
int att = 0;
|
||||
@@ -38,15 +45,28 @@ public class TreePopulator extends GaeaBlockPopulator {
|
||||
if(chunk.getBlock(x, y, z).getType().isAir() && chunk.getBlock(x, y-1, z).getType().isSolid()) break;
|
||||
y--;
|
||||
}
|
||||
if(y == 0) continue;
|
||||
origin = chunk.getBlock(x, y, z).getLocation().add(0, 1, 0);
|
||||
b = grid.getBiome(origin, GenerationPhase.POPULATE);
|
||||
try {
|
||||
if(b.getDecorator().getTrees().get(random).plant(origin, random, false, Terra.getInstance())) i++;
|
||||
} catch(NullPointerException ignore) {}
|
||||
Tree tree = b.getDecorator().getTrees().get(random);
|
||||
Range range = tw.getConfig().getBiome((UserDefinedBiome) b).getTreeRange(tree);
|
||||
if(!tw.getConfig().getBiome((UserDefinedBiome) b).getTreeRange(tree).isInRange(y)) continue;
|
||||
b = grid.getBiome(x+origX, z+origZ, GenerationPhase.POPULATE);
|
||||
for(Block block : getValidSpawnsAt(chunk, x, z, range)) {
|
||||
try {
|
||||
if(tree.plant(block.getLocation(), random, false, Terra.getInstance())) i++;
|
||||
} catch(NullPointerException ignore) {}
|
||||
}
|
||||
|
||||
x = random.nextInt(16);
|
||||
z = random.nextInt(16);
|
||||
}
|
||||
}
|
||||
}
|
||||
public List<Block> getValidSpawnsAt(Chunk chunk, int x, int z, Range check) {
|
||||
List<Block> blocks = new ArrayList<>();
|
||||
for(int y : check) {
|
||||
if(chunk.getBlock(x, y, z).getType().isSolid() && chunk.getBlock(x, y + 1, z).getType().isAir()) {
|
||||
blocks.add(chunk.getBlock(x, y, z));
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user