more refactors, create platform module

This commit is contained in:
dfsek
2021-06-23 10:39:37 -07:00
parent 506f59f8af
commit 24b8fc859c
42 changed files with 178 additions and 109 deletions

View File

@@ -163,7 +163,7 @@ public class Location implements Cloneable {
return hash;
}
public Vector3Impl toVector() {
public Vector3 toVector() {
return vector.clone();
}

View File

@@ -38,7 +38,7 @@ public interface Vector2 extends Cloneable {
* @param other Vector to add
* @return Mutated vector, for chaining.
*/
Vector2 add(Vector2Impl other);
Vector2 add(Vector2 other);
/**
* Subtract a vector from this vector,
@@ -46,7 +46,7 @@ public interface Vector2 extends Cloneable {
* @param other Vector to subtract
* @return Mutated vector, for chaining.
*/
Vector2 subtract(Vector2Impl other);
Vector2 subtract(Vector2 other);
/**
* Normalize this vector to length 1
@@ -83,7 +83,7 @@ public interface Vector2 extends Cloneable {
* @param other Another vector
* @return Distance between vectors
*/
double distance(Vector2Impl other);
double distance(Vector2 other);
/**
* Get the squared distance between 2 vectors.
@@ -91,7 +91,7 @@ public interface Vector2 extends Cloneable {
* @param other Another vector
* @return Squared distance
*/
double distanceSquared(Vector2Impl other);
double distanceSquared(Vector2 other);
Vector2 add(double x, double z);

View File

@@ -95,7 +95,7 @@ public interface Vector3 extends Cloneable {
* @param o The other vector
* @return the distance
*/
double distance(@NotNull Vector3Impl o);
double distance(@NotNull Vector3 o);
/**
* Get the squared distance between this vector and another.
@@ -103,7 +103,7 @@ public interface Vector3 extends Cloneable {
* @param o The other vector
* @return the distance
*/
double distanceSquared(@NotNull Vector3Impl o);
double distanceSquared(@NotNull Vector3 o);
/**
* Rotates the vector around a given arbitrary axis in 3 dimensional space.
@@ -117,7 +117,7 @@ public interface Vector3 extends Cloneable {
*
* @param axis the axis to rotate the vector around. If the passed vector is
* not of length 1, it gets copied and normalized before using it for the
* rotation. Please use {@link Vector3Impl#normalize()} on the instance before
* rotation. Please use {@link Vector3#normalize()} on the instance before
* passing it to this method
* @param angle the angle to rotate the vector around the axis
* @return the same vector
@@ -144,7 +144,7 @@ public interface Vector3 extends Cloneable {
* @throws IllegalArgumentException if the provided axis vector instance is
* null
*/
@NotNull Vector3 rotateAroundNonUnitAxis(@NotNull Vector3Impl axis, double angle) throws IllegalArgumentException;
@NotNull Vector3 rotateAroundNonUnitAxis(@NotNull Vector3 axis, double angle) throws IllegalArgumentException;
/**
* Calculates the dot product of this vector with another. The dot product
@@ -153,7 +153,7 @@ public interface Vector3 extends Cloneable {
* @param other The other vector
* @return dot product
*/
double dot(@NotNull Vector3Impl other);
double dot(@NotNull Vector3 other);
Location toLocation(World world);
@@ -161,5 +161,7 @@ public interface Vector3 extends Cloneable {
Vector3 subtract(int x, int y, int z);
Vector3 subtract(Vector3Impl end);
Vector3 subtract(Vector3 end);
public Vector3 clone();
}

View File

@@ -7,7 +7,7 @@ import com.dfsek.terra.api.entity.Entity;
import com.dfsek.terra.api.entity.EntityType;
import com.dfsek.terra.api.world.generator.ChunkGenerator;
import com.dfsek.terra.api.world.generator.GeneratorWrapper;
import com.dfsek.terra.api.world.generation.TerraChunkGenerator;
import com.dfsek.terra.api.world.generator.TerraChunkGenerator;
public interface World extends Handle {
long getSeed();

View File

@@ -0,0 +1,7 @@
package com.dfsek.terra.api.world.generator;
/**
* Marker interface that marks a feature as "chunkified" (only modifying one chunk at a time)
*/
public interface Chunkified {
}

View File

@@ -0,0 +1,21 @@
package com.dfsek.terra.api.world.generator;
import com.dfsek.terra.api.block.BlockData;
import com.dfsek.terra.api.noise.NoiseSampler;
import com.dfsek.terra.api.util.ProbabilityCollection;
public interface Palette {
Palette add(BlockData m, int layers, NoiseSampler sampler);
Palette add(ProbabilityCollection<BlockData> m, int layers, NoiseSampler sampler);
/**
* Fetches a material from the palette, at a given layer.
*
* @param layer - The layer at which to fetch the material.
* @return BlockData - The material fetched.
*/
BlockData get(int layer, double x, double y, double z);
int getSize();
}

View File

@@ -0,0 +1,8 @@
package com.dfsek.terra.api.world.generator;
import com.dfsek.terra.api.world.Chunk;
import com.dfsek.terra.api.world.World;
public interface TerraBlockPopulator {
void populate(World world, Chunk chunk);
}

View File

@@ -0,0 +1,27 @@
package com.dfsek.terra.api.world.generator;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.config.ConfigPack;
import com.dfsek.terra.api.world.BiomeGrid;
import com.dfsek.terra.api.world.World;
import com.dfsek.terra.api.world.biome.generation.BiomeProvider;
import com.dfsek.terra.config.pack.ConfigPackImpl;
import com.dfsek.terra.world.generation.math.samplers.Sampler;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Random;
public interface TerraChunkGenerator {
ChunkData generateChunkData(@NotNull World world, Random random, int x, int z, ChunkData original);
void generateBiomes(@NotNull World world, @NotNull Random random, int x, int z, @NotNull BiomeGrid biome);
ConfigPack getConfigPack();
TerraPlugin getMain();
Sampler createSampler(int chunkX, int chunkZ, BiomeProvider provider, World world, int elevationSmooth);
List<TerraBlockPopulator> getPopulators();
}