mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-16 13:23:07 +00:00
That's quite the commit you got there
This commit is contained in:
@@ -2,8 +2,9 @@ package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
import com.dfsek.terra.util.PopulationUtil;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
@@ -38,32 +39,34 @@ public class CavePopulator extends BlockPopulator {
|
||||
if(!tw.isSafe()) return;
|
||||
ConfigPack config = tw.getConfig();
|
||||
|
||||
for(CarverConfig c : config.getCarvers().values()) {
|
||||
for(UserDefinedCarver c : config.getCarvers()) {
|
||||
CarverTemplate template = c.getConfig();
|
||||
Map<Location, Material> shiftCandidate = new HashMap<>();
|
||||
Set<Block> updateNeeded = new HashSet<>();
|
||||
Map<Vector, CarvingData.CarvingType> blocks = c.getCarver().carve(chunk.getX(), chunk.getZ(), world).getCarvedBlocks();
|
||||
Map<Vector, CarvingData.CarvingType> blocks = c.carve(chunk.getX(), chunk.getZ(), world).getCarvedBlocks();
|
||||
for(Map.Entry<Vector, CarvingData.CarvingType> e : blocks.entrySet()) {
|
||||
|
||||
Vector v = e.getKey();
|
||||
Block b = chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
Material m = b.getType();
|
||||
if(e.getValue().equals(CarvingData.CarvingType.CENTER) && c.isReplaceableInner(m)) {
|
||||
if(c.getShiftedBlocks().containsKey(b.getType()))
|
||||
if(e.getValue().equals(CarvingData.CarvingType.CENTER) && template.getInner().canReplace(m)) {
|
||||
if(template.getShift().containsKey(b.getType()))
|
||||
shiftCandidate.put(b.getLocation(), b.getType());
|
||||
b.setBlockData(c.getPaletteInner(v.getBlockY()).get(random), c.shouldUpdateOcean() && borderingOcean(b));
|
||||
} else if(e.getValue().equals(CarvingData.CarvingType.WALL) && c.isReplaceableOuter(m)) {
|
||||
if(c.getShiftedBlocks().containsKey(b.getType()))
|
||||
b.setBlockData(template.getInner().get(v.getBlockY()).get(random), false);
|
||||
} else if(e.getValue().equals(CarvingData.CarvingType.WALL) && template.getOuter().canReplace(m)) {
|
||||
if(template.getShift().containsKey(b.getType()))
|
||||
shiftCandidate.put(b.getLocation(), b.getType());
|
||||
b.setBlockData(c.getPaletteOuter(v.getBlockY()).get(random), c.shouldUpdateOcean() && borderingOcean(b));
|
||||
} else if(e.getValue().equals(CarvingData.CarvingType.TOP) && c.isReplaceableTop(m)) {
|
||||
if(c.getShiftedBlocks().containsKey(b.getType()))
|
||||
b.setBlockData(template.getOuter().get(v.getBlockY()).get(random), false);
|
||||
} else if(e.getValue().equals(CarvingData.CarvingType.TOP) && template.getTop().canReplace(m)) {
|
||||
if(template.getShift().containsKey(b.getType()))
|
||||
shiftCandidate.put(b.getLocation(), b.getType());
|
||||
b.setBlockData(c.getPaletteTop(v.getBlockY()).get(random), c.shouldUpdateOcean() && borderingOcean(b));
|
||||
} else if(e.getValue().equals(CarvingData.CarvingType.BOTTOM) && c.isReplaceableBottom(m)) {
|
||||
if(c.getShiftedBlocks().containsKey(b.getType()))
|
||||
b.setBlockData(template.getTop().get(v.getBlockY()).get(random), false);
|
||||
} else if(e.getValue().equals(CarvingData.CarvingType.BOTTOM) && template.getBottom().canReplace(m)) {
|
||||
if(template.getShift().containsKey(b.getType()))
|
||||
shiftCandidate.put(b.getLocation(), b.getType());
|
||||
b.setBlockData(c.getPaletteBottom(v.getBlockY()).get(random), c.shouldUpdateOcean() && borderingOcean(b));
|
||||
b.setBlockData(template.getBottom().get(v.getBlockY()).get(random), false);
|
||||
}
|
||||
if(c.getUpdateBlocks().contains(m)) {
|
||||
if(template.getUpdate().contains(m)) {
|
||||
updateNeeded.add(b);
|
||||
}
|
||||
}
|
||||
@@ -74,7 +77,7 @@ public class CavePopulator extends BlockPopulator {
|
||||
do mut.subtract(0, 1, 0);
|
||||
while(mut.getBlock().getType().equals(orig));
|
||||
try {
|
||||
if(c.getShiftedBlocks().get(entry.getValue()).contains(mut.getBlock().getType())) {
|
||||
if(template.getShift().get(entry.getValue()).contains(mut.getBlock().getType())) {
|
||||
mut.getBlock().setBlockData(shiftStorage.computeIfAbsent(entry.getValue(), Material::createBlockData), false);
|
||||
}
|
||||
} catch(NullPointerException ignore) {
|
||||
@@ -85,18 +88,6 @@ public class CavePopulator extends BlockPopulator {
|
||||
b.setBlockData(AIR, false);
|
||||
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()) {
|
||||
Vector v = e.getKey();
|
||||
switch(e.getValue()) {
|
||||
case TOP:
|
||||
case CENTER:
|
||||
chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ()).setBlockData(AIR, false);
|
||||
break;
|
||||
case BOTTOM:
|
||||
chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ()).setBlockData(Material.MYCELIUM.createBlockData(), false);
|
||||
}
|
||||
|
||||
}*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,16 +4,13 @@ import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeFloraConfig;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
import org.polydev.gaea.profiler.ProfileFuture;
|
||||
import org.polydev.gaea.world.Flora;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -35,9 +32,9 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
||||
UserDefinedBiome biome = (UserDefinedBiome) grid.getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
|
||||
if(biome.getDecorator().getFloraChance() <= 0) continue;
|
||||
try {
|
||||
BiomeConfig c = biome.getConfig();
|
||||
BiomeFloraConfig f = c.getFlora();
|
||||
for(int i = 0; i < f.getFloraAttempts(); i++) {
|
||||
BiomeTemplate c = biome.getConfig();
|
||||
/*
|
||||
for(int i = 0; i < 0; i++) {
|
||||
Flora item;
|
||||
if(f.isFloraSimplex())
|
||||
item = biome.getDecorator().getFlora().get(f.getFloraNoise(), originX + x, originZ + z);
|
||||
@@ -47,6 +44,7 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
||||
item.plant(highest.getLocation());
|
||||
}
|
||||
}
|
||||
*/
|
||||
} catch(NullPointerException ignore) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,21 +3,20 @@ package com.dfsek.terra.population;
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeOreConfig;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.event.OreVeinGenerateEvent;
|
||||
import com.dfsek.terra.generation.items.ores.Ore;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.util.Vector;
|
||||
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 java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
public class OrePopulator extends GaeaBlockPopulator {
|
||||
@@ -30,20 +29,19 @@ public class OrePopulator extends GaeaBlockPopulator {
|
||||
for(int cx = -1; cx <= 1; cx++) {
|
||||
for(int cz = -1; cz <= 1; cz++) {
|
||||
Biome b = TerraWorld.getWorld(world).getGrid().getBiome(((chunk.getX() + cx) << 4) + 8, ((chunk.getZ() + cz) << 4) + 8, GenerationPhase.POPULATE);
|
||||
BiomeOreConfig ores = ((UserDefinedBiome) b).getConfig().getOres();
|
||||
for(Map.Entry<OreConfig, Range> e : ores.getOres().entrySet()) {
|
||||
int num = e.getValue().get(r);
|
||||
OreConfig ore = e.getKey();
|
||||
BiomeTemplate config = ((UserDefinedBiome) b).getConfig();
|
||||
for(Ore ore : config.getOres()) {
|
||||
int num = ore.getAmount().get(r);
|
||||
for(int i = 0; i < num; i++) {
|
||||
int x = r.nextInt(16) + cx * 16;
|
||||
int z = r.nextInt(16) + cz * 16;
|
||||
int y = ores.getOreHeights().get(ore).get(r);
|
||||
int y = ore.getHeight().get(r);
|
||||
|
||||
Vector v = new Vector(x, y, z);
|
||||
OreVeinGenerateEvent event = new OreVeinGenerateEvent(tw, v.toLocation(world), ore);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) {
|
||||
ore.doVeinSingle(new Vector(x, y, z), chunk, r);
|
||||
ore.generate(new Location(world, x, y, z), chunk, r);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,21 +2,13 @@ package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
||||
import com.dfsek.terra.config.base.PluginConfig;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import com.dfsek.terra.util.DataUtil;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.block.data.Snowable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
import org.polydev.gaea.profiler.ProfileFuture;
|
||||
|
||||
@@ -58,8 +50,9 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
||||
TerraBiomeGrid g = w.getGrid();
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
BiomeConfig biome = ((UserDefinedBiome) g.getBiome(origX + x, origZ + z, GenerationPhase.PALETTE_APPLY)).getConfig();
|
||||
if(!biome.getSnow().doSnow()) continue;
|
||||
/*
|
||||
BiomeTemplate biome = ((UserDefinedBiome) g.getBiome(origX + x, origZ + z, GenerationPhase.PALETTE_APPLY)).getConfig();
|
||||
if(!biome) continue;
|
||||
int y;
|
||||
Block b = null;
|
||||
for(y = 254; y > 0; y--) {
|
||||
@@ -76,6 +69,9 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
||||
}
|
||||
b.getRelative(BlockFace.UP).setBlockData(DataUtil.SNOW, phys);
|
||||
|
||||
|
||||
*/
|
||||
// TODO: implementation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,12 +6,11 @@ import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.structure.StructureConfig;
|
||||
import com.dfsek.terra.config.templates.StructureTemplate;
|
||||
import com.dfsek.terra.procgen.math.Vector2;
|
||||
import com.dfsek.terra.structure.Rotation;
|
||||
import com.dfsek.terra.structure.Structure;
|
||||
import com.dfsek.terra.structure.StructureContainedInventory;
|
||||
import com.dfsek.terra.structure.features.Feature;
|
||||
import com.dfsek.terra.util.PopulationUtil;
|
||||
import com.dfsek.terra.util.structure.RotationUtil;
|
||||
import net.jafama.FastMath;
|
||||
@@ -41,13 +40,13 @@ public class StructurePopulator extends BlockPopulator {
|
||||
TerraBiomeGrid grid = tw.getGrid();
|
||||
ConfigPack config = tw.getConfig();
|
||||
structure:
|
||||
for(StructureConfig conf : config.getAllStructures()) {
|
||||
for(StructureTemplate conf : config.getStructures()) {
|
||||
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
||||
if(!((UserDefinedBiome) grid.getBiome(spawn)).getConfig().getStructures().contains(conf)) continue;
|
||||
Random r2 = new FastRandom(spawn.hashCode());
|
||||
Structure struc = conf.getStructure(r2);
|
||||
Structure struc = conf.getStructures().get(r2);
|
||||
Rotation rotation = Rotation.fromDegrees(r2.nextInt(4) * 90);
|
||||
for(int y = conf.getSearchStart().get(r2); y > 0; y--) {
|
||||
for(int y = conf.getY().get(r2); y > 0; y--) {
|
||||
if(!conf.getBound().isInRange(y)) continue structure;
|
||||
spawn.setY(y);
|
||||
if(!struc.checkSpawns(spawn, rotation)) continue;
|
||||
@@ -64,7 +63,7 @@ public class StructurePopulator extends BlockPopulator {
|
||||
continue;
|
||||
Debug.info("Target is in chunk.");
|
||||
Debug.info(spawn.toString() + " became: " + inv.toString() + " (" + rotation + ", " + inv.getBlock().getType() + ")");
|
||||
LootTable table = conf.getLoot(i.getUid());
|
||||
LootTable table = conf.getLoot().get(i.getUid());
|
||||
if(table == null) continue;
|
||||
Debug.info("Target has table assigned.");
|
||||
table.fillInventory(((BlockInventoryHolder) inv.getBlock().getState()).getInventory(), random);
|
||||
@@ -73,7 +72,8 @@ public class StructurePopulator extends BlockPopulator {
|
||||
Debug.stack(e);
|
||||
}
|
||||
}
|
||||
for(Feature f : conf.getFeatures()) f.apply(struc, rotation, spawn, chunk); // Apply features.
|
||||
//for(Feature f : conf.getFeatures()) f.apply(struc, rotation, spawn, chunk); // Apply features.
|
||||
// TODO: features
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,15 +1,11 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.Terra;
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.biome.grid.TerraBiomeGrid;
|
||||
import com.dfsek.terra.event.TreeGenerateEvent;
|
||||
import net.jafama.FastMath;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -17,7 +13,6 @@ 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.GlueList;
|
||||
|
||||
import java.util.List;
|
||||
@@ -25,6 +20,7 @@ import java.util.Random;
|
||||
|
||||
|
||||
public class TreePopulator extends GaeaBlockPopulator {
|
||||
/*
|
||||
private static void doTrees(@NotNull UserDefinedBiome biome, TerraWorld world, @NotNull Random random, @NotNull Chunk chunk, int x, int z) {
|
||||
for(Block block : getValidTreeSpawnsAt(chunk, x, z, new Range(0, 254))) {
|
||||
Tree tree = biome.getDecorator().getTrees().get(random);
|
||||
@@ -40,6 +36,8 @@ public class TreePopulator extends GaeaBlockPopulator {
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
// TODO: implementation
|
||||
public static List<Block> getValidTreeSpawnsAt(Chunk chunk, int x, int z, Range check) {
|
||||
List<Block> blocks = new GlueList<>();
|
||||
for(int y : check) {
|
||||
@@ -68,7 +66,7 @@ public class TreePopulator extends GaeaBlockPopulator {
|
||||
if(random.nextInt(1000) < treeChance) {
|
||||
int xt = offset(random, x);
|
||||
int zt = offset(random, z);
|
||||
doTrees(biome, tw, random, chunk, xt, zt);
|
||||
//doTrees(biome, tw, random, chunk, xt, zt); TODO: implementation
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user