mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-02-16 10:30:42 +00:00
refactor API
This commit is contained in:
@@ -1,18 +0,0 @@
|
||||
package com.dfsek.terra;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.profiler.DataType;
|
||||
import com.dfsek.terra.api.profiler.Measurement;
|
||||
import com.dfsek.terra.api.profiler.WorldProfiler;
|
||||
|
||||
public class TerraProfiler extends WorldProfiler {
|
||||
public TerraProfiler(World w) {
|
||||
super(w);
|
||||
this
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "FloraTime")
|
||||
.addMeasurement(new Measurement(10000000, DataType.PERIOD_MILLISECONDS), "TreeTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "OreTime")
|
||||
.addMeasurement(new Measurement(5000000, DataType.PERIOD_MILLISECONDS), "CaveTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "StructureTime");
|
||||
}
|
||||
}
|
||||
@@ -4,27 +4,28 @@ import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.palette.Palette;
|
||||
import com.dfsek.terra.biome.BiomeProvider;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.generation.math.Sampler;
|
||||
import com.dfsek.terra.profiler.WorldProfiler;
|
||||
import net.jafama.FastMath;
|
||||
|
||||
public class TerraWorld {
|
||||
private final BiomeProvider provider;
|
||||
private final ConfigPack config;
|
||||
private final boolean safe;
|
||||
private final TerraProfiler profiler;
|
||||
private final WorldProfiler profiler;
|
||||
private final World world;
|
||||
private final BlockData air;
|
||||
|
||||
|
||||
public TerraWorld(World w, ConfigPack c, TerraPlugin main) {
|
||||
config = c;
|
||||
profiler = new TerraProfiler(w);
|
||||
profiler = new WorldProfiler(w);
|
||||
this.provider = config.getTemplate().getProviderBuilder().build(w.getSeed());
|
||||
this.world = w;
|
||||
air = main.getWorldHandle().createBlockData("minecraft:air");
|
||||
@@ -51,7 +52,7 @@ public class TerraWorld {
|
||||
return safe;
|
||||
}
|
||||
|
||||
public TerraProfiler getProfiler() {
|
||||
public WorldProfiler getProfiler() {
|
||||
return profiler;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.dfsek.terra.api.math.noise.samplers.Normalizer;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.biome.palette.PaletteHolder;
|
||||
import com.dfsek.terra.biome.palette.PaletteLayer;
|
||||
import com.dfsek.terra.carving.CarverPalette;
|
||||
import com.dfsek.terra.config.loaders.MaterialSetLoader;
|
||||
import com.dfsek.terra.config.loaders.ProbabilityCollectionLoader;
|
||||
import com.dfsek.terra.config.loaders.RangeLoader;
|
||||
@@ -18,7 +17,6 @@ import com.dfsek.terra.config.loaders.config.NoiseBuilderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.OreConfigLoader;
|
||||
import com.dfsek.terra.config.loaders.config.OreHolderLoader;
|
||||
import com.dfsek.terra.config.loaders.config.TreeLayerLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.CarverPaletteLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.PaletteHolderLoader;
|
||||
import com.dfsek.terra.config.loaders.palette.PaletteLayerLoader;
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
@@ -41,7 +39,6 @@ public class GenericLoaders implements LoaderRegistrar {
|
||||
public void register(TypeRegistry registry) {
|
||||
registry.registerLoader(ProbabilityCollection.class, new ProbabilityCollectionLoader())
|
||||
.registerLoader(Range.class, new RangeLoader())
|
||||
.registerLoader(CarverPalette.class, new CarverPaletteLoader())
|
||||
.registerLoader(GridSpawn.class, new GridSpawnLoader())
|
||||
.registerLoader(PaletteHolder.class, new PaletteHolderLoader())
|
||||
.registerLoader(PaletteLayer.class, new PaletteLayerLoader())
|
||||
|
||||
@@ -4,5 +4,10 @@ package com.dfsek.terra.api.platform;
|
||||
* An interface that contains a platform delegate.
|
||||
*/
|
||||
public interface Handle {
|
||||
/**
|
||||
* Gets the delegate object.
|
||||
*
|
||||
* @return Delegate
|
||||
*/
|
||||
Object getHandle();
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.dfsek.terra.api.language.Language;
|
||||
import com.dfsek.terra.api.platform.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.base.PluginConfig;
|
||||
import com.dfsek.terra.registry.ConfigRegistry;
|
||||
|
||||
@@ -38,4 +39,12 @@ public interface TerraPlugin extends LoaderRegistrar {
|
||||
void saveDefaultConfig();
|
||||
|
||||
String platformName();
|
||||
|
||||
default void packPreLoadCallback(ConfigPack pack) {
|
||||
|
||||
}
|
||||
|
||||
default void packPostLoadCallback(ConfigPack pack) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.api.platform.block.state;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public interface MobSpawner extends BlockState {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.platform.world.entity;
|
||||
package com.dfsek.terra.api.platform.entity;
|
||||
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.platform.world.entity;
|
||||
package com.dfsek.terra.api.platform.entity;
|
||||
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.dfsek.terra.api.platform.handle;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
|
||||
/**
|
||||
* Interface to be implemented for world manipulation.
|
||||
@@ -20,7 +19,5 @@ public interface WorldHandle {
|
||||
|
||||
MaterialData createMaterialData(String data);
|
||||
|
||||
Tree getTree(String id);
|
||||
|
||||
EntityType getEntity(String id);
|
||||
}
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package com.dfsek.terra.api.platform.world;
|
||||
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
|
||||
public interface Chunk extends Handle {
|
||||
public interface Chunk extends ChunkAccess {
|
||||
int getX();
|
||||
|
||||
int getZ();
|
||||
|
||||
@@ -2,5 +2,5 @@ package com.dfsek.terra.api.platform.world;
|
||||
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
|
||||
public interface Tree extends Handle, com.dfsek.terra.api.world.tree.Tree {
|
||||
public interface ChunkAccess extends Handle {
|
||||
}
|
||||
@@ -3,9 +3,9 @@ package com.dfsek.terra.api.platform.world;
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.UUID;
|
||||
@@ -31,7 +31,5 @@ public interface World extends Handle {
|
||||
|
||||
Block getBlockAt(Location l);
|
||||
|
||||
boolean generateTree(Location l, Tree vanillaTreeType);
|
||||
|
||||
Entity spawnEntity(Location location, EntityType entityType);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.platform.generator;
|
||||
package com.dfsek.terra.api.platform.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
@@ -1,8 +1,9 @@
|
||||
package com.dfsek.terra.api.platform.generator;
|
||||
package com.dfsek.terra.api.platform.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.platform.world.ChunkAccess;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -30,7 +31,7 @@ public interface ChunkGenerator extends Handle {
|
||||
@Nullable
|
||||
TerraChunkGenerator getTerraGenerator();
|
||||
|
||||
interface ChunkData extends Handle {
|
||||
interface ChunkData extends ChunkAccess {
|
||||
/**
|
||||
* Get the maximum height for the chunk.
|
||||
* <p>
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.platform.generator;
|
||||
package com.dfsek.terra.api.platform.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.Handle;
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.dfsek.terra.api.structures.script.functions;
|
||||
import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.structures.parser.exceptions.ParseException;
|
||||
import com.dfsek.terra.api.structures.parser.lang.ImplementationArguments;
|
||||
import com.dfsek.terra.api.structures.parser.lang.Returnable;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.structures.structure.buffer.items;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
|
||||
public class BufferedEntity implements BufferedItem {
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.api.world.generation;
|
||||
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -4,12 +4,12 @@ import com.dfsek.terra.api.Gaea;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
import com.dfsek.terra.api.util.SerializationUtil;
|
||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.profiler.WorldProfiler;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.api.world.tree.fractal;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.dfsek.terra.api.world.tree.fractal;
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
4
common/src/main/java/com/dfsek/terra/carving/Carver.java
Normal file
4
common/src/main/java/com/dfsek/terra/carving/Carver.java
Normal file
@@ -0,0 +1,4 @@
|
||||
package com.dfsek.terra.carving;
|
||||
|
||||
public interface Carver {
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
package com.dfsek.terra.carving;
|
||||
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.carving.Worm;
|
||||
import com.dfsek.terra.biome.BiomeProvider;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class CarverCache {
|
||||
|
||||
private final LoadingCache<Long, List<Worm.WormPoint>> cache;
|
||||
private final UserDefinedCarver carver;
|
||||
|
||||
public CarverCache(World w, TerraPlugin main, UserDefinedCarver carver) {
|
||||
this.carver = carver;
|
||||
cache = CacheBuilder.newBuilder().maximumSize(main.getTerraConfig().getCarverCacheSize())
|
||||
.build(new CacheLoader<Long, List<Worm.WormPoint>>() {
|
||||
@Override
|
||||
public List<Worm.WormPoint> load(@NotNull Long key) {
|
||||
int chunkX = (int) (key >> 32);
|
||||
int chunkZ = (int) key.longValue();
|
||||
BiomeProvider provider = main.getWorld(w).getBiomeProvider();
|
||||
if(CarverCache.this.carver.isChunkCarved(w, chunkX, chunkZ, new FastRandom(MathUtil.getCarverChunkSeed(chunkX, chunkZ, w.getSeed() + CarverCache.this.carver.hashCode())))) {
|
||||
long seed = MathUtil.getCarverChunkSeed(chunkX, chunkZ, w.getSeed());
|
||||
CarverCache.this.carver.getSeedVar().setValue(seed);
|
||||
Random r = new FastRandom(seed);
|
||||
Worm carving = CarverCache.this.carver.getWorm(seed, new Vector3((chunkX << 4) + r.nextInt(16), CarverCache.this.carver.getConfig().getHeight().get(r), (chunkZ << 4) + r.nextInt(16)));
|
||||
List<Worm.WormPoint> points = new GlueList<>();
|
||||
for(int i = 0; i < carving.getLength(); i++) {
|
||||
carving.step();
|
||||
TerraBiome biome = provider.getBiome(carving.getRunning().toLocation(w));
|
||||
if(!((UserDefinedBiome) biome).getConfig().getCarvers().containsKey(CarverCache.this.carver)) { // Stop if we enter a biome this carver is not present in
|
||||
return new GlueList<>();
|
||||
}
|
||||
points.add(carving.getPoint());
|
||||
}
|
||||
return points;
|
||||
}
|
||||
return new GlueList<>();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public List<Worm.WormPoint> getPoints(int chunkX, int chunkZ) {
|
||||
return cache.getUnchecked(MathUtil.squash(chunkX, chunkZ));
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
package com.dfsek.terra.carving;
|
||||
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
@SuppressWarnings({"unchecked", "rawtypes", "RedundantSuppression"})
|
||||
public class CarverPalette {
|
||||
private final boolean blacklist;
|
||||
private final MaterialSet replace;
|
||||
private final TreeMap<Integer, ProbabilityCollection<BlockData>> map = new TreeMap<>();
|
||||
private ProbabilityCollection<BlockData>[] layers;
|
||||
|
||||
public CarverPalette(MaterialSet replaceable, boolean blacklist) {
|
||||
this.blacklist = blacklist;
|
||||
this.replace = replaceable;
|
||||
}
|
||||
|
||||
public CarverPalette add(ProbabilityCollection<BlockData> collection, int y) {
|
||||
map.put(y, collection);
|
||||
return this;
|
||||
}
|
||||
|
||||
public ProbabilityCollection<BlockData> get(int y) {
|
||||
return layers[y];
|
||||
}
|
||||
|
||||
public boolean canReplace(MaterialData material) {
|
||||
return blacklist != replace.contains(material);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the palette to an array.
|
||||
*/
|
||||
public void build() {
|
||||
int size = map.lastKey() + 1;
|
||||
layers = new ProbabilityCollection[size];
|
||||
for(int y = 0; y < size; y++) {
|
||||
ProbabilityCollection<BlockData> d = null;
|
||||
for(Map.Entry<Integer, ProbabilityCollection<BlockData>> e : map.entrySet()) {
|
||||
if(e.getKey() >= y) {
|
||||
d = e.getValue();
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(d == null) throw new IllegalArgumentException("Null collection at Y=" + y);
|
||||
layers[y] = d;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,179 +0,0 @@
|
||||
package com.dfsek.terra.carving;
|
||||
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.math.parsii.RandomFunction;
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.world.carving.Carver;
|
||||
import com.dfsek.terra.api.world.carving.Worm;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
import net.jafama.FastMath;
|
||||
import parsii.eval.Expression;
|
||||
import parsii.eval.Parser;
|
||||
import parsii.eval.Scope;
|
||||
import parsii.eval.Variable;
|
||||
import parsii.tokenizer.ParseException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class UserDefinedCarver extends Carver {
|
||||
private final double[] start; // 0, 1, 2 = x, y, z.
|
||||
private final double[] mutate; // 0, 1, 2 = x, y, z. 3 = radius.
|
||||
private final Range length;
|
||||
private final long hash;
|
||||
private final int topCut;
|
||||
private final int bottomCut;
|
||||
private final CarverTemplate config;
|
||||
private final Expression xRad;
|
||||
private final Expression yRad;
|
||||
private final Expression zRad;
|
||||
private final Variable lengthVar;
|
||||
private final Variable position;
|
||||
private final Variable seedVar;
|
||||
private final Map<World, CarverCache> cacheMap = new ConcurrentHashMap<>();
|
||||
private double step = 2;
|
||||
private Range recalc = new Range(8, 10);
|
||||
private double recalcMagnitude = 3;
|
||||
private final TerraPlugin main;
|
||||
|
||||
public UserDefinedCarver(Range height, Range length, double[] start, double[] mutate, List<String> radii, Scope parent, long hash, int topCut, int bottomCut, CarverTemplate config, TerraPlugin main) throws ParseException {
|
||||
super(height.getMin(), height.getMax());
|
||||
this.length = length;
|
||||
this.start = start;
|
||||
this.mutate = mutate;
|
||||
this.hash = hash;
|
||||
this.topCut = topCut;
|
||||
this.bottomCut = bottomCut;
|
||||
this.config = config;
|
||||
this.main = main;
|
||||
|
||||
Parser p = new Parser();
|
||||
|
||||
p.registerFunction("rand", new RandomFunction());
|
||||
|
||||
Scope s = new Scope().withParent(parent);
|
||||
|
||||
lengthVar = s.create("length");
|
||||
position = s.create("position");
|
||||
seedVar = s.create("seed");
|
||||
|
||||
|
||||
xRad = p.parse(radii.get(0), s);
|
||||
yRad = p.parse(radii.get(1), s);
|
||||
zRad = p.parse(radii.get(2), s);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worm getWorm(long l, Vector3 vector) {
|
||||
Random r = new FastRandom(l + hash);
|
||||
return new UserDefinedWorm(length.get(r) / 2, r, vector, topCut, bottomCut);
|
||||
}
|
||||
|
||||
protected Variable getSeedVar() {
|
||||
return seedVar;
|
||||
}
|
||||
|
||||
protected Variable getLengthVar() {
|
||||
return lengthVar;
|
||||
}
|
||||
|
||||
protected Variable getPosition() {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setStep(double step) {
|
||||
this.step = step;
|
||||
}
|
||||
|
||||
public void setRecalc(Range recalc) {
|
||||
this.recalc = recalc;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void carve(int chunkX, int chunkZ, World w, BiConsumer<Vector3, CarvingType> consumer) {
|
||||
synchronized(cacheMap) {
|
||||
CarverCache cache = cacheMap.computeIfAbsent(w, world -> new CarverCache(world, main, this));
|
||||
if(cacheMap.size() > 1) Debug.info("Map size: " + cacheMap.size());
|
||||
int carvingRadius = getCarvingRadius();
|
||||
for(int x = chunkX - carvingRadius; x <= chunkX + carvingRadius; x++) {
|
||||
for(int z = chunkZ - carvingRadius; z <= chunkZ + carvingRadius; z++) {
|
||||
cache.getPoints(x, z).forEach(point -> {
|
||||
Vector3 origin = point.getOrigin();
|
||||
if(FastMath.floorDiv(origin.getBlockX(), 16) != chunkX && FastMath.floorDiv(origin.getBlockZ(), 16) != chunkZ) // We only want to carve this chunk.
|
||||
return;
|
||||
point.carve(chunkX, chunkZ, consumer);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setRecalcMagnitude(double recalcMagnitude) {
|
||||
this.recalcMagnitude = recalcMagnitude;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunkCarved(World w, int chunkX, int chunkZ, Random random) {
|
||||
BiomeTemplate conf = ((UserDefinedBiome) main.getWorld(w).getBiomeProvider().getBiome((chunkX << 4) + 8, (chunkZ << 4) + 8)).getConfig();
|
||||
if(conf.getCarvers().get(this) != null) {
|
||||
return new FastRandom(random.nextLong() + hash).nextInt(100) < conf.getCarvers().get(this);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public CarverTemplate getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
private class UserDefinedWorm extends Worm {
|
||||
private final Vector3 direction;
|
||||
private int steps;
|
||||
private int nextDirection = 0;
|
||||
private double[] currentRotation = new double[3];
|
||||
|
||||
public UserDefinedWorm(int length, Random r, Vector3 origin, int topCut, int bottomCut) {
|
||||
super(length, r, origin);
|
||||
super.setTopCut(topCut);
|
||||
super.setBottomCut(bottomCut);
|
||||
direction = new Vector3((r.nextDouble() - 0.5D) * start[0], (r.nextDouble() - 0.5D) * start[1], (r.nextDouble() - 0.5D) * start[2]).normalize().multiply(step);
|
||||
position.setValue(0);
|
||||
lengthVar.setValue(length);
|
||||
setRadius(new int[] {(int) (xRad.evaluate()), (int) (yRad.evaluate()), (int) (zRad.evaluate())});
|
||||
}
|
||||
|
||||
@Override
|
||||
public WormPoint getPoint() {
|
||||
return new WormPoint(getRunning().clone(), getRadius(), config.getCutTop(), config.getCutBottom());
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void step() {
|
||||
if(steps == nextDirection) {
|
||||
direction.rotateAroundX(FastMath.toRadians((getRandom().nextGaussian()) * mutate[0] * recalcMagnitude));
|
||||
direction.rotateAroundY(FastMath.toRadians((getRandom().nextGaussian()) * mutate[1] * recalcMagnitude));
|
||||
direction.rotateAroundZ(FastMath.toRadians((getRandom().nextGaussian()) * mutate[2] * recalcMagnitude));
|
||||
currentRotation = new double[] {(getRandom().nextGaussian()) * mutate[0],
|
||||
(getRandom().nextGaussian()) * mutate[1],
|
||||
(getRandom().nextGaussian()) * mutate[2]};
|
||||
nextDirection += recalc.get(getRandom());
|
||||
}
|
||||
steps++;
|
||||
position.setValue(steps);
|
||||
setRadius(new int[] {(int) (xRad.evaluate()), (int) (yRad.evaluate()), (int) (zRad.evaluate())});
|
||||
direction.rotateAroundX(FastMath.toRadians(currentRotation[0] * mutate[0]));
|
||||
direction.rotateAroundY(FastMath.toRadians(currentRotation[1] * mutate[1]));
|
||||
direction.rotateAroundZ(FastMath.toRadians(currentRotation[2] * mutate[2]));
|
||||
getRunning().add(direction);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,10 +14,8 @@ import com.dfsek.terra.api.world.flora.Flora;
|
||||
import com.dfsek.terra.api.world.palette.Palette;
|
||||
import com.dfsek.terra.api.world.tree.Tree;
|
||||
import com.dfsek.terra.biome.BiomeProvider;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.exception.FileMissingException;
|
||||
import com.dfsek.terra.config.factories.BiomeFactory;
|
||||
import com.dfsek.terra.config.factories.CarverFactory;
|
||||
import com.dfsek.terra.config.factories.FloraFactory;
|
||||
import com.dfsek.terra.config.factories.OreFactory;
|
||||
import com.dfsek.terra.config.factories.PaletteFactory;
|
||||
@@ -31,7 +29,6 @@ import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.config.loaders.config.biome.BiomeProviderBuilderLoader;
|
||||
import com.dfsek.terra.config.templates.AbstractableTemplate;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
import com.dfsek.terra.config.templates.FloraTemplate;
|
||||
import com.dfsek.terra.config.templates.OreTemplate;
|
||||
import com.dfsek.terra.config.templates.PaletteTemplate;
|
||||
@@ -41,7 +38,6 @@ import com.dfsek.terra.generation.math.SamplerCache;
|
||||
import com.dfsek.terra.population.items.TerraStructure;
|
||||
import com.dfsek.terra.population.items.ores.Ore;
|
||||
import com.dfsek.terra.registry.BiomeRegistry;
|
||||
import com.dfsek.terra.registry.CarverRegistry;
|
||||
import com.dfsek.terra.registry.FloraRegistry;
|
||||
import com.dfsek.terra.registry.LootRegistry;
|
||||
import com.dfsek.terra.registry.OreRegistry;
|
||||
@@ -60,7 +56,6 @@ import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -78,7 +73,6 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
|
||||
private final BiomeRegistry biomeRegistry = new BiomeRegistry();
|
||||
private final StructureRegistry structureRegistry = new StructureRegistry();
|
||||
private final CarverRegistry carverRegistry = new CarverRegistry();
|
||||
private final PaletteRegistry paletteRegistry;
|
||||
private final FloraRegistry floraRegistry;
|
||||
private final OreRegistry oreRegistry = new OreRegistry();
|
||||
@@ -156,6 +150,7 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
}
|
||||
|
||||
private void load(long start, TerraPlugin main) throws ConfigException {
|
||||
main.packPreLoadCallback(this);
|
||||
for(Map.Entry<String, Double> var : template.getVariables().entrySet()) {
|
||||
varScope.create(var.getKey()).setValue(var.getValue());
|
||||
}
|
||||
@@ -188,10 +183,10 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
.open("structures/trees", ".yml").then(streams -> buildAll(new TreeFactory(), treeRegistry, abstractConfigLoader.load(streams, TreeTemplate::new), main)).close()
|
||||
.open("structures/structures", ".yml").then(streams -> buildAll(new StructureFactory(), structureRegistry, abstractConfigLoader.load(streams, StructureTemplate::new), main)).close()
|
||||
.open("flora", ".yml").then(streams -> buildAll(new FloraFactory(), floraRegistry, abstractConfigLoader.load(streams, FloraTemplate::new), main)).close()
|
||||
.open("carving", ".yml").then(streams -> buildAll(new CarverFactory(this), carverRegistry, abstractConfigLoader.load(streams, CarverTemplate::new), main)).close()
|
||||
.open("biomes", ".yml").then(streams -> buildAll(new BiomeFactory(this), biomeRegistry, abstractConfigLoader.load(streams, () -> new BiomeTemplate(this, main)), main)).close();
|
||||
|
||||
|
||||
main.packPostLoadCallback(this);
|
||||
LangUtil.log("config-pack.loaded", Level.INFO, template.getID(), String.valueOf((System.nanoTime() - start) / 1000000D), template.getAuthor(), template.getVersion());
|
||||
}
|
||||
|
||||
@@ -215,14 +210,6 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
return structureRegistry.entries();
|
||||
}
|
||||
|
||||
public Collection<UserDefinedCarver> getCarvers() {
|
||||
return carverRegistry.entries();
|
||||
}
|
||||
|
||||
public UserDefinedCarver getCarver(String id) {
|
||||
return carverRegistry.get(id);
|
||||
}
|
||||
|
||||
public List<String> getStructureIDs() {
|
||||
return structureRegistry.entries().stream().map(terraStructure -> terraStructure.getTemplate().getID()).collect(Collectors.toList());
|
||||
}
|
||||
@@ -245,7 +232,6 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
registry
|
||||
.registerLoader(Palette.class, paletteRegistry)
|
||||
.registerLoader(TerraBiome.class, biomeRegistry)
|
||||
.registerLoader(UserDefinedCarver.class, carverRegistry)
|
||||
.registerLoader(Flora.class, floraRegistry)
|
||||
.registerLoader(Ore.class, oreRegistry)
|
||||
.registerLoader(Tree.class, treeRegistry)
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.dfsek.terra.config.factories;
|
||||
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
import parsii.tokenizer.ParseException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class CarverFactory implements TerraFactory<CarverTemplate, UserDefinedCarver> {
|
||||
private final ConfigPack pack;
|
||||
|
||||
public CarverFactory(ConfigPack pack) {
|
||||
this.pack = pack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserDefinedCarver build(CarverTemplate config, TerraPlugin main) throws LoadException {
|
||||
double[] start = new double[] {config.getStartX(), config.getStartY(), config.getStartZ()};
|
||||
double[] mutate = new double[] {config.getMutateX(), config.getMutateY(), config.getMutateZ()};
|
||||
List<String> radius = Arrays.asList(config.getRadMX(), config.getRadMY(), config.getRadMZ());
|
||||
long hash = MathUtil.hashToLong(config.getID());
|
||||
UserDefinedCarver carver;
|
||||
try {
|
||||
carver = new UserDefinedCarver(config.getHeight(), config.getLength(), start, mutate, radius, pack.getVarScope(), hash, config.getCutTop(), config.getCutBottom(), config, main);
|
||||
} catch(ParseException e) {
|
||||
throw new LoadException("Unable to parse radius equations", e);
|
||||
}
|
||||
carver.setRecalc(config.getRecalc());
|
||||
carver.setRecalcMagnitude(config.getRecaclulateMagnitude());
|
||||
return carver;
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
package com.dfsek.terra.config.loaders.palette;
|
||||
|
||||
import com.dfsek.tectonic.config.Configuration;
|
||||
import com.dfsek.tectonic.exception.LoadException;
|
||||
import com.dfsek.tectonic.loading.ConfigLoader;
|
||||
import com.dfsek.tectonic.loading.TypeLoader;
|
||||
import com.dfsek.terra.api.math.ProbabilityCollection;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.carving.CarverPalette;
|
||||
import com.dfsek.terra.config.loaders.Types;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public class CarverPaletteLoader implements TypeLoader<CarverPalette> {
|
||||
|
||||
|
||||
@Override
|
||||
public CarverPalette load(Type type, Object o, ConfigLoader configLoader) throws LoadException {
|
||||
Configuration configuration = new Configuration((Map<String, Object>) o);
|
||||
CarverPalette palette = new CarverPalette((MaterialSet) configLoader.loadType(MaterialSet.class, configuration.get("replace")), (Boolean) configuration.get("replace-blacklist"));
|
||||
|
||||
for(Map<String, Object> map : (List<Map<String, Object>>) configuration.get("layers")) {
|
||||
ProbabilityCollection<BlockData> layer = (ProbabilityCollection<BlockData>) configLoader.loadType(Types.BLOCK_DATA_PROBABILITY_COLLECTION_TYPE, map.get("materials"));
|
||||
palette.add(layer, (Integer) map.get("y"));
|
||||
}
|
||||
palette.build();
|
||||
return palette;
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,6 @@ import com.dfsek.terra.api.util.GlueList;
|
||||
import com.dfsek.terra.api.world.palette.Palette;
|
||||
import com.dfsek.terra.biome.palette.PaletteHolder;
|
||||
import com.dfsek.terra.biome.palette.SinglePalette;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.generation.config.NoiseBuilder;
|
||||
import com.dfsek.terra.population.items.TerraStructure;
|
||||
@@ -27,7 +26,6 @@ import parsii.eval.Parser;
|
||||
import parsii.eval.Scope;
|
||||
import parsii.tokenizer.ParseException;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -57,10 +55,12 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
@Value("palette")
|
||||
@Abstractable
|
||||
private PaletteHolder palette;
|
||||
|
||||
@Value("slant.palette")
|
||||
@Abstractable
|
||||
@Default
|
||||
private PaletteHolder slantPalette = null;
|
||||
|
||||
@Value("vanilla")
|
||||
@Abstractable
|
||||
private ProbabilityCollection<Biome> vanilla;
|
||||
@@ -89,25 +89,26 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
@Abstractable
|
||||
@Default
|
||||
private String erode = null;
|
||||
|
||||
@Value("structures")
|
||||
@Abstractable
|
||||
@Default
|
||||
private List<TerraStructure> structures = new GlueList<>();
|
||||
@Value("carving")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<UserDefinedCarver, Integer> carvers = new HashMap<>();
|
||||
|
||||
@Value("noise-equation")
|
||||
@Abstractable
|
||||
private String noiseEquation;
|
||||
|
||||
@Value("ores")
|
||||
@Abstractable
|
||||
@Default
|
||||
private OreHolder oreHolder = new OreHolder();
|
||||
|
||||
@Value("ocean.level")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int seaLevel = 62;
|
||||
|
||||
@Value("ocean.palette")
|
||||
@Abstractable
|
||||
@Default
|
||||
@@ -274,10 +275,6 @@ public class BiomeTemplate extends AbstractableTemplate implements ValidatedConf
|
||||
return structures;
|
||||
}
|
||||
|
||||
public Map<UserDefinedCarver, Integer> getCarvers() {
|
||||
return carvers;
|
||||
}
|
||||
|
||||
public String getNoiseEquation() {
|
||||
return noiseEquation;
|
||||
}
|
||||
|
||||
@@ -1,205 +0,0 @@
|
||||
package com.dfsek.terra.config.templates;
|
||||
|
||||
import com.dfsek.tectonic.annotations.Abstractable;
|
||||
import com.dfsek.tectonic.annotations.Default;
|
||||
import com.dfsek.tectonic.annotations.Value;
|
||||
import com.dfsek.terra.api.math.Range;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.carving.CarverPalette;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@SuppressWarnings({"unused", "FieldMayBeFinal"})
|
||||
public class CarverTemplate extends AbstractableTemplate {
|
||||
@Value("id")
|
||||
private String id;
|
||||
|
||||
@Value("step")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int step = 2;
|
||||
|
||||
@Value("recalculate-magnitude")
|
||||
@Default
|
||||
@Abstractable
|
||||
private double recaclulateMagnitude = 4;
|
||||
|
||||
@Value("recalculate-direction")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Range recalc = new Range(8, 10);
|
||||
|
||||
@Value("length")
|
||||
@Abstractable
|
||||
private Range length;
|
||||
|
||||
@Value("start.x")
|
||||
@Abstractable
|
||||
private double startX;
|
||||
|
||||
@Value("start.y")
|
||||
@Abstractable
|
||||
private double startY;
|
||||
|
||||
@Value("start.z")
|
||||
@Abstractable
|
||||
private double startZ;
|
||||
|
||||
@Value("start.radius.x")
|
||||
@Abstractable
|
||||
private String radMX;
|
||||
|
||||
@Value("start.radius.y")
|
||||
@Abstractable
|
||||
private String radMY;
|
||||
|
||||
@Value("start.radius.z")
|
||||
@Abstractable
|
||||
private String radMZ;
|
||||
|
||||
@Value("start.height")
|
||||
@Abstractable
|
||||
private Range height;
|
||||
|
||||
@Value("cut.bottom")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int cutBottom = 0;
|
||||
|
||||
@Value("cut.top")
|
||||
@Abstractable
|
||||
@Default
|
||||
private int cutTop = 0;
|
||||
|
||||
@Value("mutate.x")
|
||||
@Abstractable
|
||||
private double mutateX;
|
||||
|
||||
@Value("mutate.y")
|
||||
@Abstractable
|
||||
private double mutateY;
|
||||
|
||||
@Value("mutate.z")
|
||||
@Abstractable
|
||||
private double mutateZ;
|
||||
|
||||
@Value("palette.top")
|
||||
@Abstractable
|
||||
private CarverPalette top;
|
||||
|
||||
@Value("palette.bottom")
|
||||
@Abstractable
|
||||
private CarverPalette bottom;
|
||||
|
||||
@Value("palette.outer")
|
||||
@Abstractable
|
||||
private CarverPalette outer;
|
||||
|
||||
@Value("palette.inner")
|
||||
@Abstractable
|
||||
private CarverPalette inner;
|
||||
|
||||
@Value("shift")
|
||||
@Abstractable
|
||||
@Default
|
||||
private Map<MaterialData, MaterialSet> shift = new HashMap<>();
|
||||
|
||||
@Value("update")
|
||||
@Abstractable
|
||||
@Default
|
||||
private MaterialSet update = new MaterialSet();
|
||||
|
||||
public String getID() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getStep() {
|
||||
return step;
|
||||
}
|
||||
|
||||
public Range getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public double getStartX() {
|
||||
return startX;
|
||||
}
|
||||
|
||||
public double getStartY() {
|
||||
return startY;
|
||||
}
|
||||
|
||||
public double getStartZ() {
|
||||
return startZ;
|
||||
}
|
||||
|
||||
public String getRadMX() {
|
||||
return radMX;
|
||||
}
|
||||
|
||||
public String getRadMY() {
|
||||
return radMY;
|
||||
}
|
||||
|
||||
public String getRadMZ() {
|
||||
return radMZ;
|
||||
}
|
||||
|
||||
public Range getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
public int getCutBottom() {
|
||||
return cutBottom;
|
||||
}
|
||||
|
||||
public int getCutTop() {
|
||||
return cutTop;
|
||||
}
|
||||
|
||||
public double getMutateX() {
|
||||
return mutateX;
|
||||
}
|
||||
|
||||
public double getMutateY() {
|
||||
return mutateY;
|
||||
}
|
||||
|
||||
public double getMutateZ() {
|
||||
return mutateZ;
|
||||
}
|
||||
|
||||
public CarverPalette getTop() {
|
||||
return top;
|
||||
}
|
||||
|
||||
public CarverPalette getBottom() {
|
||||
return bottom;
|
||||
}
|
||||
|
||||
public CarverPalette getOuter() {
|
||||
return outer;
|
||||
}
|
||||
|
||||
public CarverPalette getInner() {
|
||||
return inner;
|
||||
}
|
||||
|
||||
public Map<MaterialData, MaterialSet> getShift() {
|
||||
return shift;
|
||||
}
|
||||
|
||||
public MaterialSet getUpdate() {
|
||||
return update;
|
||||
}
|
||||
|
||||
public Range getRecalc() {
|
||||
return recalc;
|
||||
}
|
||||
|
||||
public double getRecaclulateMagnitude() {
|
||||
return recaclulateMagnitude;
|
||||
}
|
||||
}
|
||||
@@ -10,10 +10,9 @@ import com.dfsek.terra.api.platform.block.data.Bisected;
|
||||
import com.dfsek.terra.api.platform.block.data.Slab;
|
||||
import com.dfsek.terra.api.platform.block.data.Stairs;
|
||||
import com.dfsek.terra.api.platform.block.data.Waterlogged;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.api.world.palette.Palette;
|
||||
@@ -24,6 +23,7 @@ import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.generation.math.Sampler;
|
||||
import com.dfsek.terra.generation.math.SamplerCache;
|
||||
import com.dfsek.terra.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.util.PaletteUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -1,105 +0,0 @@
|
||||
package com.dfsek.terra.population;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.templates.CarverTemplate;
|
||||
import com.dfsek.terra.util.PopulationUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class CavePopulator implements TerraBlockPopulator {
|
||||
private final TerraPlugin main;
|
||||
private static final Map<MaterialData, BlockData> shiftStorage = new HashMap<>(); // Persist BlockData created for shifts, to avoid re-calculating each time.
|
||||
|
||||
public CavePopulator(TerraPlugin main) {
|
||||
this.main = main;
|
||||
}
|
||||
|
||||
@SuppressWarnings("try")
|
||||
@Override
|
||||
public void populate(@NotNull World world, @NotNull Chunk chunk) {
|
||||
TerraWorld tw = main.getWorld(world);
|
||||
WorldHandle handle = main.getWorldHandle();
|
||||
BlockData AIR = handle.createBlockData("minecraft:air");
|
||||
try(ProfileFuture ignored = tw.getProfiler().measure("CaveTime")) {
|
||||
Random random = PopulationUtil.getRandom(chunk);
|
||||
if(!tw.isSafe()) return;
|
||||
ConfigPack config = tw.getConfig();
|
||||
|
||||
for(UserDefinedCarver c : config.getCarvers()) {
|
||||
CarverTemplate template = c.getConfig();
|
||||
Map<Location, MaterialData> shiftCandidate = new HashMap<>();
|
||||
Set<Block> updateNeeded = new HashSet<>();
|
||||
c.carve(chunk.getX(), chunk.getZ(), world, (v, type) -> {
|
||||
Block b = chunk.getBlock(v.getBlockX(), v.getBlockY(), v.getBlockZ());
|
||||
MaterialData m = handle.getType(b);
|
||||
switch(type) {
|
||||
case CENTER:
|
||||
if(template.getInner().canReplace(m)) {
|
||||
handle.setBlockData(b, template.getInner().get(v.getBlockY()).get(random), false);
|
||||
if(template.getUpdate().contains(m)) updateNeeded.add(b);
|
||||
if(template.getShift().containsKey(m)) shiftCandidate.put(b.getLocation(), m);
|
||||
}
|
||||
break;
|
||||
case WALL:
|
||||
if(template.getOuter().canReplace(m)) {
|
||||
handle.setBlockData(b, template.getOuter().get(v.getBlockY()).get(random), false);
|
||||
if(template.getUpdate().contains(m)) updateNeeded.add(b);
|
||||
if(template.getShift().containsKey(m)) shiftCandidate.put(b.getLocation(), m);
|
||||
}
|
||||
break;
|
||||
case TOP:
|
||||
if(template.getTop().canReplace(m)) {
|
||||
handle.setBlockData(b, template.getTop().get(v.getBlockY()).get(random), false);
|
||||
if(template.getUpdate().contains(m)) updateNeeded.add(b);
|
||||
if(template.getShift().containsKey(m)) shiftCandidate.put(b.getLocation(), m);
|
||||
}
|
||||
break;
|
||||
case BOTTOM:
|
||||
if(template.getBottom().canReplace(m)) {
|
||||
handle.setBlockData(b, template.getBottom().get(v.getBlockY()).get(random), false);
|
||||
if(template.getUpdate().contains(m)) updateNeeded.add(b);
|
||||
if(template.getShift().containsKey(m)) shiftCandidate.put(b.getLocation(), m);
|
||||
}
|
||||
break;
|
||||
}
|
||||
});
|
||||
for(Map.Entry<Location, MaterialData> entry : shiftCandidate.entrySet()) {
|
||||
Location l = entry.getKey();
|
||||
Location mut = l.clone();
|
||||
MaterialData orig = handle.getType(l.getBlock());
|
||||
do mut.subtract(0, 1, 0);
|
||||
while(mut.getY() > 0 && handle.getType(mut.getBlock()).equals(orig));
|
||||
try {
|
||||
if(template.getShift().get(entry.getValue()).contains(mut.getBlock().getType())) {
|
||||
handle.setBlockData(mut.getBlock(), shiftStorage.computeIfAbsent(entry.getValue(), MaterialData::createBlockData), false);
|
||||
}
|
||||
} catch(NullPointerException ignore) {
|
||||
}
|
||||
}
|
||||
for(Block b : updateNeeded) {
|
||||
BlockData orig = handle.getBlockData(b);
|
||||
handle.setBlockData(b, AIR, false);
|
||||
handle.setBlockData(b, orig, true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,11 +5,11 @@ import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.biome.BiomeProvider;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.population.items.flora.FloraLayer;
|
||||
import com.dfsek.terra.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.util.PopulationUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -6,12 +6,12 @@ import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.world.biome.TerraBiome;
|
||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
import com.dfsek.terra.profiler.ProfileFuture;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.structures.structure.Rotation;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
@@ -14,6 +13,7 @@ import com.dfsek.terra.biome.BiomeProvider;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.population.items.TerraStructure;
|
||||
import com.dfsek.terra.profiler.ProfileFuture;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ import com.dfsek.terra.api.math.vector.Vector2;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.api.world.generation.TerraBlockPopulator;
|
||||
import com.dfsek.terra.biome.BiomeProvider;
|
||||
import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.population.items.tree.TreeLayer;
|
||||
import com.dfsek.terra.profiler.ProfileFuture;
|
||||
import com.dfsek.terra.util.PopulationUtil;
|
||||
import net.jafama.FastMath;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.profiler;
|
||||
package com.dfsek.terra.profiler;
|
||||
|
||||
/**
|
||||
* Class to hold a profiler data value. Contains formatting method to highlight value based on desired range.
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.profiler;
|
||||
package com.dfsek.terra.profiler;
|
||||
|
||||
import net.jafama.FastMath;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.profiler;
|
||||
package com.dfsek.terra.profiler;
|
||||
|
||||
|
||||
/**
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.profiler;
|
||||
package com.dfsek.terra.profiler;
|
||||
|
||||
import com.dfsek.terra.api.math.MathUtil;
|
||||
import com.dfsek.terra.api.util.GlueList;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.profiler;
|
||||
package com.dfsek.terra.profiler;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.dfsek.terra.api.profiler;
|
||||
package com.dfsek.terra.profiler;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.google.common.collect.BiMap;
|
||||
@@ -14,8 +14,14 @@ public class WorldProfiler {
|
||||
|
||||
public WorldProfiler(World w) {
|
||||
if(w.getGenerator().getTerraGenerator() == null)
|
||||
throw new IllegalArgumentException("Attempted to instantiate profiler on non-Gaea managed world!");
|
||||
this.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "TotalChunkGenTime");
|
||||
throw new IllegalArgumentException("Attempted to instantiate profiler on non-Terra managed world!");
|
||||
this.addMeasurement(new Measurement(2500000, DataType.PERIOD_MILLISECONDS), "TotalChunkGenTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "FloraTime")
|
||||
.addMeasurement(new Measurement(10000000, DataType.PERIOD_MILLISECONDS), "TreeTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "OreTime")
|
||||
.addMeasurement(new Measurement(5000000, DataType.PERIOD_MILLISECONDS), "CaveTime")
|
||||
.addMeasurement(new Measurement(1500000, DataType.PERIOD_MILLISECONDS), "StructureTime");
|
||||
;
|
||||
isProfiling = false;
|
||||
this.world = w;
|
||||
}
|
||||
@@ -46,7 +52,7 @@ public class WorldProfiler {
|
||||
}
|
||||
}
|
||||
|
||||
public com.dfsek.terra.api.profiler.WorldProfiler addMeasurement(Measurement m, String name) {
|
||||
public com.dfsek.terra.profiler.WorldProfiler addMeasurement(Measurement m, String name) {
|
||||
measures.put(name, m);
|
||||
return this;
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
package com.dfsek.terra.registry;
|
||||
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
|
||||
public class CarverRegistry extends TerraRegistry<UserDefinedCarver> {
|
||||
}
|
||||
@@ -25,41 +25,14 @@ public class TreeRegistry extends TerraRegistry<Tree> {
|
||||
|
||||
public TreeRegistry(TerraPlugin main) {
|
||||
this.main = main;
|
||||
addTree("ACACIA");
|
||||
addTree("BIRCH");
|
||||
addTree("BROWN_MUSHROOM");
|
||||
tryAdd("CACTUS", Cactus.class);
|
||||
addTree("CHORUS_PLANT");
|
||||
addTree("DARK_OAK");
|
||||
tryAdd("GIANT_OAK", OakTree.class);
|
||||
tryAdd("GIANT_SPRUCE", SpruceTree.class);
|
||||
addTree("JUNGLE");
|
||||
addTree("JUNGLE_COCOA");
|
||||
addTree("JUNGLE_BUSH");
|
||||
addTree("LARGE_OAK");
|
||||
tryAdd("LARGE_SHATTERED_PILLAR", ShatteredPillar.class);
|
||||
addTree("LARGE_SPRUCE");
|
||||
addTree("MEGA_SPRUCE");
|
||||
addTree("OAK");
|
||||
addTree("RED_MUSHROOM");
|
||||
tryAdd("SHATTERED_LARGE", ShatteredTree.class);
|
||||
tryAdd("SHATTERED_SMALL", SmallShatteredTree.class);
|
||||
addTree("SMALL_JUNGLE");
|
||||
addTree("SPRUCE");
|
||||
addTree("SWAMP_OAK");
|
||||
tryAdd("SMALL_SHATTERED_PILLAR", SmallShatteredPillar.class);
|
||||
tryAdd("ICE_SPIKE", IceSpike.class);
|
||||
addTree("TALL_BIRCH");
|
||||
addTree("WARPED_FUNGUS");
|
||||
addTree("CRIMSON_FUNGUS");
|
||||
}
|
||||
|
||||
private void addTree(String id) {
|
||||
try {
|
||||
add(id, main.getWorldHandle().getTree(id));
|
||||
} catch(Exception e) {
|
||||
main.getLogger().warning("Unable to load tree " + id + ": " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
private void tryAdd(String id, Class<? extends FractalTree> value) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
|
||||
public class BukkitEntity implements Entity {
|
||||
private final org.bukkit.entity.Entity entity;
|
||||
|
||||
@@ -10,10 +10,7 @@ import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.handle.ItemHandle;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.platform.world.Biome;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.transform.MapTransform;
|
||||
import com.dfsek.terra.api.transform.Transformer;
|
||||
import com.dfsek.terra.bukkit.command.command.TerraCommand;
|
||||
import com.dfsek.terra.bukkit.command.command.structure.LocateCommand;
|
||||
import com.dfsek.terra.bukkit.generator.BukkitChunkGeneratorWrapper;
|
||||
@@ -23,6 +20,7 @@ import com.dfsek.terra.bukkit.listeners.CommonListener;
|
||||
import com.dfsek.terra.bukkit.listeners.PaperListener;
|
||||
import com.dfsek.terra.bukkit.listeners.SpigotListener;
|
||||
import com.dfsek.terra.bukkit.util.PaperUtil;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.bukkit.world.BukkitBiome;
|
||||
import com.dfsek.terra.bukkit.world.BukkitTree;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
@@ -54,7 +52,7 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
private final ConfigRegistry registry = new ConfigRegistry();
|
||||
private final PluginConfig config = new PluginConfig();
|
||||
private final ItemHandle itemHandle = new BukkitItemHandle();
|
||||
private WorldHandle handle = new BukkitWorldHandle(this);
|
||||
private WorldHandle handle = new BukkitWorldHandle();
|
||||
private final GenericLoaders genericLoaders = new GenericLoaders(this);
|
||||
|
||||
public static final Version BUKKIT_VERSION;
|
||||
@@ -100,6 +98,13 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
this.handle = handle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void packPreLoadCallback(ConfigPack pack) {
|
||||
for(TreeType value : TreeType.values()) {
|
||||
pack.getTreeRegistry().add(BukkitAdapter.TREE_TRANSFORMER.translate(value), new BukkitTree(value, this));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
BukkitChunkGeneratorWrapper.saveAll();
|
||||
@@ -114,19 +119,6 @@ public class TerraBukkitPlugin extends JavaPlugin implements TerraPlugin {
|
||||
getLogger().warning("Terra is running on an unknown Bukkit version. Proceed with caution.");
|
||||
}
|
||||
|
||||
((BukkitWorldHandle) handle).setTreeTransformer(new Transformer.Builder<String, Tree>()
|
||||
.addTransform(id -> new BukkitTree(TreeType.valueOf(id), this)) // First try getting directly from enum
|
||||
.addTransform(new MapTransform<String, Tree>() // Then try map of less stupid names
|
||||
.add("JUNGLE_COCOA", new BukkitTree(TreeType.COCOA_TREE, this))
|
||||
.add("LARGE_OAK", new BukkitTree(TreeType.BIG_TREE, this))
|
||||
.add("LARGE_SPRUCE", new BukkitTree(TreeType.TALL_REDWOOD, this))
|
||||
.add("SPRUCE", new BukkitTree(TreeType.REDWOOD, this))
|
||||
.add("OAK", new BukkitTree(TreeType.TREE, this))
|
||||
.add("MEGA_SPRUCE", new BukkitTree(TreeType.MEGA_REDWOOD, this))
|
||||
.add("SWAMP_OAK", new BukkitTree(TreeType.SWAMP, this)))
|
||||
.addTransform(id -> new BukkitTree(TreeType.valueOf(id), this)) // Finally, try stripping minecraft namespace.
|
||||
.build());
|
||||
|
||||
saveDefaultConfig();
|
||||
|
||||
Metrics metrics = new Metrics(this, 9017); // Set up bStats.
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.dfsek.terra.biome.UserDefinedBiome;
|
||||
import com.dfsek.terra.bukkit.BukkitCommandSender;
|
||||
import com.dfsek.terra.bukkit.command.WorldCommand;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.carving.UserDefinedCarver;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.config.templates.BiomeTemplate;
|
||||
@@ -18,7 +17,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BiomeInfoCommand extends WorldCommand {
|
||||
@@ -54,16 +52,6 @@ public class BiomeInfoCommand extends WorldCommand {
|
||||
}
|
||||
}
|
||||
|
||||
Map<UserDefinedCarver, Integer> carverConfigs = bio.getCarvers();
|
||||
|
||||
if(structureConfigs.size() == 0) sender.sendMessage("No Carvers");
|
||||
else {
|
||||
sender.sendMessage("---------Carvers--------");
|
||||
for(Map.Entry<UserDefinedCarver, Integer> entry : carverConfigs.entrySet()) {
|
||||
sender.sendMessage(" - " + entry.getKey().getConfig().getID() + ": " + entry.getValue() + "%");
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.bukkit.command.command.profile;
|
||||
|
||||
import com.dfsek.terra.api.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.bukkit.command.WorldCommand;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.profiler.WorldProfiler;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.bukkit.command.command.profile;
|
||||
|
||||
import com.dfsek.terra.api.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.bukkit.BukkitCommandSender;
|
||||
import com.dfsek.terra.bukkit.command.WorldCommand;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.profiler.WorldProfiler;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.bukkit.command.command.profile;
|
||||
|
||||
import com.dfsek.terra.api.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.bukkit.BukkitCommandSender;
|
||||
import com.dfsek.terra.bukkit.command.WorldCommand;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.profiler.WorldProfiler;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.dfsek.terra.bukkit.command.command.profile;
|
||||
|
||||
import com.dfsek.terra.api.profiler.WorldProfiler;
|
||||
import com.dfsek.terra.bukkit.BukkitCommandSender;
|
||||
import com.dfsek.terra.bukkit.command.WorldCommand;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.profiler.WorldProfiler;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.generator.BlockPopulator;
|
||||
import com.dfsek.terra.api.platform.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.BlockPopulator;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.bukkit.world.BukkitBiomeGrid;
|
||||
import com.dfsek.terra.bukkit.world.BukkitWorld;
|
||||
@@ -16,7 +16,7 @@ import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class BukkitChunkGenerator implements com.dfsek.terra.api.platform.generator.ChunkGenerator {
|
||||
public class BukkitChunkGenerator implements com.dfsek.terra.api.platform.world.generator.ChunkGenerator {
|
||||
private final ChunkGenerator delegate;
|
||||
|
||||
public BukkitChunkGenerator(ChunkGenerator delegate) {
|
||||
|
||||
@@ -2,8 +2,8 @@ package com.dfsek.terra.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.api.world.generation.population.PopulationManager;
|
||||
import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package com.dfsek.terra.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.generator.BlockPopulator;
|
||||
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;
|
||||
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
package com.dfsek.terra.bukkit.handles;
|
||||
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.transform.Transformer;
|
||||
import com.dfsek.terra.bukkit.world.block.BukkitMaterialData;
|
||||
import com.dfsek.terra.bukkit.world.block.data.BukkitBlockData;
|
||||
import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
||||
@@ -15,15 +12,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
|
||||
public class BukkitWorldHandle implements WorldHandle {
|
||||
private Transformer<String, Tree> treeTransformer;
|
||||
|
||||
public BukkitWorldHandle(TerraPlugin main) {
|
||||
}
|
||||
|
||||
public void setTreeTransformer(Transformer<String, Tree> treeTransformer) {
|
||||
this.treeTransformer = treeTransformer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(Block block, BlockData data, boolean physics) {
|
||||
block.setBlockData(data, physics);
|
||||
@@ -50,11 +38,6 @@ public class BukkitWorldHandle implements WorldHandle {
|
||||
return new BukkitMaterialData(Material.matchMaterial(data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree getTree(String id) {
|
||||
return treeTransformer.translate(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntity(String id) {
|
||||
return new BukkitEntityType(org.bukkit.entity.EntityType.valueOf(id));
|
||||
|
||||
@@ -13,15 +13,31 @@ import com.dfsek.terra.api.platform.block.data.Stairs;
|
||||
import com.dfsek.terra.api.platform.inventory.item.Enchantment;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.transform.MapTransform;
|
||||
import com.dfsek.terra.api.transform.Transformer;
|
||||
import com.dfsek.terra.bukkit.BukkitCommandSender;
|
||||
import com.dfsek.terra.bukkit.world.inventory.meta.BukkitEnchantment;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* Utility class to adapt Bukkit enums to Terra enums.
|
||||
*/
|
||||
public final class BukkitAdapter {
|
||||
public static Transformer<TreeType, String> TREE_TRANSFORMER = new Transformer.Builder<TreeType, String>()
|
||||
.addTransform(new MapTransform<TreeType, String>()
|
||||
.add(TreeType.COCOA_TREE, "JUNGLE_COCOA")
|
||||
.add(TreeType.BIG_TREE, "LARGE_OAK")
|
||||
.add(TreeType.TALL_REDWOOD, "LARGE_SPRUCE")
|
||||
.add(TreeType.REDWOOD, "SPRUCE")
|
||||
.add(TreeType.TREE, "OAK")
|
||||
.add(TreeType.MEGA_REDWOOD, "MEGA_SPRUCE")
|
||||
.add(TreeType.SWAMP, "SWAMP_OAK"))
|
||||
.addTransform(TreeType::toString)
|
||||
.build();
|
||||
|
||||
|
||||
public static Stairs.Shape adapt(org.bukkit.block.data.type.Stairs.Shape shape) {
|
||||
switch(shape) {
|
||||
case STRAIGHT:
|
||||
|
||||
@@ -4,7 +4,7 @@ import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.world.tree.Tree;
|
||||
import com.dfsek.terra.util.MaterialSet;
|
||||
import org.bukkit.TreeType;
|
||||
|
||||
@@ -41,11 +41,6 @@ public class BukkitTree implements Tree {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TreeType getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plant(Location l, Random r) {
|
||||
return ((BukkitWorld) l.getWorld()).getHandle().generateTree(BukkitAdapter.adapt(l), delegate);
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.dfsek.terra.bukkit.world;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.bukkit.BukkitEntity;
|
||||
import com.dfsek.terra.bukkit.generator.BukkitChunkGenerator;
|
||||
import com.dfsek.terra.bukkit.world.block.BukkitBlock;
|
||||
@@ -73,11 +72,6 @@ public class BukkitWorld implements World {
|
||||
return new BukkitBlock(delegate.getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location l, Tree vanillaTreeType) {
|
||||
return delegate.generateTree(new org.bukkit.Location(delegate, l.getX(), l.getY(), l.getZ()), ((BukkitTree) vanillaTreeType).getHandle());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
return new BukkitEntity(delegate.spawnEntity(BukkitAdapter.adapt(location), ((BukkitEntityType) entityType).getHandle()));
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.bukkit.world.block.state;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.state.MobSpawner;
|
||||
import com.dfsek.terra.api.platform.block.state.SerialState;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.bukkit.world.entity.BukkitEntityType;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.world.entity;
|
||||
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
|
||||
public class BukkitEntityType implements EntityType {
|
||||
private final org.bukkit.entity.EntityType delegate;
|
||||
|
||||
@@ -251,8 +251,6 @@ public class TerraFabricPlugin implements TerraPlugin, ModInitializer {
|
||||
logger.setLevel(Level.INFO);
|
||||
instance = this;
|
||||
|
||||
((FabricWorldHandle) worldHandle).setTreeTransformer(TREE_TRANSFORMER);
|
||||
|
||||
config = new File(FabricLoader.getInstance().getConfigDir().toFile(), "Terra");
|
||||
saveDefaultConfig();
|
||||
plugin.load(this);
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.dfsek.terra.fabric.world;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.world.tree.Tree;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
||||
import com.dfsek.terra.fabric.world.handles.world.FabricWorldAccess;
|
||||
@@ -34,9 +34,4 @@ public class FabricTree implements Tree {
|
||||
return MaterialSet.get(TerraFabricPlugin.getInstance().getWorldHandle().createMaterialData("minecraft:grass_block"),
|
||||
TerraFabricPlugin.getInstance().getWorldHandle().createMaterialData("minecraft:podzol"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfiguredFeature<?, ?> getHandle() {
|
||||
return delegate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,10 +3,8 @@ package com.dfsek.terra.fabric.world;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.transform.Transformer;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import com.dfsek.terra.fabric.world.block.FabricMaterialData;
|
||||
import com.dfsek.terra.fabric.world.block.data.FabricMultipleFacing;
|
||||
@@ -19,17 +17,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.command.argument.BlockArgumentParser;
|
||||
import net.minecraft.state.property.Properties;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
public class FabricWorldHandle implements WorldHandle {
|
||||
private Transformer<String, ConfiguredFeature<?, ?>> treeTransformer;
|
||||
|
||||
public void setTreeTransformer(Transformer<String, ConfiguredFeature<?, ?>> treeTransformer) {
|
||||
this.treeTransformer = treeTransformer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBlockData(Block block, BlockData data, boolean physics) {
|
||||
block.setBlockData(data, physics);
|
||||
@@ -72,11 +63,6 @@ public class FabricWorldHandle implements WorldHandle {
|
||||
return new FabricMaterialData(createBlockData(data).getHandle().getBlock());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree getTree(String id) {
|
||||
return new FabricTree(treeTransformer.translate(id));
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntity(String id) {
|
||||
return null;
|
||||
|
||||
@@ -27,7 +27,6 @@ public class PopulatorFeature extends Feature<DefaultFeatureConfig> {
|
||||
FabricChunkGeneratorWrapper gen = (FabricChunkGeneratorWrapper) chunkGenerator;
|
||||
FabricChunkWorldAccess chunk = new FabricChunkWorldAccess(world, pos.getX() >> 4, pos.getZ() >> 4);
|
||||
FabricWorld world1 = new FabricWorld(world.toServerWorld(), new FabricChunkGenerator(chunkGenerator));
|
||||
gen.getCavePopulator().populate(world1, chunk);
|
||||
gen.getStructurePopulator().populate(new FabricSeededWorldAccess(world, world.getSeed(), chunkGenerator), chunk);
|
||||
gen.getOrePopulator().populate(world1, chunk);
|
||||
gen.getTreePopulator().populate(world1, chunk);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.dfsek.terra.fabric.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlockData;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.fabric.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.generator.BlockPopulator;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.BlockPopulator;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.dfsek.terra.fabric.world.generator;
|
||||
|
||||
import com.dfsek.terra.api.platform.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.platform.world.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.util.FastRandom;
|
||||
import com.dfsek.terra.config.base.ConfigPack;
|
||||
import com.dfsek.terra.fabric.TerraFabricPlugin;
|
||||
import com.dfsek.terra.fabric.world.TerraBiomeSource;
|
||||
import com.dfsek.terra.fabric.world.handles.world.FabricSeededWorldAccess;
|
||||
import com.dfsek.terra.generation.MasterChunkGenerator;
|
||||
import com.dfsek.terra.population.CavePopulator;
|
||||
import com.dfsek.terra.population.FloraPopulator;
|
||||
import com.dfsek.terra.population.OrePopulator;
|
||||
import com.dfsek.terra.population.StructurePopulator;
|
||||
@@ -46,7 +45,6 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
||||
private final ConfigPack pack;
|
||||
|
||||
|
||||
private final CavePopulator cavePopulator = new CavePopulator(TerraFabricPlugin.getInstance());
|
||||
private final FloraPopulator floraPopulator = new FloraPopulator(TerraFabricPlugin.getInstance());
|
||||
private final OrePopulator orePopulator = new OrePopulator(TerraFabricPlugin.getInstance());
|
||||
private final TreePopulator treePopulator = new TreePopulator(TerraFabricPlugin.getInstance());
|
||||
@@ -56,10 +54,6 @@ public class FabricChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
||||
return treePopulator;
|
||||
}
|
||||
|
||||
public CavePopulator getCavePopulator() {
|
||||
return cavePopulator;
|
||||
}
|
||||
|
||||
public OrePopulator getOrePopulator() {
|
||||
return orePopulator;
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.dfsek.terra.fabric.world.handles;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.handles.chunk.FabricChunk;
|
||||
import net.minecraft.server.world.ServerWorld;
|
||||
@@ -86,11 +85,6 @@ public class FabricWorld implements World {
|
||||
return getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location l, Tree vanillaTreeType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
return null;
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.dfsek.terra.fabric.world.handles.world;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -75,11 +74,6 @@ public class FabricSeededWorldAccess implements World {
|
||||
return getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location l, Tree vanillaTreeType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
return null;
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.dfsek.terra.fabric.world.handles.world;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -76,11 +75,6 @@ public class FabricWorldAccess implements World {
|
||||
return getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location l, Tree vanillaTreeType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
return null;
|
||||
|
||||
@@ -2,12 +2,11 @@ package com.dfsek.terra.fabric.world.handles.world;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.fabric.world.block.FabricBlock;
|
||||
import com.dfsek.terra.fabric.world.generator.FabricChunkGenerator;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
@@ -85,11 +84,6 @@ public class FabricWorldChunkRegion implements World {
|
||||
return getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location l, Tree vanillaTreeType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
return null;
|
||||
|
||||
@@ -3,8 +3,8 @@ package com.dfsek.terra.platform;
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import net.querz.mca.Chunk;
|
||||
import net.querz.nbt.tag.CompoundTag;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -4,12 +4,11 @@ import com.dfsek.terra.DirectUtils;
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.math.vector.Vector3;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.entity.Entity;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import net.jafama.FastMath;
|
||||
import net.querz.mca.MCAFile;
|
||||
import net.querz.mca.MCAUtil;
|
||||
@@ -88,11 +87,6 @@ public class DirectWorld implements World {
|
||||
return getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean generateTree(Location l, Tree vanillaTreeType) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity spawnEntity(Location location, EntityType entityType) {
|
||||
return null;
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.platform.generator.BlockPopulator;
|
||||
import com.dfsek.terra.api.platform.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.platform.world.BiomeGrid;
|
||||
import com.dfsek.terra.api.platform.world.World;
|
||||
import com.dfsek.terra.api.platform.world.generator.BlockPopulator;
|
||||
import com.dfsek.terra.api.platform.world.generator.ChunkGenerator;
|
||||
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
|
||||
import com.dfsek.terra.generation.MasterChunkGenerator;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -2,18 +2,13 @@ package com.dfsek.terra.platform;
|
||||
|
||||
import com.dfsek.terra.api.math.vector.Location;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.world.tree.Tree;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
|
||||
public class RawTree implements Tree { // TODO: implement
|
||||
@Override
|
||||
public Object getHandle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean plant(Location l, Random r) {
|
||||
return false;
|
||||
|
||||
@@ -3,9 +3,8 @@ package com.dfsek.terra.platform;
|
||||
import com.dfsek.terra.api.platform.block.Block;
|
||||
import com.dfsek.terra.api.platform.block.BlockData;
|
||||
import com.dfsek.terra.api.platform.block.MaterialData;
|
||||
import com.dfsek.terra.api.platform.entity.EntityType;
|
||||
import com.dfsek.terra.api.platform.handle.WorldHandle;
|
||||
import com.dfsek.terra.api.platform.world.Tree;
|
||||
import com.dfsek.terra.api.platform.world.entity.EntityType;
|
||||
|
||||
public class RawWorldHandle implements WorldHandle {
|
||||
@Override
|
||||
@@ -33,11 +32,6 @@ public class RawWorldHandle implements WorldHandle {
|
||||
return new Data(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Tree getTree(String id) {
|
||||
return new RawTree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getEntity(String id) {
|
||||
return null;
|
||||
|
||||
@@ -6,7 +6,6 @@ import com.dfsek.terra.generation.math.SamplerCache;
|
||||
import com.dfsek.terra.platform.DirectChunkData;
|
||||
import com.dfsek.terra.platform.DirectWorld;
|
||||
import com.dfsek.terra.platform.GenWrapper;
|
||||
import com.dfsek.terra.population.CavePopulator;
|
||||
import com.dfsek.terra.population.FloraPopulator;
|
||||
import com.dfsek.terra.population.OrePopulator;
|
||||
import com.dfsek.terra.population.StructurePopulator;
|
||||
@@ -24,7 +23,6 @@ public class Generator {
|
||||
StructurePopulator structurePopulator;
|
||||
TreePopulator treePopulator;
|
||||
OrePopulator orePopulator;
|
||||
CavePopulator cavePopulator;
|
||||
MasterChunkGenerator generator;
|
||||
|
||||
public Generator(long seed, StandalonePlugin plugin) {
|
||||
@@ -33,7 +31,6 @@ public class Generator {
|
||||
structurePopulator = new StructurePopulator(plugin);
|
||||
treePopulator = new TreePopulator(plugin);
|
||||
orePopulator = new OrePopulator(plugin);
|
||||
cavePopulator = new CavePopulator(plugin);
|
||||
generator = new MasterChunkGenerator(plugin.getRegistry().get("DEFAULT"), plugin, new SamplerCache(plugin));
|
||||
this.seed = seed;
|
||||
}
|
||||
@@ -55,7 +52,6 @@ public class Generator {
|
||||
DirectChunkData chunkData = (DirectChunkData) world.getChunkAt(cx, cz);
|
||||
generator.generateChunkData(world, null, cx, cz, chunkData);
|
||||
|
||||
cavePopulator.populate(world, chunkData);
|
||||
structurePopulator.populate(world, chunkData);
|
||||
orePopulator.populate(world, chunkData);
|
||||
floraPopulator.populate(world, chunkData);
|
||||
|
||||
Reference in New Issue
Block a user