mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-18 10:32:30 +00:00
Allow multi-level Flora, use ID hash for cave checking
This commit is contained in:
parent
ed77802ffd
commit
ca5accafa2
2
pom.xml
2
pom.xml
@ -95,7 +95,7 @@
|
||||
<dependency>
|
||||
<groupId>org.polydev</groupId>
|
||||
<artifactId>gaea</artifactId>
|
||||
<version>1.10.47</version>
|
||||
<version>1.10.48</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.lucko</groupId>
|
||||
|
@ -41,7 +41,7 @@ public class UserDefinedCarver extends Carver {
|
||||
|
||||
@Override
|
||||
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
||||
return random.nextInt(100) < BiomeConfig.fromBiome((UserDefinedBiome) TerraBiomeGrid.fromWorld(w).getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
|
||||
return new Random(random.nextLong()+hash).nextInt(100) < BiomeConfig.fromBiome((UserDefinedBiome) TerraBiomeGrid.fromWorld(w).getBiome(chunkX << 4, chunkZ << 4, GenerationPhase.POPULATE)).getCarverChance(this);
|
||||
}
|
||||
|
||||
private class UserDefinedWorm extends Worm {
|
||||
|
@ -15,6 +15,7 @@ import org.polydev.gaea.world.palette.RandomPalette;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
@ -81,11 +82,15 @@ public class FloraConfig extends TerraConfigObject implements Flora {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getHighestValidSpawnAt(Chunk chunk, int x, int z) {
|
||||
public List<Block> getValidSpawnsAt(Chunk chunk, int x, int z) {
|
||||
List<Block> blocks = new ArrayList<>();
|
||||
int y;
|
||||
for(y = chunk.getWorld().getMaxHeight() - 1; (!spawnable.contains(chunk.getBlock(x, y, z).getType())) && y > 0; y--);
|
||||
if(y <= 0) return null;
|
||||
return chunk.getBlock(x, y, z);
|
||||
for(y = chunk.getWorld().getMaxHeight() - 1; y > 0; y--) {
|
||||
if(spawnable.contains(chunk.getBlock(x, y, z).getType()) && replaceable.contains(chunk.getBlock(x, y+1, z).getType())) {
|
||||
blocks.add(chunk.getBlock(x, y, z));
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,6 +6,7 @@ import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.genconfig.BiomeConfig;
|
||||
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;
|
||||
@ -15,7 +16,9 @@ import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
import org.polydev.gaea.profiler.ProfileFuture;
|
||||
import org.polydev.gaea.world.Flora;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
@ -29,17 +32,17 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
UserDefinedBiome biome = (UserDefinedBiome) TerraBiomeGrid.fromWorld(world).getBiome((chunk.getX() << 4) + x, (chunk.getZ() << 4) + z, GenerationPhase.POPULATE);
|
||||
if(biome.getDecorator().getFloraChance() <= 0 || random.nextInt(100) > biome.getDecorator().getFloraChance())
|
||||
continue;
|
||||
if(biome.getDecorator().getFloraChance() <= 0) continue;
|
||||
try {
|
||||
BiomeConfig c = BiomeConfig.fromBiome(biome);
|
||||
for(int i = 0; i < c.getFloraAttempts(); i++) {
|
||||
Flora item;
|
||||
if(c.isFloraSimplex()) item = biome.getDecorator().getFlora().get(c.getFloraNoise(), (chunk.getX() << 4) + x, (chunk.getZ() << 4) + z);
|
||||
else item = biome.getDecorator().getFlora().get(random);
|
||||
Block highest = item.getHighestValidSpawnAt(chunk, x, z);
|
||||
if(highest != null && c.getFloraHeights(item).isInRange(highest.getY()))
|
||||
item.plant(highest.getLocation());
|
||||
for(Block highest : item.getValidSpawnsAt(chunk, x, z)) {
|
||||
if(c.getFloraHeights(item).isInRange(highest.getY()) && random.nextInt(100) < biome.getDecorator().getFloraChance())
|
||||
item.plant(highest.getLocation());
|
||||
}
|
||||
}
|
||||
} catch(NullPointerException ignore) {}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user