mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-04-17 22:00:08 +00:00
Clean up imports
This commit is contained in:
@@ -13,6 +13,7 @@ import java.util.Random;
|
||||
public class GridSpawn {
|
||||
private final int separation;
|
||||
private final int width;
|
||||
|
||||
public GridSpawn(int width, int separation) {
|
||||
this.separation = separation;
|
||||
this.width = width;
|
||||
@@ -20,17 +21,18 @@ public class GridSpawn {
|
||||
|
||||
/**
|
||||
* Get nearest spawn point
|
||||
* @param x X coordinate
|
||||
* @param z Z coordinate
|
||||
*
|
||||
* @param x X coordinate
|
||||
* @param z Z coordinate
|
||||
* @param seed Seed for RNG
|
||||
* @return Vector representing nearest spawnpoint
|
||||
*/
|
||||
public Vector getNearestSpawn(int x, int z, long seed) {
|
||||
int structureChunkX = x / (width + 2*separation);
|
||||
int structureChunkZ = z / (width + 2*separation);
|
||||
int structureChunkX = x / (width + 2 * separation);
|
||||
int structureChunkZ = z / (width + 2 * separation);
|
||||
List<Vector> zones = new ArrayList<>();
|
||||
for(int xi = structureChunkX-1; xi <= structureChunkX+1; xi++) {
|
||||
for(int zi = structureChunkZ-1; zi <= structureChunkZ+1; zi++) {
|
||||
for(int xi = structureChunkX - 1; xi <= structureChunkX + 1; xi++) {
|
||||
for(int zi = structureChunkZ - 1; zi <= structureChunkZ + 1; zi++) {
|
||||
zones.add(getChunkSpawn(xi, zi, seed));
|
||||
}
|
||||
}
|
||||
@@ -44,17 +46,18 @@ public class GridSpawn {
|
||||
|
||||
/**
|
||||
* Get the X/Z coordinates of the spawn point in the nearest Chunk (not Minecraft chunk)
|
||||
*
|
||||
* @param structureChunkX Chunk X coordinate
|
||||
* @param structureChunkZ Chunk Z coordinate
|
||||
* @param seed Seed for RNG
|
||||
* @param seed Seed for RNG
|
||||
* @return Vector representing spawnpoint
|
||||
*/
|
||||
public Vector getChunkSpawn(int structureChunkX, int structureChunkZ, long seed) {
|
||||
Random r = new Random(MathUtil.getCarverChunkSeed(structureChunkX, structureChunkZ, seed));
|
||||
int offsetX = r.nextInt(width);
|
||||
int offsetZ = r.nextInt(width);
|
||||
int sx = structureChunkX * (width + 2*separation) + offsetX;
|
||||
int sz = structureChunkZ * (width + 2*separation) + offsetZ;
|
||||
int sx = structureChunkX * (width + 2 * separation) + offsetX;
|
||||
int sz = structureChunkZ * (width + 2 * separation) + offsetZ;
|
||||
return new Vector(sx, 0, sz);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package com.dfsek.terra.procgen.math;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
/**
|
||||
* oh yeah
|
||||
*/
|
||||
@@ -11,6 +9,7 @@ public class Vector2 implements Cloneable {
|
||||
|
||||
/**
|
||||
* Create a vector with a given X and Z component
|
||||
*
|
||||
* @param x X component
|
||||
* @param z Z component
|
||||
*/
|
||||
@@ -21,6 +20,7 @@ public class Vector2 implements Cloneable {
|
||||
|
||||
/**
|
||||
* Get X component
|
||||
*
|
||||
* @return X component
|
||||
*/
|
||||
public double getX() {
|
||||
@@ -29,6 +29,7 @@ public class Vector2 implements Cloneable {
|
||||
|
||||
/**
|
||||
* Get Z component
|
||||
*
|
||||
* @return Z component
|
||||
*/
|
||||
public double getZ() {
|
||||
@@ -37,36 +38,40 @@ public class Vector2 implements Cloneable {
|
||||
|
||||
/**
|
||||
* Multiply X and Z components by a value.
|
||||
*
|
||||
* @param m Value to multiply
|
||||
* @return Mutated vector, for chaining.
|
||||
*/
|
||||
public Vector2 multiply(double m) {
|
||||
x*=m;
|
||||
z*=m;
|
||||
x *= m;
|
||||
z *= m;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Divide X and Z components by a value.
|
||||
*
|
||||
* @param d Divisor
|
||||
* @return Mutated vector, for chaining.
|
||||
*/
|
||||
public Vector2 divide(double d) {
|
||||
x/=d;
|
||||
z/=d;
|
||||
x /= d;
|
||||
z /= d;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the squared length of this Vector
|
||||
*
|
||||
* @return squared length
|
||||
*/
|
||||
public double lengthSquared() {
|
||||
return x*x+z*z;
|
||||
return x * x + z * z;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the length of this Vector
|
||||
*
|
||||
* @return length
|
||||
*/
|
||||
public double length() {
|
||||
@@ -75,28 +80,31 @@ public class Vector2 implements Cloneable {
|
||||
|
||||
/**
|
||||
* Add this vector to another.
|
||||
*
|
||||
* @param other Vector to add
|
||||
* @return Mutated vector, for chaining.
|
||||
*/
|
||||
public Vector2 add(Vector2 other) {
|
||||
x+=other.x;
|
||||
z+=other.z;
|
||||
x += other.x;
|
||||
z += other.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Subtract a vector from this vector,
|
||||
*
|
||||
* @param other Vector to subtract
|
||||
* @return Mutated vector, for chaining.
|
||||
*/
|
||||
public Vector2 subtract(Vector2 other) {
|
||||
x-=other.x;
|
||||
z-=other.z;
|
||||
x -= other.x;
|
||||
z -= other.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalize this vector to length 1
|
||||
*
|
||||
* @return Mutated vector, for chaining.
|
||||
*/
|
||||
public Vector2 normalize() {
|
||||
@@ -106,6 +114,7 @@ public class Vector2 implements Cloneable {
|
||||
|
||||
/**
|
||||
* Get the distance from this vector to another.
|
||||
*
|
||||
* @param other Another vector
|
||||
* @return Distance between vectors
|
||||
*/
|
||||
@@ -115,6 +124,7 @@ public class Vector2 implements Cloneable {
|
||||
|
||||
/**
|
||||
* Get the squared distance between 2 vectors.
|
||||
*
|
||||
* @param other Another vector
|
||||
* @return Squared distance
|
||||
*/
|
||||
@@ -126,7 +136,7 @@ public class Vector2 implements Cloneable {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (!(obj instanceof Vector2)) {
|
||||
if(! (obj instanceof Vector2)) {
|
||||
return false;
|
||||
}
|
||||
Vector2 other = (Vector2) obj;
|
||||
@@ -150,7 +160,7 @@ public class Vector2 implements Cloneable {
|
||||
public Vector2 clone() {
|
||||
try {
|
||||
return (Vector2) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
} catch(CloneNotSupportedException e) {
|
||||
throw new Error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,6 @@ package com.dfsek.terra.procgen.pixel;
|
||||
|
||||
public class Distribution {
|
||||
public Distribution(Rectangle bound, int numPoints, double minRad) {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@ import java.util.Set;
|
||||
public class Rectangle extends Polygon {
|
||||
private Vector2 min;
|
||||
private Vector2 max;
|
||||
|
||||
public Rectangle(Vector2 min, Vector2 max) {
|
||||
this.max = new Vector2(Math.min(min.getX(), max.getX()), Math.min(min.getZ(), max.getZ()));
|
||||
this.min = new Vector2(Math.max(min.getX(), max.getX()), Math.max(min.getZ(), max.getZ()));;
|
||||
this.min = new Vector2(Math.max(min.getX(), max.getX()), Math.max(min.getZ(), max.getZ()));
|
||||
;
|
||||
}
|
||||
|
||||
public Rectangle(Vector2 center, double xRadius, double zRadius) {
|
||||
Vector2 rad = new Vector2(xRadius, zRadius);
|
||||
this.min = center.clone().subtract(rad);
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package com.dfsek.terra.procgen.voxel;
|
||||
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.polydev.gaea.math.FastNoiseLite;
|
||||
|
||||
public class DeformedSphere extends VoxelGeometry {
|
||||
public DeformedSphere(Vector start, int rad, double deform, FastNoiseLite noise) {
|
||||
for(int x = -rad; x <= rad; x++) {
|
||||
for(int y = -rad; y <= rad; y++) {
|
||||
for(int z = -rad; z <= rad; z++) {
|
||||
for(int x = - rad; x <= rad; x++) {
|
||||
for(int y = - rad; y <= rad; y++) {
|
||||
for(int z = - rad; z <= rad; z++) {
|
||||
Vector c = new Vector(x, y, z);
|
||||
if(c.length() < (rad + 0.5) * ((noise.getNoise(x, y, z)+1)*deform)) {
|
||||
if(c.length() < (rad + 0.5) * ((noise.getNoise(x, y, z) + 1) * deform)) {
|
||||
addVector(c.add(start));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
package com.dfsek.terra.procgen.voxel;
|
||||
|
||||
import org.bukkit.util.Vector;
|
||||
import org.polydev.gaea.math.FastNoiseLite;
|
||||
|
||||
public class Sphere extends VoxelGeometry {
|
||||
public Sphere(Vector start, int rad) {
|
||||
for(int x = -rad; x <= rad; x++) {
|
||||
for(int y = -rad; y <= rad; y++) {
|
||||
for(int z = -rad; z <= rad; z++) {
|
||||
for(int x = - rad; x <= rad; x++) {
|
||||
for(int y = - rad; y <= rad; y++) {
|
||||
for(int z = - rad; z <= rad; z++) {
|
||||
Vector c = new Vector(x, y, z);
|
||||
if(c.length() < rad + 0.5) {
|
||||
addVector(c.add(start));
|
||||
|
||||
@@ -19,7 +19,9 @@ public abstract class VoxelGeometry {
|
||||
public void merge(VoxelGeometry other) {
|
||||
geometry.addAll(other.geometry);
|
||||
}
|
||||
|
||||
public static VoxelGeometry getBlank() {
|
||||
return new VoxelGeometry() {};
|
||||
return new VoxelGeometry() {
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user