mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
begin work on impl
This commit is contained in:
@@ -4,6 +4,7 @@ import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.Handle;
|
||||
import com.dfsek.terra.api.block.state.BlockState;
|
||||
|
||||
@Deprecated
|
||||
public interface Block extends Handle {
|
||||
void setBlockData(BlockData data, boolean physics);
|
||||
|
||||
|
||||
@@ -16,4 +16,16 @@ public interface WorldConfig {
|
||||
SamplerCache getSamplerCache();
|
||||
|
||||
BiomeProvider getProvider();
|
||||
|
||||
int elevationBlend();
|
||||
|
||||
boolean disableTrees();
|
||||
|
||||
boolean disableCarving();
|
||||
|
||||
boolean disableOres();
|
||||
|
||||
boolean disableFlora();
|
||||
|
||||
boolean disableStructures();
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.api.world.biome.pipeline.mutator;
|
||||
|
||||
import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.collections.ProbabilityCollectionImpl;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.pipeline.BiomeMutator;
|
||||
@@ -8,12 +9,12 @@ import com.dfsek.terra.api.world.biome.generation.pipeline.BiomeMutator;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReplaceListMutator implements BiomeMutator {
|
||||
private final Map<TerraBiome, ProbabilityCollectionImpl<TerraBiome>> replace;
|
||||
private final Map<TerraBiome, ProbabilityCollection<TerraBiome>> replace;
|
||||
private final NoiseSampler sampler;
|
||||
private final ProbabilityCollectionImpl<TerraBiome> replaceDefault;
|
||||
private final ProbabilityCollection<TerraBiome> replaceDefault;
|
||||
private final String defaultTag;
|
||||
|
||||
public ReplaceListMutator(Map<TerraBiome, ProbabilityCollectionImpl<TerraBiome>> replace, String defaultTag, ProbabilityCollectionImpl<TerraBiome> replaceDefault, NoiseSampler sampler) {
|
||||
public ReplaceListMutator(Map<TerraBiome, ProbabilityCollection<TerraBiome>> replace, String defaultTag, ProbabilityCollection<TerraBiome> replaceDefault, NoiseSampler sampler) {
|
||||
this.replace = replace;
|
||||
this.sampler = sampler;
|
||||
this.defaultTag = defaultTag;
|
||||
|
||||
@@ -2,7 +2,6 @@ package com.dfsek.terra.api.world.biome.provider;
|
||||
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
|
||||
import com.dfsek.terra.registry.OpenRegistry;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.config.loaders.config.biome.templates.stage.mutator;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.api.util.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.util.collections.ProbabilityCollectionImpl;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.biome.generation.pipeline.BiomeMutator;
|
||||
@@ -19,11 +20,11 @@ public class ReplaceListMutatorTemplate extends MutatorStageTemplate {
|
||||
private ProbabilityCollectionImpl<BiomeBuilder> defaultTo;
|
||||
|
||||
@Value("to")
|
||||
private Map<BiomeBuilder, ProbabilityCollectionImpl<BiomeBuilder>> replace;
|
||||
private Map<BiomeBuilder, ProbabilityCollection<BiomeBuilder>> replace;
|
||||
|
||||
@Override
|
||||
public BiomeMutator build(long seed) {
|
||||
Map<TerraBiome, ProbabilityCollectionImpl<TerraBiome>> replaceMap = new HashMap<>();
|
||||
Map<TerraBiome, ProbabilityCollection<TerraBiome>> replaceMap = new HashMap<>();
|
||||
|
||||
replace.forEach((biomeBuilder, biomeBuilders) -> replaceMap.put(biomeBuilder.apply(seed), biomeBuilders.map(builder -> builder.apply(seed), true)));
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.structure.LootTable;
|
||||
import com.dfsek.terra.api.structure.Structure;
|
||||
import com.dfsek.terra.api.structures.loot.LootTableImpl;
|
||||
import com.dfsek.terra.api.structures.parser.lang.functions.FunctionBuilder;
|
||||
@@ -37,6 +38,8 @@ import com.dfsek.terra.config.loaders.config.sampler.NoiseSamplerBuilderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.sampler.templates.ImageSamplerTemplate;
|
||||
import com.dfsek.terra.api.config.ConfigType;
|
||||
import com.dfsek.terra.config.prototype.ProtoConfig;
|
||||
import com.dfsek.terra.registry.CheckedRegistryImpl;
|
||||
import com.dfsek.terra.registry.OpenRegistryImpl;
|
||||
import com.dfsek.terra.registry.config.ConfigTypeRegistry;
|
||||
import com.dfsek.terra.registry.config.FunctionRegistry;
|
||||
import com.dfsek.terra.registry.config.LootRegistry;
|
||||
@@ -89,7 +92,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
try {
|
||||
this.configTypeRegistry = new ConfigTypeRegistry(this, main, (id, configType) -> {
|
||||
OpenRegistry<?> openRegistry = configType.registrySupplier().get();
|
||||
registryMap.put(configType.getTypeClass(), ImmutablePair.of(openRegistry, new CheckedRegistry<>(openRegistry)));
|
||||
registryMap.put(configType.getTypeClass(), ImmutablePair.of(openRegistry, new CheckedRegistryImpl<>(openRegistry)));
|
||||
});
|
||||
this.loader = new FolderLoader(folder.toPath());
|
||||
this.main = main;
|
||||
@@ -132,7 +135,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
try {
|
||||
this.configTypeRegistry = new ConfigTypeRegistry(this, main, (id, configType) -> {
|
||||
OpenRegistry<?> openRegistry = configType.registrySupplier().get();
|
||||
registryMap.put(configType.getTypeClass(), ImmutablePair.of(openRegistry, new CheckedRegistry<>(openRegistry)));
|
||||
registryMap.put(configType.getTypeClass(), ImmutablePair.of(openRegistry, new CheckedRegistryImpl<>(openRegistry)));
|
||||
});
|
||||
this.loader = new ZIPLoader(file);
|
||||
this.main = main;
|
||||
@@ -191,18 +194,18 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
|
||||
putPair(map, NoiseProvider.class, new NoiseRegistry());
|
||||
putPair(map, FunctionBuilder.class, (OpenRegistry<FunctionBuilder>) (Object) new FunctionRegistry());
|
||||
putPair(map, LootTableImpl.class, new LootRegistry());
|
||||
putPair(map, StructureScript.class, new ScriptRegistry());
|
||||
putPair(map, LootTable.class, new LootRegistry());
|
||||
putPair(map, Structure.class, new ScriptRegistry());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
private <R> void putPair(Map<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> map, Class<R> key, OpenRegistry<R> l) {
|
||||
map.put(key, ImmutablePair.of(l, new CheckedRegistry<>(l)));
|
||||
map.put(key, ImmutablePair.of(l, new CheckedRegistryImpl<>(l)));
|
||||
}
|
||||
|
||||
private void checkDeadEntries(TerraPlugin main) {
|
||||
registryMap.forEach((clazz, pair) -> pair.getLeft().getDeadEntries().forEach((id, value) -> main.getDebugLogger().warn("Dead entry in '" + clazz + "' registry: '" + id + "'")));
|
||||
registryMap.forEach((clazz, pair) -> ((OpenRegistryImpl<?>) pair.getLeft()).getDeadEntries().forEach((id, value) -> main.getDebugLogger().warning("Dead entry in '" + clazz + "' registry: '" + id + "'")));
|
||||
}
|
||||
|
||||
protected Map<Class<?>, ImmutablePair<OpenRegistry<?>, CheckedRegistry<?>>> getRegistryMap() {
|
||||
@@ -218,8 +221,8 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
loader.open("", ".tesf").thenEntries(entries -> {
|
||||
for(Map.Entry<String, InputStream> entry : entries) {
|
||||
try(InputStream stream = entry.getValue()) {
|
||||
Structure structure = new StructureScript(stream, main, getRegistry(StructureScript.class), getRegistry(LootTableImpl.class), (Registry<FunctionBuilder<?>>) (Object) getRegistry(FunctionBuilder.class));
|
||||
getOpenRegistry(StructureScript.class).add(structure.getId(), structure);
|
||||
Structure structure = new StructureScript(stream, main, getRegistry(Structure.class), getRegistry(LootTable.class), (Registry<FunctionBuilder<?>>) (Object) getRegistry(FunctionBuilder.class));
|
||||
getOpenRegistry(Structure.class).add(structure.getId(), structure);
|
||||
} catch(com.dfsek.terra.api.structures.parser.exceptions.ParseException | IOException e) {
|
||||
throw new LoadException("Unable to load script \"" + entry.getKey() + "\"", e);
|
||||
}
|
||||
@@ -306,7 +309,7 @@ public class ConfigPackImpl implements ConfigPack {
|
||||
|
||||
@Override
|
||||
public CheckedRegistry<ConfigType<?, ?>> getConfigTypeRegistry() {
|
||||
return new CheckedRegistry<ConfigType<?, ?>>(configTypeRegistry) {
|
||||
return new CheckedRegistryImpl<>(configTypeRegistry) {
|
||||
@Override
|
||||
@SuppressWarnings("deprecation")
|
||||
public void addUnchecked(String identifier, ConfigType<?, ?> value) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.config.pack;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.registry.Registry;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
@@ -18,7 +19,7 @@ import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class WorldConfigImpl implements com.dfsek.terra.api.config.WorldConfig {
|
||||
public class WorldConfigImpl implements WorldConfig {
|
||||
private final SamplerCache samplerCache;
|
||||
|
||||
private final BiomeProvider provider;
|
||||
@@ -63,6 +64,36 @@ public class WorldConfigImpl implements com.dfsek.terra.api.config.WorldConfig {
|
||||
return provider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int elevationBlend() {
|
||||
return pack.getTemplate().getElevationBlend();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableTrees() {
|
||||
return pack.getTemplate().disableTrees();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableCarving() {
|
||||
return pack.getTemplate().disableCarvers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableOres() {
|
||||
return pack.getTemplate().disableOres();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableFlora() {
|
||||
return pack.getTemplate().disableFlora();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disableStructures() {
|
||||
return pack.getTemplate().disableStructures();
|
||||
}
|
||||
|
||||
public Set<TerraStructure> getStructures() {
|
||||
return new HashSet<>(getRegistry(TerraStructure.class).entries());
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ import com.dfsek.terra.api.noise.NoiseSampler;
|
||||
import com.dfsek.terra.noise.samplers.noise.simplex.OpenSimplex2Sampler;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.vector.Vector2Impl;
|
||||
import com.dfsek.terra.vector.Vector3Impl;
|
||||
|
||||
/**
|
||||
* NoiseSampler implementation for Cellular (Voronoi/Worley) Noise.
|
||||
@@ -229,7 +231,7 @@ public class CellularSampler extends NoiseFunction {
|
||||
int xPrimed = (xr - 1) * PRIME_X;
|
||||
int yPrimedBase = (yr - 1) * PRIME_Y;
|
||||
|
||||
Vector2 center = new Vector2(x, y);
|
||||
Vector2 center = new Vector2Impl(x, y);
|
||||
|
||||
switch(distanceFunction) {
|
||||
default:
|
||||
@@ -382,7 +384,7 @@ public class CellularSampler extends NoiseFunction {
|
||||
int yPrimedBase = (yr - 1) * PRIME_Y;
|
||||
int zPrimedBase = (zr - 1) * PRIME_Z;
|
||||
|
||||
Vector3 center = new Vector3(x, y, z);
|
||||
Vector3 center = new Vector3Impl(x, y, z);
|
||||
|
||||
switch(distanceFunction) {
|
||||
case Euclidean:
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.terra.api.registry.CheckedRegistry;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.registry.DuplicateEntryException;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.dfsek.terra.api.config.ConfigPack;
|
||||
import com.dfsek.terra.api.registry.OpenRegistry;
|
||||
import com.dfsek.terra.api.world.Tree;
|
||||
import com.dfsek.terra.api.world.Flora;
|
||||
import com.dfsek.terra.api.world.generator.Palette;
|
||||
import com.dfsek.terra.api.world.palette.PaletteImpl;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.builder.BiomeBuilder;
|
||||
@@ -42,7 +43,7 @@ public class ConfigTypeRegistry extends OpenRegistryImpl<ConfigType<?, ?>> {
|
||||
public ConfigTypeRegistry(ConfigPackImpl pack, TerraPlugin main, BiConsumer<String, ConfigType<?, ?>> callback) {
|
||||
super(new LinkedHashMap<>()); // Ordered
|
||||
this.callback = callback;
|
||||
add("PALETTE", new ConfigBuilder<>(new PaletteFactory(), PaletteTemplate::new, PaletteImpl.class, () -> new PaletteRegistry(main)));
|
||||
add("PALETTE", new ConfigBuilder<>(new PaletteFactory(), PaletteTemplate::new, Palette.class, () -> new PaletteRegistry(main)));
|
||||
add("ORE", new ConfigBuilder<>(new OreFactory(), OreTemplate::new, Ore.class, OreRegistry::new));
|
||||
add("FLORA", new ConfigBuilder<>(new FloraFactory(), FloraTemplate::new, Flora.class, () -> new FloraRegistry(main)));
|
||||
add("CARVER", new ConfigBuilder<>(new CarverFactory(pack), CarverTemplate::new, UserDefinedCarver.class, CarverRegistry::new));
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.registry.master;
|
||||
import com.dfsek.tectonic.exception.ConfigException;
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.config.pack.ConfigPackImpl;
|
||||
import com.dfsek.terra.registry.OpenRegistry;
|
||||
import com.dfsek.terra.registry.OpenRegistryImpl;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -12,7 +12,7 @@ import java.util.zip.ZipFile;
|
||||
/**
|
||||
* Class to hold config packs
|
||||
*/
|
||||
public class ConfigRegistry extends OpenRegistry<ConfigPackImpl> {
|
||||
public class ConfigRegistry extends OpenRegistryImpl<ConfigPackImpl> {
|
||||
public void load(File folder, TerraPlugin main) throws ConfigException {
|
||||
ConfigPackImpl pack = new ConfigPackImpl(folder, main);
|
||||
add(pack.getTemplate().getID(), pack);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.vector;
|
||||
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
@@ -52,16 +52,16 @@ public class Vector2Impl implements Vector2 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2 add(Vector2Impl other) {
|
||||
x += other.x;
|
||||
z += other.z;
|
||||
public Vector2 add(Vector2 other) {
|
||||
x += other.getX();
|
||||
z += other.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2 subtract(Vector2Impl other) {
|
||||
x -= other.x;
|
||||
z -= other.z;
|
||||
public Vector2 subtract(Vector2 other) {
|
||||
x -= other.getX();
|
||||
z -= other.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -89,14 +89,14 @@ public class Vector2Impl implements Vector2 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double distance(Vector2Impl other) {
|
||||
public double distance(Vector2 other) {
|
||||
return FastMath.sqrt(distanceSquared(other));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double distanceSquared(Vector2Impl other) {
|
||||
double dx = other.x - x;
|
||||
double dz = other.z - z;
|
||||
public double distanceSquared(Vector2 other) {
|
||||
double dx = other.getX() - x;
|
||||
double dz = other.getZ() - z;
|
||||
return dx * dx + dz * dz;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.vector;
|
||||
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.util.MathUtil;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.world.World;
|
||||
import com.dfsek.terra.api.vector.Vector2;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
@@ -163,13 +164,13 @@ public class Vector3Impl implements Vector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double distance(@NotNull Vector3Impl o) {
|
||||
return FastMath.sqrt(FastMath.pow2(x - o.x) + FastMath.pow2(y - o.y) + FastMath.pow2(z - o.z));
|
||||
public double distance(@NotNull Vector3 o) {
|
||||
return FastMath.sqrt(FastMath.pow2(x - o.getX()) + FastMath.pow2(y - o.getY()) + FastMath.pow2(z - o.getZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double distanceSquared(@NotNull Vector3Impl o) {
|
||||
return FastMath.pow2(x - o.x) + FastMath.pow2(y - o.y) + FastMath.pow2(z - o.z);
|
||||
public double distanceSquared(@NotNull Vector3 o) {
|
||||
return FastMath.pow2(x - o.getX()) + FastMath.pow2(y - o.getY()) + FastMath.pow2(z - o.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,7 +181,7 @@ public class Vector3Impl implements Vector3 {
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public Vector3 rotateAroundNonUnitAxis(@NotNull Vector3Impl axis, double angle) throws IllegalArgumentException {
|
||||
public Vector3 rotateAroundNonUnitAxis(@NotNull Vector3 axis, double angle) throws IllegalArgumentException {
|
||||
double x = getX(), y = getY(), z = getZ();
|
||||
double x2 = axis.getX(), y2 = axis.getY(), z2 = axis.getZ();
|
||||
|
||||
@@ -202,12 +203,12 @@ public class Vector3Impl implements Vector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double dot(@NotNull Vector3Impl other) {
|
||||
return x * other.x + y * other.y + z * other.z;
|
||||
public double dot(@NotNull Vector3 other) {
|
||||
return x * other.getX() + y * other.getY() + z * other.getZ();
|
||||
}
|
||||
|
||||
@Override
|
||||
public LocationImpl toLocation(World world) {
|
||||
public Location toLocation(World world) {
|
||||
return new LocationImpl(world, this.clone());
|
||||
}
|
||||
|
||||
@@ -225,10 +226,10 @@ public class Vector3Impl implements Vector3 {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector3 subtract(Vector3Impl end) {
|
||||
x -= end.x;
|
||||
y -= end.y;
|
||||
z -= end.z;
|
||||
public Vector3 subtract(Vector3 end) {
|
||||
x -= end.getX();
|
||||
y -= end.getY();
|
||||
z -= end.getZ();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@ package com.dfsek.terra.world;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.event.events.world.TerraWorldLoadEvent;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.api.world.TerraWorld;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.vector.Vector3;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
@@ -14,7 +16,7 @@ import com.dfsek.terra.config.pack.WorldConfigImpl;
|
||||
import com.dfsek.terra.api.world.generator.Sampler;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
public class TerraWorldImpl implements com.dfsek.terra.api.world.TerraWorld {
|
||||
public class TerraWorldImpl implements TerraWorld {
|
||||
private final BiomeProvider provider;
|
||||
private final WorldConfigImpl config;
|
||||
private final boolean safe;
|
||||
@@ -76,7 +78,7 @@ public class TerraWorldImpl implements com.dfsek.terra.api.world.TerraWorld {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockData getUngeneratedBlock(LocationImpl l) {
|
||||
public BlockData getUngeneratedBlock(Location l) {
|
||||
return getUngeneratedBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
|
||||
@@ -54,31 +54,6 @@ public class DefaultChunkGenerator2D implements TerraChunkGenerator {
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParallelCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateCaves() {
|
||||
return configPack.getTemplate().vanillaCaves();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateDecorations() {
|
||||
return configPack.getTemplate().vanillaDecorations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateMobs() {
|
||||
return configPack.getTemplate().vanillaMobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateStructures() {
|
||||
return configPack.getTemplate().vanillaStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPackImpl getConfigPack() {
|
||||
return configPack;
|
||||
|
||||
@@ -66,31 +66,6 @@ public class DefaultChunkGenerator3D implements TerraChunkGenerator {
|
||||
blank = new PaletteImpl.Singleton(main.getWorldHandle().createBlockData("minecraft:air"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParallelCapable() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateCaves() {
|
||||
return configPack.getTemplate().vanillaCaves();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateDecorations() {
|
||||
return configPack.getTemplate().vanillaDecorations();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateMobs() {
|
||||
return configPack.getTemplate().vanillaMobs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldGenerateStructures() {
|
||||
return configPack.getTemplate().vanillaStructures();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigPackImpl getConfigPack() {
|
||||
return configPack;
|
||||
|
||||
@@ -20,7 +20,7 @@ public class SamplerCacheImpl implements com.dfsek.terra.api.world.generator.Sam
|
||||
public Sampler load(@NotNull Long key) {
|
||||
int cx = (int) (key >> 32);
|
||||
int cz = (int) key.longValue();
|
||||
return world.getWorld().getTerraGenerator().createSampler(cx, cz, world.getBiomeProvider(), world.getWorld(), world.getConfig().getTemplate().getElevationBlend());
|
||||
return world.getWorld().getTerraGenerator().createSampler(cx, cz, world.getBiomeProvider(), world.getWorld(), world.getConfig().elevationBlend());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.dfsek.terra.world.population;
|
||||
|
||||
import com.dfsek.terra.api.TerraPlugin;
|
||||
import com.dfsek.terra.api.config.WorldConfig;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
@@ -41,12 +43,12 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("carving")) {
|
||||
Random random = PopulationUtil.getRandom(chunk);
|
||||
if(!tw.isSafe()) return;
|
||||
WorldConfigImpl config = tw.getConfig();
|
||||
if(config.getTemplate().disableCarvers()) return;
|
||||
WorldConfig config = tw.getConfig();
|
||||
if(config.disableCarving()) return;
|
||||
|
||||
for(UserDefinedCarver c : config.getCarvers()) {
|
||||
for(UserDefinedCarver c : config.getRegistry(UserDefinedCarver.class).entries()) {
|
||||
CarverTemplate template = c.getConfig();
|
||||
Map<LocationImpl, BlockData> shiftCandidate = new HashMap<>();
|
||||
Map<Location, BlockData> shiftCandidate = new HashMap<>();
|
||||
Set<Block> updateNeeded = new HashSet<>();
|
||||
c.carve(chunk.getX(), chunk.getZ(), world, (v, type) -> {
|
||||
try(ProfileFrame ignored = main.getProfiler().profile("carving:" + c.getConfig().getID())) {
|
||||
@@ -85,9 +87,9 @@ public class CavePopulator implements TerraBlockPopulator, Chunkified {
|
||||
}
|
||||
}
|
||||
});
|
||||
for(Map.Entry<LocationImpl, BlockData> entry : shiftCandidate.entrySet()) {
|
||||
LocationImpl l = entry.getKey();
|
||||
LocationImpl mut = l.clone();
|
||||
for(Map.Entry<Location, BlockData> entry : shiftCandidate.entrySet()) {
|
||||
Location l = entry.getKey();
|
||||
Location mut = l.clone();
|
||||
BlockData orig = l.getBlock().getBlockData();
|
||||
do mut.subtract(0, 1, 0);
|
||||
while(mut.getY() > world.getMinHeight() && mut.getBlock().getBlockData().matches(orig));
|
||||
|
||||
@@ -34,7 +34,7 @@ public class FloraPopulator implements TerraBlockPopulator {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("flora")) {
|
||||
if(tw.getConfig().getTemplate().disableFlora()) return;
|
||||
if(tw.getConfig().disableFlora()) return;
|
||||
|
||||
if(!tw.isSafe()) return;
|
||||
BiomeProvider provider = tw.getBiomeProvider();
|
||||
|
||||
@@ -33,7 +33,7 @@ public class TreePopulator implements TerraBlockPopulator {
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
try(ProfileFrame ignore = main.getProfiler().profile("tree")) {
|
||||
if(tw.getConfig().getTemplate().disableTrees()) return;
|
||||
if(tw.getConfig().disableTrees()) return;
|
||||
|
||||
if(!tw.isSafe()) return;
|
||||
BiomeProvider provider = tw.getBiomeProvider();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.dfsek.terra.world.population.items.flora;
|
||||
|
||||
import com.dfsek.terra.api.util.Range;
|
||||
import com.dfsek.terra.api.vector.Location;
|
||||
import com.dfsek.terra.vector.LocationImpl;
|
||||
import com.dfsek.terra.api.block.Block;
|
||||
import com.dfsek.terra.api.block.BlockData;
|
||||
@@ -43,7 +44,7 @@ public class ConstantFlora implements Flora {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plant(LocationImpl l) {
|
||||
public boolean plant(Location l) {
|
||||
for(int i = 1; i < data.size() + 1; i++) {
|
||||
l.clone().add(0, i, 0).getBlock().setBlockData(data.get(i - 1), false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user