mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-19 14:50:30 +00:00
Clean up imports
This commit is contained in:
@@ -2,11 +2,9 @@ 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.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import com.dfsek.terra.config.genconfig.CarverConfig;
|
||||
import com.dfsek.terra.structure.StructureSpawnRequirement;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -29,12 +27,13 @@ import java.util.Set;
|
||||
public class CavePopulator extends BlockPopulator {
|
||||
private static final Map<Material, BlockData> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
||||
private static final BlockData AIR = Material.AIR.createBlockData();
|
||||
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
if(ConfigUtil.masterDisableCaves) return;
|
||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("CaveTime")) {
|
||||
TerraWorld tw = TerraWorld.getWorld(world);
|
||||
if(!tw.isSafe()) return;
|
||||
if(! tw.isSafe()) return;
|
||||
ConfigPack config = tw.getConfig();
|
||||
|
||||
for(CarverConfig c : config.getCarvers().values()) {
|
||||
@@ -75,7 +74,8 @@ public class CavePopulator extends BlockPopulator {
|
||||
if(c.getShiftedBlocks().get(shiftCandidate.get(l)).contains(mut.getBlock().getType())) {
|
||||
mut.getBlock().setBlockData(shiftStorage.computeIfAbsent(shiftCandidate.get(l), Material::createBlockData), false);
|
||||
}
|
||||
} catch(NullPointerException ignore) {}
|
||||
} catch(NullPointerException ignore) {
|
||||
}
|
||||
}
|
||||
try(ProfileFuture ignore = TerraProfiler.fromWorld(world).measure("CaveBlockUpdate")) {
|
||||
for(Block b : updateNeeded) {
|
||||
@@ -100,6 +100,7 @@ public class CavePopulator extends BlockPopulator {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private boolean borderingOcean(Block b) {
|
||||
return b.getRelative(BlockFace.UP).getType().equals(Material.WATER) || b.getType().equals(Material.LAVA);
|
||||
}
|
||||
|
||||
@@ -9,14 +9,12 @@ import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeFloraConfig;
|
||||
import com.dfsek.terra.event.TreeGenerateEvent;
|
||||
import com.dfsek.terra.generation.UserDefinedDecorator;
|
||||
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;
|
||||
import org.polydev.gaea.biome.Biome;
|
||||
import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.math.Range;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
@@ -34,9 +32,9 @@ import java.util.Random;
|
||||
public class FloraPopulator extends GaeaBlockPopulator {
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
|
||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("FloraTime")) {
|
||||
TerraWorld tw = TerraWorld.getWorld(world);
|
||||
if(!tw.isSafe()) return;
|
||||
if(! tw.isSafe()) return;
|
||||
int originX = chunk.getX() << 4;
|
||||
int originZ = chunk.getZ() << 4;
|
||||
TerraBiomeGrid grid = tw.getGrid();
|
||||
@@ -58,40 +56,46 @@ public class FloraPopulator extends GaeaBlockPopulator {
|
||||
BiomeFloraConfig f = c.getFlora();
|
||||
for(int i = 0; i < f.getFloraAttempts(); i++) {
|
||||
Flora item;
|
||||
if(f.isFloraSimplex()) item = biome.getDecorator().getFlora().get(f.getFloraNoise(), originX + x, originZ + z);
|
||||
if(f.isFloraSimplex())
|
||||
item = biome.getDecorator().getFlora().get(f.getFloraNoise(), originX + x, originZ + z);
|
||||
else item = biome.getDecorator().getFlora().get(random);
|
||||
for(Block highest : item.getValidSpawnsAt(chunk, x, z, c.getFloraHeights(item))) {
|
||||
if(random.nextInt(100) < biome.getDecorator().getFloraChance())
|
||||
item.plant(highest.getLocation());
|
||||
}
|
||||
}
|
||||
} catch(NullPointerException ignore) {}
|
||||
} catch(NullPointerException ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private static boolean doTrees(@NotNull UserDefinedBiome biome, TerraWorld world, @NotNull Random random, @NotNull Chunk chunk, int x, int z) {
|
||||
|
||||
private static boolean 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);
|
||||
Range range = world.getConfig().getBiome(biome).getTreeRange(tree);
|
||||
if(!range.isInRange(block.getY())) continue;
|
||||
if(! range.isInRange(block.getY())) continue;
|
||||
try {
|
||||
Location l = block.getLocation();
|
||||
TreeGenerateEvent event = new TreeGenerateEvent(world, l, tree);
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
if(!event.isCancelled()) tree.plant(l, random, Terra.getInstance());
|
||||
} catch(NullPointerException ignore) {}
|
||||
if(! event.isCancelled()) tree.plant(l, random, Terra.getInstance());
|
||||
} catch(NullPointerException ignore) {
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static int offset(Random r, int i) {
|
||||
return Math.min(Math.max(i + r.nextInt(3)-1, 0), 15);
|
||||
return Math.min(Math.max(i + r.nextInt(3) - 1, 0), 15);
|
||||
}
|
||||
|
||||
public static List<Block> getValidTreeSpawnsAt(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+1, z));
|
||||
blocks.add(chunk.getBlock(x, y + 1, z));
|
||||
}
|
||||
}
|
||||
return blocks;
|
||||
|
||||
@@ -1,20 +1,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.base.ConfigPack;
|
||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeOreConfig;
|
||||
import com.dfsek.terra.event.OreVeinGenerateEvent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.polydev.gaea.math.Range;
|
||||
import com.dfsek.terra.TerraProfiler;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.genconfig.OreConfig;
|
||||
import org.bukkit.Chunk;
|
||||
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;
|
||||
|
||||
@@ -24,19 +24,19 @@ import java.util.Random;
|
||||
public class OrePopulator extends GaeaBlockPopulator {
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) {
|
||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("OreTime")) {
|
||||
TerraWorld tw = TerraWorld.getWorld(world);
|
||||
if(!tw.isSafe()) return;
|
||||
if(! tw.isSafe()) return;
|
||||
ConfigPack config = tw.getConfig();
|
||||
Biome b = TerraWorld.getWorld(world).getGrid().getBiome((chunk.getX() << 4)+8, (chunk.getZ() << 4) + 8, GenerationPhase.POPULATE);
|
||||
Biome b = TerraWorld.getWorld(world).getGrid().getBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8, GenerationPhase.POPULATE);
|
||||
BiomeOreConfig ores = config.getBiome((UserDefinedBiome) b).getOres();
|
||||
for(Map.Entry<OreConfig, Range> e : ores.getOres().entrySet()) {
|
||||
int num = e.getValue().get(random);
|
||||
OreConfig ore = e.getKey();
|
||||
int edgeOffset = ore.getChunkEdgeOffset();
|
||||
for(int i = 0; i < num; i++) {
|
||||
int x = random.nextInt(16 - edgeOffset*2) + edgeOffset;
|
||||
int z = random.nextInt(16 - edgeOffset*2) + edgeOffset;
|
||||
int x = random.nextInt(16 - edgeOffset * 2) + edgeOffset;
|
||||
int z = random.nextInt(16 - edgeOffset * 2) + edgeOffset;
|
||||
int y = ores.getOreHeights().get(ore).get(random);
|
||||
|
||||
Vector v = new Vector(x, y, z);
|
||||
|
||||
@@ -4,7 +4,6 @@ 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.ConfigPack;
|
||||
import com.dfsek.terra.config.base.ConfigUtil;
|
||||
import com.dfsek.terra.config.genconfig.biome.BiomeConfig;
|
||||
import com.dfsek.terra.util.DataUtil;
|
||||
@@ -13,7 +12,6 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.polydev.gaea.generation.GenerationPhase;
|
||||
import org.polydev.gaea.population.GaeaBlockPopulator;
|
||||
@@ -25,6 +23,7 @@ import java.util.Set;
|
||||
|
||||
public class SnowPopulator extends GaeaBlockPopulator {
|
||||
private static final Set<Material> blacklistSpawn = new HashSet<>();
|
||||
|
||||
static {
|
||||
for(Material m : Material.values()) {
|
||||
String name = m.toString().toLowerCase();
|
||||
@@ -44,9 +43,10 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
||||
if(ConfigUtil.debug)
|
||||
Bukkit.getLogger().info("Added " + blacklistSpawn.size() + " materials to snow blacklist");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk chunk) {
|
||||
try (ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("SnowTime")) {
|
||||
try(ProfileFuture ignored = TerraProfiler.fromWorld(world).measure("SnowTime")) {
|
||||
int origX = chunk.getX() << 4;
|
||||
int origZ = chunk.getZ() << 4;
|
||||
TerraWorld w = TerraWorld.getWorld(world);
|
||||
@@ -55,7 +55,7 @@ public class SnowPopulator extends GaeaBlockPopulator {
|
||||
for(int x = 0; x < 16; x++) {
|
||||
for(int z = 0; z < 16; z++) {
|
||||
BiomeConfig biome = w.getConfig().getBiome((UserDefinedBiome) g.getBiome(origX + x, origZ + z, GenerationPhase.PALETTE_APPLY));
|
||||
if(!biome.getSnow().doSnow()) continue;
|
||||
if(! biome.getSnow().doSnow()) continue;
|
||||
int y;
|
||||
Block b = null;
|
||||
for(y = 254; y > 0; y--) {
|
||||
|
||||
@@ -30,17 +30,18 @@ public class StructurePopulator extends BlockPopulator {
|
||||
int cx = (chunk.getX() << 4);
|
||||
int cz = (chunk.getZ() << 4);
|
||||
TerraWorld tw = TerraWorld.getWorld(world);
|
||||
if(!tw.isSafe()) return;
|
||||
if(! tw.isSafe()) return;
|
||||
TerraBiomeGrid grid = tw.getGrid();
|
||||
ConfigPack config = tw.getConfig();
|
||||
structure: for(StructureConfig conf : config.getAllStructures()) {
|
||||
structure:
|
||||
for(StructureConfig conf : config.getAllStructures()) {
|
||||
Location spawn = conf.getSpawn().getNearestSpawn(cx + 8, cz + 8, world.getSeed()).toLocation(world);
|
||||
if(!config.getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(conf)) continue;
|
||||
if(! config.getBiome((UserDefinedBiome) grid.getBiome(spawn)).getStructures().contains(conf)) continue;
|
||||
Random r2 = new Random(spawn.hashCode());
|
||||
Structure struc = conf.getStructure(r2);
|
||||
Structure.Rotation rotation = Structure.Rotation.fromDegrees(r2.nextInt(4) * 90);
|
||||
for(int y = conf.getSearchStart().get(r2); y > 0; y--) {
|
||||
if(!conf.getBound().isInRange(y)) continue structure;
|
||||
if(! conf.getBound().isInRange(y)) continue structure;
|
||||
spawn.setY(y);
|
||||
if(! struc.checkSpawns(spawn, rotation)) continue;
|
||||
double horizontal = struc.getStructureInfo().getMaxHorizontal();
|
||||
@@ -73,6 +74,7 @@ public class StructurePopulator extends BlockPopulator {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum SearchType {
|
||||
UP, DOWN
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user