A little refactoring

This commit is contained in:
Aleksey 2021-01-12 11:30:31 +03:00
parent a2d7a5f7c8
commit 0ffbb1c8f2
2 changed files with 75 additions and 69 deletions

View file

@ -161,6 +161,14 @@ public class MHelper {
return i * i;
}
public static float pow2(float f) {
return f * f;
}
public static double pow2(double d) {
return d * d;
}
public static int fromHSBtoRGB(float hue, float saturation, float brightness) {
int red = 0;
int green = 0;

View file

@ -48,7 +48,7 @@ public class LakePiece extends BasePiece {
this.center = center;
this.radius = radius;
this.depth = depth;
this.r2 = radius * radius;
this.r2 = MHelper.pow2(radius);
this.seed1 = random.nextInt();
this.seed2 = random.nextInt();
this.noise1 = new OpenSimplexNoise(this.seed1);
@ -77,7 +77,7 @@ public class LakePiece extends BasePiece {
center = NbtHelper.toBlockPos(tag.getCompound("center"));
radius = tag.getFloat("radius");
depth = tag.getFloat("depth");
r2 = radius * radius;
r2 = MHelper.pow2(radius);
seed1 = tag.getInt("seed1");
seed2 = tag.getInt("seed2");
noise1 = new OpenSimplexNoise(seed1);
@ -94,15 +94,14 @@ public class LakePiece extends BasePiece {
Heightmap map = chunk.getHeightmap(Type.WORLD_SURFACE_WG);
for (int x = 0; x < 16; x++) {
int px = x + sx;
int px2 = px - center.getX();
px2 *= px2;
int px2 = MHelper.pow2(px - center.getX());
pos.setX(x);
for (int z = 0; z < 16; z++) {
int pz = z + sz;
int pz2 = pz - center.getZ();
pz2 *= pz2;
int pz2 = MHelper.pow2(pz - center.getZ());
float dist = px2 + pz2;
if (dist < r2) {
if (dist > r2) continue;
pos.setZ(z);
dist = 1 - dist / r2;
int maxY = map.get(x, z);
@ -176,7 +175,6 @@ public class LakePiece extends BasePiece {
}
}
}
}
map = chunk.getHeightmap(Type.WORLD_SURFACE);