mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-08-29 21:30:43 +00:00
Merge pull request #101 from PolyhedralDev/ver/5.1.1
API to add populators, Buildscript improvements
This commit is contained in:
@@ -30,7 +30,7 @@ fun Project.configureCommon() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun Project.getGitHash(): String {
|
fun Project.getGitHash(): String {
|
||||||
val stdout = java.io.ByteArrayOutputStream()
|
val stdout = ByteArrayOutputStream()
|
||||||
exec {
|
exec {
|
||||||
commandLine = mutableListOf("git", "rev-parse", "--short", "HEAD")
|
commandLine = mutableListOf("git", "rev-parse", "--short", "HEAD")
|
||||||
standardOutput = stdout
|
standardOutput = stdout
|
||||||
|
|||||||
@@ -14,13 +14,9 @@ fun Project.configureDistribution() {
|
|||||||
apply(plugin = "java-library")
|
apply(plugin = "java-library")
|
||||||
apply(plugin = "com.github.johnrengelman.shadow")
|
apply(plugin = "com.github.johnrengelman.shadow")
|
||||||
|
|
||||||
|
|
||||||
// configurations.create("shaded")
|
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
val shaded = create("shaded")
|
val shaded = create("shaded")
|
||||||
getByName("compile").extendsFrom(shaded)
|
getByName("compile").extendsFrom(shaded)
|
||||||
// shaded.extendsFrom(getByName("compile"))
|
|
||||||
val shadedApi = create("shadedApi")
|
val shadedApi = create("shadedApi")
|
||||||
shaded.extendsFrom(shadedApi)
|
shaded.extendsFrom(shadedApi)
|
||||||
getByName("api").extendsFrom(shadedApi)
|
getByName("api").extendsFrom(shadedApi)
|
||||||
@@ -29,11 +25,8 @@ fun Project.configureDistribution() {
|
|||||||
getByName("implementation").extendsFrom(shadedImplementation)
|
getByName("implementation").extendsFrom(shadedImplementation)
|
||||||
}
|
}
|
||||||
|
|
||||||
// tasks.withType<JavaCompile> {
|
|
||||||
// classpath +=
|
|
||||||
// }
|
|
||||||
|
|
||||||
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
|
val downloadDefaultPacks = tasks.create("downloadDefaultPacks") {
|
||||||
|
group = "terra"
|
||||||
doFirst {
|
doFirst {
|
||||||
file("${buildDir}/resources/main/packs/").deleteRecursively()
|
file("${buildDir}/resources/main/packs/").deleteRecursively()
|
||||||
|
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ public class TerraCommandManager implements CommandManager {
|
|||||||
if(field.isAnnotationPresent(SwitchTarget.class)) {
|
if(field.isAnnotationPresent(SwitchTarget.class)) {
|
||||||
SwitchTarget switchTarget = field.getAnnotation(SwitchTarget.class);
|
SwitchTarget switchTarget = field.getAnnotation(SwitchTarget.class);
|
||||||
if(!holder.switches.containsValue(switchTarget.value())) {
|
if(!holder.switches.containsValue(switchTarget.value())) {
|
||||||
System.out.println(holder.switches);
|
|
||||||
throw new MalformedCommandException("Switch Target specifies nonexistent switch \"" + switchTarget.value() + "\"");
|
throw new MalformedCommandException("Switch Target specifies nonexistent switch \"" + switchTarget.value() + "\"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package com.dfsek.terra.api.world.generation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Marker interface that marks a feature as "chunkified" (only modifying one chunk at a time)
|
||||||
|
*/
|
||||||
|
public interface Chunkified {
|
||||||
|
}
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
package com.dfsek.terra.api.world.generation;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The phase of terrain generation. Used for modifying values based on the phase of generation.
|
|
||||||
*/
|
|
||||||
public enum GenerationPhase {
|
|
||||||
BASE, POPULATE, GENERATION_POPULATE, PALETTE_APPLY, POST_GEN
|
|
||||||
}
|
|
||||||
@@ -6,10 +6,10 @@ import com.dfsek.terra.api.platform.world.World;
|
|||||||
import com.dfsek.terra.api.platform.world.generator.ChunkData;
|
import com.dfsek.terra.api.platform.world.generator.ChunkData;
|
||||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||||
import com.dfsek.terra.config.pack.ConfigPack;
|
import com.dfsek.terra.config.pack.ConfigPack;
|
||||||
import com.dfsek.terra.world.generation.math.SamplerCache;
|
|
||||||
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public interface TerraChunkGenerator {
|
public interface TerraChunkGenerator {
|
||||||
@@ -32,4 +32,6 @@ public interface TerraChunkGenerator {
|
|||||||
TerraPlugin getMain();
|
TerraPlugin getMain();
|
||||||
|
|
||||||
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);
|
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);
|
||||||
|
|
||||||
|
List<TerraBlockPopulator> getPopulators();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,8 +63,6 @@ public class StructureLoadCommand implements CommandTemplate {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender) {
|
public void execute(CommandSender sender) {
|
||||||
System.out.println(rotation);
|
|
||||||
|
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
long t = System.nanoTime();
|
long t = System.nanoTime();
|
||||||
|
|||||||
@@ -4,7 +4,10 @@ import com.dfsek.terra.api.platform.world.Biome;
|
|||||||
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
|
import com.dfsek.terra.api.util.collections.ProbabilityCollection;
|
||||||
import com.dfsek.terra.api.util.seeded.SeededBuilder;
|
import com.dfsek.terra.api.util.seeded.SeededBuilder;
|
||||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||||
|
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||||
|
|
||||||
public interface BiomeBuilder extends SeededBuilder<TerraBiome> {
|
public interface BiomeBuilder extends SeededBuilder<TerraBiome> {
|
||||||
ProbabilityCollection<Biome> getVanillaBiomes();
|
ProbabilityCollection<Biome> getVanillaBiomes();
|
||||||
|
|
||||||
|
BiomeTemplate getTemplate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,4 +66,9 @@ public class UserDefinedBiomeBuilder implements BiomeBuilder {
|
|||||||
public ProbabilityCollection<Biome> getVanillaBiomes() {
|
public ProbabilityCollection<Biome> getVanillaBiomes() {
|
||||||
return template.getVanilla();
|
return template.getVanilla();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeTemplate getTemplate() {
|
||||||
|
return template;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
-1
@@ -65,7 +65,6 @@ public class ExpressionFunctionTemplate extends SamplerTemplate<ExpressionFuncti
|
|||||||
Map<String, Function> noiseFunctionMap = new HashMap<>();
|
Map<String, Function> noiseFunctionMap = new HashMap<>();
|
||||||
|
|
||||||
for(Map.Entry<String, FunctionTemplate> entry : expressions.entrySet()) {
|
for(Map.Entry<String, FunctionTemplate> entry : expressions.entrySet()) {
|
||||||
System.out.println(entry);
|
|
||||||
noiseFunctionMap.put(entry.getKey(), UserDefinedFunction.newInstance(entry.getValue(), new Parser(), new Scope()));
|
noiseFunctionMap.put(entry.getKey(), UserDefinedFunction.newInstance(entry.getValue(), new Parser(), new Scope()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -73,6 +73,46 @@ public class ConfigPackTemplate implements ConfigTemplate {
|
|||||||
@Default
|
@Default
|
||||||
private String version = "0.1.0";
|
private String version = "0.1.0";
|
||||||
|
|
||||||
|
@Value("disable.carvers")
|
||||||
|
@Default
|
||||||
|
private boolean disableCarvers = false;
|
||||||
|
|
||||||
|
@Value("disable.structures")
|
||||||
|
@Default
|
||||||
|
private boolean disableStructures = false;
|
||||||
|
|
||||||
|
@Value("disable.ores")
|
||||||
|
@Default
|
||||||
|
private boolean disableOres = false;
|
||||||
|
|
||||||
|
@Value("disable.trees")
|
||||||
|
@Default
|
||||||
|
private boolean disableTrees = false;
|
||||||
|
|
||||||
|
@Value("disable.flora")
|
||||||
|
@Default
|
||||||
|
private boolean disableFlora = false;
|
||||||
|
|
||||||
|
public boolean disableCarvers() {
|
||||||
|
return disableCarvers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean disableFlora() {
|
||||||
|
return disableFlora;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean disableOres() {
|
||||||
|
return disableOres;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean disableStructures() {
|
||||||
|
return disableStructures;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean disableTrees() {
|
||||||
|
return disableTrees;
|
||||||
|
}
|
||||||
|
|
||||||
public LinkedHashMap<String, FunctionTemplate> getFunctions() {
|
public LinkedHashMap<String, FunctionTemplate> getFunctions() {
|
||||||
return functions;
|
return functions;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -190,10 +190,19 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
|||||||
@Default
|
@Default
|
||||||
private Map<UserDefinedCarver, Integer> carvers = new HashMap<>();
|
private Map<UserDefinedCarver, Integer> carvers = new HashMap<>();
|
||||||
|
|
||||||
|
@Value("colors")
|
||||||
|
@Abstractable
|
||||||
|
@Default
|
||||||
|
private Map<String, Integer> colors = new HashMap<>(); // Plain ol' map, so platforms can decide what to do with colors (if anything).
|
||||||
|
|
||||||
public Set<String> getTags() {
|
public Set<String> getTags() {
|
||||||
return tags;
|
return tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<String, Integer> getColors() {
|
||||||
|
return colors;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<UserDefinedCarver, Integer> getCarvers() {
|
public Map<UserDefinedCarver, Integer> getCarvers() {
|
||||||
return carvers;
|
return carvers;
|
||||||
}
|
}
|
||||||
|
|||||||
+18
@@ -10,6 +10,7 @@ import com.dfsek.terra.api.util.world.PaletteUtil;
|
|||||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||||
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||||
|
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.palette.Palette;
|
import com.dfsek.terra.api.world.palette.Palette;
|
||||||
import com.dfsek.terra.config.pack.ConfigPack;
|
import com.dfsek.terra.config.pack.ConfigPack;
|
||||||
@@ -21,9 +22,15 @@ import com.dfsek.terra.world.carving.NoiseCarver;
|
|||||||
import com.dfsek.terra.world.generation.math.SamplerCache;
|
import com.dfsek.terra.world.generation.math.SamplerCache;
|
||||||
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
||||||
import com.dfsek.terra.world.generation.math.samplers.Sampler2D;
|
import com.dfsek.terra.world.generation.math.samplers.Sampler2D;
|
||||||
|
import com.dfsek.terra.world.population.CavePopulator;
|
||||||
|
import com.dfsek.terra.world.population.OrePopulator;
|
||||||
|
import com.dfsek.terra.world.population.StructurePopulator;
|
||||||
|
import com.dfsek.terra.world.population.TreePopulator;
|
||||||
import net.jafama.FastMath;
|
import net.jafama.FastMath;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class DefaultChunkGenerator2D implements TerraChunkGenerator {
|
public class DefaultChunkGenerator2D implements TerraChunkGenerator {
|
||||||
@@ -31,12 +38,18 @@ public class DefaultChunkGenerator2D implements TerraChunkGenerator {
|
|||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
|
|
||||||
private final Carver carver;
|
private final Carver carver;
|
||||||
|
private final List<TerraBlockPopulator> blockPopulators = new ArrayList<>();
|
||||||
|
|
||||||
private final SamplerCache cache;
|
private final SamplerCache cache;
|
||||||
|
|
||||||
public DefaultChunkGenerator2D(ConfigPack c, TerraPlugin main, SamplerCache cache) {
|
public DefaultChunkGenerator2D(ConfigPack c, TerraPlugin main, SamplerCache cache) {
|
||||||
this.configPack = c;
|
this.configPack = c;
|
||||||
this.main = main;
|
this.main = main;
|
||||||
|
blockPopulators.add(new CavePopulator(main));
|
||||||
|
blockPopulators.add(new StructurePopulator(main));
|
||||||
|
blockPopulators.add(new OrePopulator(main));
|
||||||
|
blockPopulators.add(new TreePopulator(main));
|
||||||
|
blockPopulators.add(new TreePopulator(main));
|
||||||
carver = new NoiseCarver(new Range(0, 255), main.getWorldHandle().createBlockData("minecraft:air"), main);
|
carver = new NoiseCarver(new Range(0, 255), main.getWorldHandle().createBlockData("minecraft:air"), main);
|
||||||
this.cache = cache;
|
this.cache = cache;
|
||||||
}
|
}
|
||||||
@@ -125,4 +138,9 @@ public class DefaultChunkGenerator2D implements TerraChunkGenerator {
|
|||||||
public Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth) {
|
public Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth) {
|
||||||
return new Sampler2D(chunkX, chunkZ, provider, world, elevationSmooth);
|
return new Sampler2D(chunkX, chunkZ, provider, world, elevationSmooth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TerraBlockPopulator> getPopulators() {
|
||||||
|
return blockPopulators;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+21
-1
@@ -17,6 +17,7 @@ import com.dfsek.terra.api.util.world.PaletteUtil;
|
|||||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||||
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||||
|
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||||
import com.dfsek.terra.api.world.palette.Palette;
|
import com.dfsek.terra.api.world.palette.Palette;
|
||||||
import com.dfsek.terra.api.world.palette.SinglePalette;
|
import com.dfsek.terra.api.world.palette.SinglePalette;
|
||||||
@@ -28,8 +29,15 @@ import com.dfsek.terra.world.TerraWorld;
|
|||||||
import com.dfsek.terra.world.carving.NoiseCarver;
|
import com.dfsek.terra.world.carving.NoiseCarver;
|
||||||
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
import com.dfsek.terra.world.generation.math.samplers.Sampler;
|
||||||
import com.dfsek.terra.world.generation.math.samplers.Sampler3D;
|
import com.dfsek.terra.world.generation.math.samplers.Sampler3D;
|
||||||
|
import com.dfsek.terra.world.population.CavePopulator;
|
||||||
|
import com.dfsek.terra.world.population.FloraPopulator;
|
||||||
|
import com.dfsek.terra.world.population.OrePopulator;
|
||||||
|
import com.dfsek.terra.world.population.StructurePopulator;
|
||||||
|
import com.dfsek.terra.world.population.TreePopulator;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
@@ -38,14 +46,21 @@ public class DefaultChunkGenerator3D implements TerraChunkGenerator {
|
|||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
private final BlockType water;
|
private final BlockType water;
|
||||||
private final SinglePalette<BlockData> blank;
|
private final SinglePalette<BlockData> blank;
|
||||||
|
private final List<TerraBlockPopulator> blockPopulators = new ArrayList<>();
|
||||||
|
|
||||||
private final Carver carver;
|
private final Carver carver;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public DefaultChunkGenerator3D(ConfigPack c, TerraPlugin main) {
|
public DefaultChunkGenerator3D(ConfigPack c, TerraPlugin main) {
|
||||||
this.configPack = c;
|
this.configPack = c;
|
||||||
this.main = main;
|
this.main = main;
|
||||||
|
|
||||||
|
blockPopulators.add(new CavePopulator(main));
|
||||||
|
blockPopulators.add(new StructurePopulator(main));
|
||||||
|
blockPopulators.add(new OrePopulator(main));
|
||||||
|
blockPopulators.add(new TreePopulator(main));
|
||||||
|
blockPopulators.add(new FloraPopulator(main));
|
||||||
|
|
||||||
carver = new NoiseCarver(new Range(0, 255), main.getWorldHandle().createBlockData("minecraft:air"), main);
|
carver = new NoiseCarver(new Range(0, 255), main.getWorldHandle().createBlockData("minecraft:air"), main);
|
||||||
water = main.getWorldHandle().createBlockData("minecraft:water").getBlockType();
|
water = main.getWorldHandle().createBlockData("minecraft:water").getBlockType();
|
||||||
blank = new SinglePalette<>(main.getWorldHandle().createBlockData("minecraft:air"));
|
blank = new SinglePalette<>(main.getWorldHandle().createBlockData("minecraft:air"));
|
||||||
@@ -236,4 +251,9 @@ public class DefaultChunkGenerator3D implements TerraChunkGenerator {
|
|||||||
public Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth) {
|
public Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth) {
|
||||||
return new Sampler3D(chunkX, chunkZ, provider, world, elevationSmooth);
|
return new Sampler3D(chunkX, chunkZ, provider, world, elevationSmooth);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TerraBlockPopulator> getPopulators() {
|
||||||
|
return blockPopulators;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.dfsek.terra.api.platform.handle.WorldHandle;
|
|||||||
import com.dfsek.terra.api.platform.world.Chunk;
|
import com.dfsek.terra.api.platform.world.Chunk;
|
||||||
import com.dfsek.terra.api.platform.world.World;
|
import com.dfsek.terra.api.platform.world.World;
|
||||||
import com.dfsek.terra.api.util.world.PopulationUtil;
|
import com.dfsek.terra.api.util.world.PopulationUtil;
|
||||||
|
import com.dfsek.terra.api.world.generation.Chunkified;
|
||||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||||
import com.dfsek.terra.config.pack.WorldConfig;
|
import com.dfsek.terra.config.pack.WorldConfig;
|
||||||
@@ -23,7 +24,7 @@ import java.util.Map;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class CavePopulator implements TerraBlockPopulator {
|
public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||||
private static final Map<BlockType, BlockData> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
private static final Map<BlockType, BlockData> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
|
|
||||||
@@ -41,6 +42,7 @@ public class CavePopulator implements TerraBlockPopulator {
|
|||||||
Random random = PopulationUtil.getRandom(chunk);
|
Random random = PopulationUtil.getRandom(chunk);
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
WorldConfig config = tw.getConfig();
|
WorldConfig config = tw.getConfig();
|
||||||
|
if(config.getTemplate().disableCarvers()) return;
|
||||||
|
|
||||||
for(UserDefinedCarver c : config.getCarvers()) {
|
for(UserDefinedCarver c : config.getCarvers()) {
|
||||||
CarverTemplate template = c.getConfig();
|
CarverTemplate template = c.getConfig();
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class FloraPopulator implements TerraBlockPopulator {
|
|||||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
try(ProfileFuture ignored = tw.getProfiler().measure("FloraTime")) {
|
try(ProfileFuture ignored = tw.getProfiler().measure("FloraTime")) {
|
||||||
|
if(tw.getConfig().getTemplate().disableCarvers()) return;
|
||||||
|
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
BiomeProvider provider = tw.getBiomeProvider();
|
BiomeProvider provider = tw.getBiomeProvider();
|
||||||
Map<Vector2, List<FloraLayer>> layers = new HashMap<>();
|
Map<Vector2, List<FloraLayer>> layers = new HashMap<>();
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public class OrePopulator implements TerraBlockPopulator {
|
|||||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
try(ProfileFuture ignored = tw.getProfiler().measure("OreTime")) {
|
try(ProfileFuture ignored = tw.getProfiler().measure("OreTime")) {
|
||||||
|
if(tw.getConfig().getTemplate().disableCarvers()) return;
|
||||||
|
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
for(int cx = -1; cx <= 1; cx++) {
|
for(int cx = -1; cx <= 1; cx++) {
|
||||||
for(int cz = -1; cz <= 1; cz++) {
|
for(int cz = -1; cz <= 1; cz++) {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import com.dfsek.terra.api.structures.structure.Rotation;
|
|||||||
import com.dfsek.terra.api.util.FastRandom;
|
import com.dfsek.terra.api.util.FastRandom;
|
||||||
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
import com.dfsek.terra.api.world.biome.UserDefinedBiome;
|
||||||
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
import com.dfsek.terra.api.world.biome.provider.BiomeProvider;
|
||||||
|
import com.dfsek.terra.api.world.generation.Chunkified;
|
||||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||||
import com.dfsek.terra.config.pack.ConfigPack;
|
import com.dfsek.terra.config.pack.ConfigPack;
|
||||||
import com.dfsek.terra.config.pack.WorldConfig;
|
import com.dfsek.terra.config.pack.WorldConfig;
|
||||||
@@ -20,7 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class StructurePopulator implements TerraBlockPopulator {
|
public class StructurePopulator implements TerraBlockPopulator, Chunkified {
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
|
|
||||||
public StructurePopulator(TerraPlugin main) {
|
public StructurePopulator(TerraPlugin main) {
|
||||||
@@ -32,6 +33,8 @@ public class StructurePopulator implements TerraBlockPopulator {
|
|||||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
try(ProfileFuture ignored = tw.getProfiler().measure("StructureTime")) {
|
try(ProfileFuture ignored = tw.getProfiler().measure("StructureTime")) {
|
||||||
|
if(tw.getConfig().getTemplate().disableCarvers()) return;
|
||||||
|
|
||||||
int cx = (chunk.getX() << 4);
|
int cx = (chunk.getX() << 4);
|
||||||
int cz = (chunk.getZ() << 4);
|
int cz = (chunk.getZ() << 4);
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
|
|||||||
@@ -33,6 +33,8 @@ public class TreePopulator implements TerraBlockPopulator {
|
|||||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||||
TerraWorld tw = main.getWorld(world);
|
TerraWorld tw = main.getWorld(world);
|
||||||
try(ProfileFuture ignored = tw.getProfiler().measure("TreeTime")) {
|
try(ProfileFuture ignored = tw.getProfiler().measure("TreeTime")) {
|
||||||
|
if(tw.getConfig().getTemplate().disableCarvers()) return;
|
||||||
|
|
||||||
if(!tw.isSafe()) return;
|
if(!tw.isSafe()) return;
|
||||||
BiomeProvider provider = tw.getBiomeProvider();
|
BiomeProvider provider = tw.getBiomeProvider();
|
||||||
Random random = PopulationUtil.getRandom(chunk);
|
Random random = PopulationUtil.getRandom(chunk);
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ import com.dfsek.terra.config.loaders.config.biome.templates.provider.SingleBiom
|
|||||||
import com.dfsek.terra.config.loaders.config.sampler.NoiseSamplerBuilderLoader;
|
import com.dfsek.terra.config.loaders.config.sampler.NoiseSamplerBuilderLoader;
|
||||||
import com.dfsek.terra.config.pack.ConfigPack;
|
import com.dfsek.terra.config.pack.ConfigPack;
|
||||||
import com.dfsek.terra.config.templates.AbstractableTemplate;
|
import com.dfsek.terra.config.templates.AbstractableTemplate;
|
||||||
|
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||||
import com.dfsek.terra.registry.config.BiomeRegistry;
|
import com.dfsek.terra.registry.config.BiomeRegistry;
|
||||||
import com.dfsek.terra.registry.config.NoiseRegistry;
|
import com.dfsek.terra.registry.config.NoiseRegistry;
|
||||||
import com.dfsek.terra.world.TerraWorld;
|
import com.dfsek.terra.world.TerraWorld;
|
||||||
@@ -306,6 +307,11 @@ public class DistributionTest {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeTemplate getTemplate() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Generator getGenerator(World w) {
|
public Generator getGenerator(World w) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -15,6 +15,13 @@ configureCommon()
|
|||||||
|
|
||||||
group = "com.dfsek.terra.bukkit"
|
group = "com.dfsek.terra.bukkit"
|
||||||
|
|
||||||
|
val mcVersion = "1.16.5"
|
||||||
|
val testDir = "target/server/"
|
||||||
|
val testMem = "3G"
|
||||||
|
|
||||||
|
val paperURL = "https://papermc.io/api/v1/paper/%version%/latest/download/"
|
||||||
|
val purpurURL = "https://ci.pl3x.net/job/Purpur/lastSuccessfulBuild/artifact/final/purpurclip.jar"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
maven { url = uri("http://maven.enginehub.org/repo/") }
|
maven { url = uri("http://maven.enginehub.org/repo/") }
|
||||||
@@ -35,73 +42,155 @@ dependencies {
|
|||||||
"shadedImplementation"("com.google.guava:guava:30.0-jre")
|
"shadedImplementation"("com.google.guava:guava:30.0-jre")
|
||||||
}
|
}
|
||||||
|
|
||||||
val testDir = "target/server/"
|
val aikarsFlags = listOf("-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled", "-XX:MaxGCPauseMillis=200",
|
||||||
|
"-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC", "-XX:+AlwaysPreTouch",
|
||||||
|
"-XX:G1NewSizePercent=30", "-XX:G1MaxNewSizePercent=40", "-XX:G1HeapRegionSize=8M",
|
||||||
|
"-XX:G1ReservePercent=20", "-XX:G1HeapWastePercent=5", "-XX:G1MixedGCCountTarget=4",
|
||||||
|
"-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90",
|
||||||
|
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
|
||||||
|
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
|
||||||
|
"-Daikars.new.flags=true", "-DIReallyKnowWhatIAmDoingISwear")
|
||||||
|
|
||||||
val setupServer = tasks.create("setupServer") {
|
fun downloadPaperclip(url: String, dir: String) {
|
||||||
dependsOn("shadowJar")
|
val clip = URL(url.replace("%version%", mcVersion))
|
||||||
doFirst {
|
val clipReadableByteChannel = Channels.newChannel(clip.openStream())
|
||||||
// clean
|
val clipFile = file("$testDir/$dir/paperclip.jar")
|
||||||
file("${testDir}/").deleteRecursively()
|
val clipOutputStream = clipFile.outputStream()
|
||||||
file("${testDir}/plugins").mkdirs()
|
val clipFileChannel = clipOutputStream.channel
|
||||||
|
clipFileChannel.transferFrom(clipReadableByteChannel, 0, Long.MAX_VALUE)
|
||||||
|
}
|
||||||
|
|
||||||
// Downloading latest paper jar.
|
fun copyTerra(dir: String) {
|
||||||
val paperUrl = URL("https://papermc.io/api/v1/paper/1.16.4/latest/download")
|
file("$testDir/$dir").walk().forEach {
|
||||||
val paperReadableByteChannel = Channels.newChannel(paperUrl.openStream())
|
if(it.name.startsWith("Terra-") && it.name.endsWith(".jar")) it.delete() // Delete old Terra jar(s)
|
||||||
val paperFile = file("${testDir}/paper.jar")
|
}
|
||||||
val paperFileOutputStream = paperFile.outputStream()
|
copy {
|
||||||
val paperFileChannel = paperFileOutputStream.channel
|
from("$buildDir/libs/Terra-bukkit-$version-shaded.jar")
|
||||||
paperFileChannel.transferFrom(paperReadableByteChannel, 0, Long.MAX_VALUE)
|
into("$testDir/$dir/plugins/")
|
||||||
|
|
||||||
// Cloning test setup.
|
|
||||||
gitClone("https://github.com/PolyhedralDev/WorldGenTestServer")
|
|
||||||
// Copying plugins
|
|
||||||
Files.move(Paths.get("WorldGenTestServer/plugins"),
|
|
||||||
Paths.get("$testDir/plugins"),
|
|
||||||
StandardCopyOption.REPLACE_EXISTING)
|
|
||||||
// Copying config
|
|
||||||
val serverText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/server.properties").readText()
|
|
||||||
file("${testDir}/server.properties").writeText(serverText)
|
|
||||||
val bukkitText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/bukkit.yml").readText()
|
|
||||||
file("${testDir}/bukkit.yml").writeText(bukkitText.replace("\${world}", "world").replace("\${gen}", "Terra:DEFAULT"))
|
|
||||||
|
|
||||||
File("${testDir}/eula.txt").writeText("eula=true")
|
|
||||||
|
|
||||||
// clean up
|
|
||||||
file("WorldGenTestServer").deleteRecursively()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val testWithPaper = task<JavaExec>(name = "testWithPaper") {
|
fun installServer(dir: String) {
|
||||||
|
// clean
|
||||||
|
file("$testDir/$dir").deleteRecursively()
|
||||||
|
file("$testDir/$dir/plugins").mkdirs()
|
||||||
|
// Cloning test setup.
|
||||||
|
gitClone("https://github.com/PolyhedralDev/WorldGenTestServer")
|
||||||
|
// Copying plugins
|
||||||
|
Files.move(Paths.get("WorldGenTestServer/plugins"),
|
||||||
|
Paths.get("$testDir/$dir/plugins"),
|
||||||
|
StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
// Copying config
|
||||||
|
val serverText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/server.properties").readText()
|
||||||
|
file("$testDir/$dir/server.properties").writeText(serverText)
|
||||||
|
val bukkitText = URL("https://raw.githubusercontent.com/PolyhedralDev/WorldGenTestServer/master/bukkit.yml").readText()
|
||||||
|
file("$testDir/$dir/bukkit.yml").writeText(bukkitText.replace("\${world}", "world").replace("\${gen}", "Terra:DEFAULT"))
|
||||||
|
|
||||||
|
println("By proceeding, you are agreeing to the Minecraft EULA: https://account.mojang.com/documents/minecraft_eula")
|
||||||
|
file("$testDir/$dir/eula.txt").writeText("eula=true")
|
||||||
|
|
||||||
|
// clean up
|
||||||
|
file("WorldGenTestServer").deleteRecursively()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deleteFolder(folder: File) {
|
||||||
|
if(folder.exists()) folder.deleteRecursively()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun deleteFile(file: File) {
|
||||||
|
if(file.exists()) file.delete()
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.create("cleanWorlds") {
|
||||||
|
group = "bukkit"
|
||||||
|
doFirst {
|
||||||
|
deleteFolder(file("$testDir/paper/world"))
|
||||||
|
deleteFolder(file("$testDir/paper/world_nether"))
|
||||||
|
deleteFolder(file("$testDir/paper/world_the_end"))
|
||||||
|
|
||||||
|
deleteFolder(file("$testDir/purpur/world"))
|
||||||
|
deleteFolder(file("$testDir/purpur/world_nether"))
|
||||||
|
deleteFolder(file("$testDir/purpur/world_the_end"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.create("updatePaper") {
|
||||||
|
group = "bukkit"
|
||||||
|
doFirst {
|
||||||
|
deleteFile(file("$testDir/paper/paperclip.jar"))
|
||||||
|
downloadPaperclip(paperURL, "paper")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.create("updatePurpur") {
|
||||||
|
group = "bukkit"
|
||||||
|
doFirst {
|
||||||
|
deleteFile(file("$testDir/paper/paperclip.jar"))
|
||||||
|
downloadPaperclip(purpurURL, "purpur")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.create("installPaper") {
|
||||||
|
group = "bukkit"
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
doFirst {
|
||||||
|
installServer("paper")
|
||||||
|
// Downloading latest paper jar.
|
||||||
|
downloadPaperclip(paperURL, "paper")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.create("installPurpur") {
|
||||||
|
group = "bukkit"
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
doFirst {
|
||||||
|
installServer("purpur")
|
||||||
|
// Downloading latest paper jar.
|
||||||
|
downloadPaperclip(purpurURL, "purpur")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
task<JavaExec>(name = "runPaper") {
|
||||||
|
group = "bukkit"
|
||||||
standardInput = System.`in`
|
standardInput = System.`in`
|
||||||
dependsOn("shadowJar")
|
dependsOn("shadowJar")
|
||||||
// Copy Terra into dir
|
// Copy Terra into dir
|
||||||
doFirst {
|
doFirst {
|
||||||
copy {
|
copyTerra("paper")
|
||||||
from("${buildDir}/libs/Terra-bukkit-${version}-shaded.jar")
|
|
||||||
into("${testDir}/plugins/")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main = "io.papermc.paperclip.Paperclip"
|
main = "io.papermc.paperclip.Paperclip"
|
||||||
jvmArgs = listOf("-XX:+UseG1GC", "-XX:+ParallelRefProcEnabled", "-XX:MaxGCPauseMillis=200",
|
jvmArgs = aikarsFlags
|
||||||
"-XX:+UnlockExperimentalVMOptions", "-XX:+DisableExplicitGC", "-XX:+AlwaysPreTouch",
|
maxHeapSize = testMem
|
||||||
"-XX:G1NewSizePercent=30", "-XX:G1MaxNewSizePercent=40", "-XX:G1HeapRegionSize=8M",
|
minHeapSize = testMem
|
||||||
"-XX:G1ReservePercent=20", "-XX:G1HeapWastePercent=5", "-XX:G1MixedGCCountTarget=4",
|
|
||||||
"-XX:InitiatingHeapOccupancyPercent=15", "-XX:G1MixedGCLiveThresholdPercent=90",
|
|
||||||
"-XX:G1RSetUpdatingPauseTimePercent=5", "-XX:SurvivorRatio=32", "-XX:+PerfDisableSharedMem",
|
|
||||||
"-XX:MaxTenuringThreshold=1", "-Dusing.aikars.flags=https://mcflags.emc.gs",
|
|
||||||
"-Daikars.new.flags=true", "-DIReallyKnowWhatIAmDoingISwear")
|
|
||||||
maxHeapSize = "4G"
|
|
||||||
minHeapSize = "4G"
|
|
||||||
//args = listOf("nogui")
|
//args = listOf("nogui")
|
||||||
workingDir = file("${testDir}/")
|
workingDir = file("$testDir/paper")
|
||||||
classpath = files("${testDir}/paper.jar")
|
classpath = files("$testDir/paper/paperclip.jar")
|
||||||
|
}
|
||||||
|
|
||||||
|
task<JavaExec>(name = "runPurpur") {
|
||||||
|
group = "bukkit"
|
||||||
|
standardInput = System.`in`
|
||||||
|
dependsOn("shadowJar")
|
||||||
|
// Copy Terra into dir
|
||||||
|
doFirst {
|
||||||
|
copyTerra("purpur")
|
||||||
|
}
|
||||||
|
|
||||||
|
main = "io.papermc.paperclip.Paperclip"
|
||||||
|
jvmArgs = aikarsFlags
|
||||||
|
maxHeapSize = testMem
|
||||||
|
minHeapSize = testMem
|
||||||
|
//args = listOf("nogui")
|
||||||
|
workingDir = file("$testDir/purpur")
|
||||||
|
classpath = files("$testDir/purpur/paperclip.jar")
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks.named<ShadowJar>("shadowJar") {
|
tasks.named<ShadowJar>("shadowJar") {
|
||||||
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
|
relocate("org.bstats.bukkit", "com.dfsek.terra.lib.bstats")
|
||||||
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
|
relocate("io.papermc.lib", "com.dfsek.terra.lib.paperlib")
|
||||||
}
|
}
|
||||||
|
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
create<MavenPublication>("mavenJava") {
|
create<MavenPublication>("mavenJava") {
|
||||||
@@ -112,7 +201,6 @@ publishing {
|
|||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
val mavenUrl = "https://repo.codemc.io/repository/maven-releases/"
|
val mavenUrl = "https://repo.codemc.io/repository/maven-releases/"
|
||||||
val mavenSnapshotUrl = "https://repo.codemc.io/repository/maven-snapshots/"
|
|
||||||
|
|
||||||
maven(mavenUrl) {
|
maven(mavenUrl) {
|
||||||
val mavenUsername: String? by project
|
val mavenUsername: String? by project
|
||||||
|
|||||||
+5
-10
@@ -23,6 +23,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -40,20 +42,13 @@ public class BukkitChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
|
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
|
|
||||||
private final List<TerraBlockPopulator> populators = new LinkedList<>();
|
|
||||||
|
|
||||||
private boolean needsLoad = true;
|
private boolean needsLoad = true;
|
||||||
|
|
||||||
public BukkitChunkGeneratorWrapper(TerraChunkGenerator delegate) {
|
public BukkitChunkGeneratorWrapper(TerraChunkGenerator delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
this.main = delegate.getMain();
|
this.main = delegate.getMain();
|
||||||
popMan = new PopulationManager(main);
|
this.popMan = new PopulationManager(delegate, main);
|
||||||
popMan.attach(new OrePopulator(main));
|
|
||||||
popMan.attach(new TreePopulator(main));
|
|
||||||
popMan.attach(new FloraPopulator(main));
|
|
||||||
populators.add(new CavePopulator(main));
|
|
||||||
populators.add(new StructurePopulator(main));
|
|
||||||
populators.add(popMan);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -96,7 +91,7 @@ public class BukkitChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
public @NotNull List<BlockPopulator> getDefaultPopulators(@NotNull World world) {
|
||||||
return populators.stream().map(BukkitPopulatorWrapper::new).collect(Collectors.toList());
|
return Arrays.asList(popMan, new BukkitPopulatorWrapper(delegate));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,27 +0,0 @@
|
|||||||
package com.dfsek.terra.bukkit.generator;
|
|
||||||
|
|
||||||
import com.dfsek.terra.api.platform.world.Chunk;
|
|
||||||
import com.dfsek.terra.api.platform.world.World;
|
|
||||||
import com.dfsek.terra.api.platform.world.generator.BlockPopulator;
|
|
||||||
import com.dfsek.terra.bukkit.world.BukkitChunk;
|
|
||||||
import com.dfsek.terra.bukkit.world.BukkitWorld;
|
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
public class BukkitPopulator implements BlockPopulator {
|
|
||||||
private final org.bukkit.generator.BlockPopulator handle;
|
|
||||||
|
|
||||||
public BukkitPopulator(org.bukkit.generator.BlockPopulator handle) {
|
|
||||||
this.handle = handle;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void populate(World world, Random random, Chunk chunk) {
|
|
||||||
handle.populate(((BukkitWorld) world).getHandle(), random, ((BukkitChunk) chunk).getHandle());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public org.bukkit.generator.BlockPopulator getHandle() {
|
|
||||||
return handle;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+9
-3
@@ -1,6 +1,8 @@
|
|||||||
package com.dfsek.terra.bukkit.generator;
|
package com.dfsek.terra.bukkit.generator;
|
||||||
|
|
||||||
|
import com.dfsek.terra.api.world.generation.Chunkified;
|
||||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||||
|
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@@ -10,14 +12,18 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class BukkitPopulatorWrapper extends BlockPopulator {
|
public class BukkitPopulatorWrapper extends BlockPopulator {
|
||||||
private final TerraBlockPopulator delegate;
|
private final TerraChunkGenerator delegate;
|
||||||
|
|
||||||
public BukkitPopulatorWrapper(TerraBlockPopulator delegate) {
|
public BukkitPopulatorWrapper(TerraChunkGenerator delegate) {
|
||||||
this.delegate = delegate;
|
this.delegate = delegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk source) {
|
public void populate(@NotNull World world, @NotNull Random random, @NotNull Chunk source) {
|
||||||
delegate.populate(BukkitAdapter.adapt(world), BukkitAdapter.adapt(source));
|
delegate.getPopulators().forEach(populator -> {
|
||||||
|
if(populator instanceof Chunkified) {
|
||||||
|
populator.populate(BukkitAdapter.adapt(world), BukkitAdapter.adapt(source));
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+31
-30
@@ -4,54 +4,35 @@ import com.dfsek.terra.api.TerraPlugin;
|
|||||||
import com.dfsek.terra.api.platform.world.Chunk;
|
import com.dfsek.terra.api.platform.world.Chunk;
|
||||||
import com.dfsek.terra.api.platform.world.World;
|
import com.dfsek.terra.api.platform.world.World;
|
||||||
import com.dfsek.terra.api.util.FastRandom;
|
import com.dfsek.terra.api.util.FastRandom;
|
||||||
import com.dfsek.terra.api.util.GlueList;
|
import com.dfsek.terra.api.world.generation.Chunkified;
|
||||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||||
|
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||||
import com.dfsek.terra.bukkit.TerraBukkitPlugin;
|
import com.dfsek.terra.bukkit.TerraBukkitPlugin;
|
||||||
|
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||||
import com.dfsek.terra.profiler.ProfileFuture;
|
import com.dfsek.terra.profiler.ProfileFuture;
|
||||||
import com.dfsek.terra.profiler.WorldProfiler;
|
import com.dfsek.terra.profiler.WorldProfiler;
|
||||||
|
import org.bukkit.generator.BlockPopulator;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Cursed management class for the horrors of Bukkit population
|
* Cursed management class for the horrors of Bukkit population
|
||||||
*/
|
*/
|
||||||
public class PopulationManager implements TerraBlockPopulator {
|
public class PopulationManager extends BlockPopulator {
|
||||||
private final List<TerraBlockPopulator> attachedPopulators = new GlueList<>();
|
private final TerraChunkGenerator generator;
|
||||||
private final HashSet<ChunkCoordinate> needsPop = new HashSet<>();
|
private final HashSet<ChunkCoordinate> needsPop = new HashSet<>();
|
||||||
private final TerraPlugin main;
|
private final TerraPlugin main;
|
||||||
private WorldProfiler profiler;
|
private WorldProfiler profiler;
|
||||||
|
|
||||||
public PopulationManager(TerraPlugin main) {
|
public PopulationManager(TerraChunkGenerator generator, TerraPlugin main) {
|
||||||
|
this.generator = generator;
|
||||||
this.main = main;
|
this.main = main;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void attach(TerraBlockPopulator populator) {
|
|
||||||
this.attachedPopulators.add(populator);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@SuppressWarnings("try")
|
|
||||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
|
||||||
try(ProfileFuture ignored = measure()) {
|
|
||||||
needsPop.add(new ChunkCoordinate(chunk));
|
|
||||||
int x = chunk.getX();
|
|
||||||
int z = chunk.getZ();
|
|
||||||
if(((TerraBukkitPlugin) main).isEnabled()) {
|
|
||||||
for(int xi = -1; xi <= 1; xi++) {
|
|
||||||
for(int zi = -1; zi <= 1; zi++) {
|
|
||||||
if(xi == 0 && zi == 0) continue;
|
|
||||||
if(world.isChunkGenerated(xi + x, zi + z)) checkNeighbors(xi + x, zi + z, world);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private ProfileFuture measure() {
|
private ProfileFuture measure() {
|
||||||
if(profiler != null) return profiler.measure("PopulationManagerTime");
|
if(profiler != null) return profiler.measure("PopulationManagerTime");
|
||||||
return null;
|
return null;
|
||||||
@@ -87,10 +68,30 @@ public class PopulationManager implements TerraBlockPopulator {
|
|||||||
long zRand = (random.nextLong() / 2L << 1L) + 1L;
|
long zRand = (random.nextLong() / 2L << 1L) + 1L;
|
||||||
random.setSeed((long) x * xRand + (long) z * zRand ^ w.getSeed());
|
random.setSeed((long) x * xRand + (long) z * zRand ^ w.getSeed());
|
||||||
Chunk currentChunk = w.getChunkAt(x, z);
|
Chunk currentChunk = w.getChunkAt(x, z);
|
||||||
for(TerraBlockPopulator r : attachedPopulators) {
|
generator.getPopulators().forEach(populator -> {
|
||||||
r.populate(w, currentChunk);
|
if(!(populator instanceof Chunkified)) {
|
||||||
}
|
populator.populate(w, currentChunk);
|
||||||
|
}
|
||||||
|
});
|
||||||
needsPop.remove(c);
|
needsPop.remove(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(org.bukkit.@NotNull World world, @NotNull Random random, org.bukkit.@NotNull Chunk source) {
|
||||||
|
try(ProfileFuture ignored = measure()) {
|
||||||
|
Chunk chunk = BukkitAdapter.adapt(source);
|
||||||
|
needsPop.add(new ChunkCoordinate(chunk));
|
||||||
|
int x = chunk.getX();
|
||||||
|
int z = chunk.getZ();
|
||||||
|
if(((TerraBukkitPlugin) main).isEnabled()) {
|
||||||
|
for(int xi = -1; xi <= 1; xi++) {
|
||||||
|
for(int zi = -1; zi <= 1; zi++) {
|
||||||
|
if(xi == 0 && zi == 0) continue;
|
||||||
|
if(world.isChunkGenerated(xi + x, zi + z)) checkNeighbors(xi + x, zi + z, BukkitAdapter.adapt(world));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@ configure<LoomGradleExtension> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tasks.register<RemapJarTask>("remapShadedJar") {
|
tasks.register<RemapJarTask>("remapShadedJar") {
|
||||||
|
group = "fabric"
|
||||||
val shadowJar = tasks.getByName<ShadowJar>("shadowJar")
|
val shadowJar = tasks.getByName<ShadowJar>("shadowJar")
|
||||||
dependsOn(shadowJar)
|
dependsOn(shadowJar)
|
||||||
input.set(shadowJar.archiveFile)
|
input.set(shadowJar.archiveFile)
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import com.dfsek.terra.config.builder.BiomeBuilder;
|
|||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.config.lang.Language;
|
import com.dfsek.terra.config.lang.Language;
|
||||||
import com.dfsek.terra.config.pack.ConfigPack;
|
import com.dfsek.terra.config.pack.ConfigPack;
|
||||||
|
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||||
import com.dfsek.terra.fabric.inventory.FabricItemHandle;
|
import com.dfsek.terra.fabric.inventory.FabricItemHandle;
|
||||||
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
|
import com.dfsek.terra.fabric.mixin.GeneratorTypeAccessor;
|
||||||
import com.dfsek.terra.fabric.world.FabricAdapter;
|
import com.dfsek.terra.fabric.world.FabricAdapter;
|
||||||
@@ -150,7 +151,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TerraWorld getWorld(World world) {
|
public TerraWorld getWorld(World world) {
|
||||||
if(worldMap.size() > 1) System.out.println(worldMap.size());
|
|
||||||
return worldMap.computeIfAbsent(world.getSeed(), w -> {
|
return worldMap.computeIfAbsent(world.getSeed(), w -> {
|
||||||
logger.info("Loading world " + w);
|
logger.info("Loading world " + w);
|
||||||
return new TerraWorld(world, ((FabricChunkGeneratorWrapper) ((FabricChunkGenerator) world.getGenerator()).getHandle()).getPack(), this);
|
return new TerraWorld(world, ((FabricChunkGeneratorWrapper) ((FabricChunkGenerator) world.getGenerator()).getHandle()).getPack(), this);
|
||||||
@@ -246,6 +246,9 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
DefaultBiomeFeatures.addFarmAnimals(spawnSettings);
|
DefaultBiomeFeatures.addFarmAnimals(spawnSettings);
|
||||||
DefaultBiomeFeatures.addMonsters(spawnSettings, 95, 5, 100);
|
DefaultBiomeFeatures.addMonsters(spawnSettings, 95, 5, 100);
|
||||||
|
|
||||||
|
BiomeTemplate template = biome.getTemplate();
|
||||||
|
Map<String, Integer> colors = template.getColors();
|
||||||
|
|
||||||
Biome vanilla = ((FabricBiome) new ArrayList<>(biome.getVanillaBiomes().getContents()).get(0)).getHandle();
|
Biome vanilla = ((FabricBiome) new ArrayList<>(biome.getVanillaBiomes().getContents()).get(0)).getHandle();
|
||||||
|
|
||||||
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
|
GenerationSettings.Builder generationSettings = new GenerationSettings.Builder();
|
||||||
@@ -254,28 +257,37 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
|
|
||||||
|
|
||||||
BiomeEffects.Builder effects = new BiomeEffects.Builder()
|
BiomeEffects.Builder effects = new BiomeEffects.Builder()
|
||||||
.waterColor(vanilla.getEffects().waterColor)
|
.waterColor(colors.getOrDefault("water", vanilla.getEffects().waterColor))
|
||||||
.waterFogColor(vanilla.getEffects().waterFogColor)
|
.waterFogColor(colors.getOrDefault("water-fog", vanilla.getEffects().waterFogColor))
|
||||||
.fogColor(vanilla.getEffects().fogColor)
|
.fogColor(colors.getOrDefault("fog", vanilla.getEffects().fogColor))
|
||||||
.skyColor(vanilla.getEffects().skyColor)
|
.skyColor(colors.getOrDefault("sky", vanilla.getEffects().skyColor))
|
||||||
.grassColorModifier(vanilla.getEffects().grassColorModifier);
|
.grassColorModifier(vanilla.getEffects().grassColorModifier);
|
||||||
vanilla.getEffects().grassColor.ifPresent(effects::grassColor);
|
|
||||||
vanilla.getEffects().foliageColor.ifPresent(effects::foliageColor);
|
|
||||||
|
|
||||||
return (new Biome.Builder())
|
if(colors.containsKey("grass")) {
|
||||||
|
effects.grassColor(colors.get("grass"));
|
||||||
|
} else {
|
||||||
|
vanilla.getEffects().grassColor.ifPresent(effects::grassColor);
|
||||||
|
}
|
||||||
|
vanilla.getEffects().foliageColor.ifPresent(effects::foliageColor);
|
||||||
|
if(colors.containsKey("foliage")) {
|
||||||
|
effects.foliageColor(colors.get("foliage"));
|
||||||
|
} else {
|
||||||
|
vanilla.getEffects().foliageColor.ifPresent(effects::foliageColor);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new Biome.Builder()
|
||||||
.precipitation(vanilla.getPrecipitation())
|
.precipitation(vanilla.getPrecipitation())
|
||||||
.category(vanilla.getCategory())
|
.category(vanilla.getCategory())
|
||||||
.depth(vanilla.getDepth())
|
.depth(vanilla.getDepth())
|
||||||
.scale(vanilla.getScale())
|
.scale(vanilla.getScale())
|
||||||
.temperature(vanilla.getTemperature())
|
.temperature(vanilla.getTemperature())
|
||||||
.downfall(vanilla.getDownfall())
|
.downfall(vanilla.getDownfall())
|
||||||
.effects(vanilla.getEffects()) // TODO: configurable
|
.effects(effects.build())
|
||||||
.spawnSettings(spawnSettings.build())
|
.spawnSettings(spawnSettings.build())
|
||||||
.generationSettings(generationSettings.build())
|
.generationSettings(generationSettings.build())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
@Override
|
@Override
|
||||||
public void onInitialize() {
|
public void onInitialize() {
|
||||||
instance = this;
|
instance = this;
|
||||||
@@ -327,10 +339,8 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
|||||||
|
|
||||||
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
|
CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> {
|
||||||
int max = manager.getMaxArgumentDepth();
|
int max = manager.getMaxArgumentDepth();
|
||||||
System.out.println("MAX:" + max);
|
|
||||||
RequiredArgumentBuilder<ServerCommandSource, String> arg = argument("arg" + (max - 1), StringArgumentType.word());
|
RequiredArgumentBuilder<ServerCommandSource, String> arg = argument("arg" + (max - 1), StringArgumentType.word());
|
||||||
for(int i = 0; i < max; i++) {
|
for(int i = 0; i < max; i++) {
|
||||||
System.out.println("arg " + i);
|
|
||||||
RequiredArgumentBuilder<ServerCommandSource, String> next = argument("arg" + (max - i - 1), StringArgumentType.word());
|
RequiredArgumentBuilder<ServerCommandSource, String> next = argument("arg" + (max - i - 1), StringArgumentType.word());
|
||||||
|
|
||||||
arg = next.then(assemble(arg, manager));
|
arg = next.then(assemble(arg, manager));
|
||||||
|
|||||||
+1
-5
@@ -27,11 +27,7 @@ public class PopulatorFeature extends Feature<DefaultFeatureConfig> {
|
|||||||
FabricChunkGeneratorWrapper gen = (FabricChunkGeneratorWrapper) chunkGenerator;
|
FabricChunkGeneratorWrapper gen = (FabricChunkGeneratorWrapper) chunkGenerator;
|
||||||
FabricChunkWorldAccess chunk = new FabricChunkWorldAccess(world, pos.getX() >> 4, pos.getZ() >> 4);
|
FabricChunkWorldAccess chunk = new FabricChunkWorldAccess(world, pos.getX() >> 4, pos.getZ() >> 4);
|
||||||
FabricWorld world1 = new FabricWorld(world.toServerWorld(), new FabricChunkGenerator(chunkGenerator));
|
FabricWorld world1 = new FabricWorld(world.toServerWorld(), new FabricChunkGenerator(chunkGenerator));
|
||||||
gen.getCavePopulator().populate(new FabricWorldAccess(world), chunk);
|
gen.getHandle().getPopulators().forEach(populator -> populator.populate(world1, chunk));
|
||||||
gen.getStructurePopulator().populate(new FabricWorldAccess(world), chunk);
|
|
||||||
gen.getOrePopulator().populate(world1, chunk);
|
|
||||||
gen.getTreePopulator().populate(world1, chunk);
|
|
||||||
gen.getFloraPopulator().populate(world1, chunk);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-26
@@ -50,32 +50,6 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
return pack;
|
return pack;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final FloraPopulator floraPopulator = new FloraPopulator(TerraFabricPlugin.getInstance());
|
|
||||||
private final OrePopulator orePopulator = new OrePopulator(TerraFabricPlugin.getInstance());
|
|
||||||
private final TreePopulator treePopulator = new TreePopulator(TerraFabricPlugin.getInstance());
|
|
||||||
private final StructurePopulator structurePopulator = new StructurePopulator(TerraFabricPlugin.getInstance());
|
|
||||||
private final CavePopulator cavePopulator = new CavePopulator(TerraFabricPlugin.getInstance());
|
|
||||||
|
|
||||||
public TreePopulator getTreePopulator() {
|
|
||||||
return treePopulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public OrePopulator getOrePopulator() {
|
|
||||||
return orePopulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FloraPopulator getFloraPopulator() {
|
|
||||||
return floraPopulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public StructurePopulator getStructurePopulator() {
|
|
||||||
return structurePopulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CavePopulator getCavePopulator() {
|
|
||||||
return cavePopulator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FabricChunkGeneratorWrapper(TerraBiomeSource biomeSource, long seed, ConfigPack configPack) {
|
public FabricChunkGeneratorWrapper(TerraBiomeSource biomeSource, long seed, ConfigPack configPack) {
|
||||||
super(biomeSource, new StructuresConfig(false));
|
super(biomeSource, new StructuresConfig(false));
|
||||||
this.pack = configPack;
|
this.pack = configPack;
|
||||||
@@ -124,6 +98,8 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isStrongholdStartingChunk(ChunkPos chunkPos) {
|
public boolean isStrongholdStartingChunk(ChunkPos chunkPos) {
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user