make worldgen classes server side

This commit is contained in:
Sen 2025-07-24 22:49:22 +02:00
parent 4de4f41a5d
commit d56f28e6d2
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
69 changed files with 1018 additions and 1809 deletions

View file

@ -1,27 +0,0 @@
package common.biome;
public final class Biome {
public final float temperature;
public final float humidity;
public final float depth;
public final float scale;
public final float factor;
public int id;
public Biome(float temperature, float humidity, float depth, float scale) {
this.temperature = temperature;
this.humidity = humidity;
this.depth = depth;
this.scale = scale;
this.factor = Math.min(humidity * 0.01f * ((temperature + 14.0f) / 40.0f + 0.15f), 1.0f);
}
public Biome(float temperature, float humidity, Scaling scaling) {
this(temperature, humidity, scaling.depth, scaling.scale);
}
public Biome(float temperature, float humidity) {
this(temperature, humidity, Scaling.VARYING_LOW);
}
}

View file

@ -1,28 +0,0 @@
package common.biome;
public enum Scaling {
VARYING_LOW(0.1F, 0.2F),
VARYING_MEDIUM(0.1F, 1.0F),
VARYING_CHAOTIC(1.0F, 2.0F),
SEA_VARYING(0.1F, 0.8F),
SEA_SHORE(0.0F, 0.025F),
SEA_POND(-0.2F, 0.1F),
SEA_SHALLOW(-0.5F, 0.0F),
SEA_MEDIUM(-1.0F, 0.1F),
SEA_DEEP(-1.8F, 0.1F),
PLAINS_LOW(0.125F, 0.05F),
PLAINS_MEDIUM(0.2F, 0.2F),
PLAINS_VARYING(0.2F, 0.3F),
HILLS_LOW(0.45F, 0.3F),
HILLS_MEDIUM(0.8F, 0.3F),
HILLS_LARGE(1.0F, 0.5F),
HILLS_PLATEAU(1.5F, 0.025F);
public final float depth;
public final float scale;
private Scaling(float depth, float scale) {
this.depth = depth;
this.scale = scale;
}
}

View file

@ -1,5 +1,7 @@
package common.dimension;
import common.world.State;
public final class Area extends Dimension {
public static int widthToSize(int width) {
int size = width / 2;
@ -10,14 +12,15 @@ public final class Area extends Dimension {
super(true);
}
public Area(int sky, int fog, int width, float temperature, int brightness) {
public Area(int sky, int fog, int width, float temperature, int brightness, State surface, State liquid, int seaLevel) {
super(false);
this.setPhysics(widthToSize(width), 1L, 1L, 0.0f, 10.0f, temperature, brightness);
this.setSkyColor(sky).setFogColor(fog);
this.setComposition(surface, liquid, seaLevel);
}
public Area(int color, int width, float temperature, int brightness) {
this(color, color, width, temperature, brightness);
public Area(int color, int width, float temperature, int brightness, State surface, State liquid, int seaLevel) {
this(color, color, width, temperature, brightness, surface, liquid, seaLevel);
}
public final DimType getType() {

File diff suppressed because it is too large Load diff

View file

@ -1,7 +0,0 @@
package common.dimension;
public final class Domain extends Section {
public Domain(boolean custom) {
super(custom);
}
}

View file

@ -1,7 +0,0 @@
package common.dimension;
public final class Galaxy extends Section {
public Galaxy(boolean custom) {
super(custom);
}
}

View file

@ -1,6 +0,0 @@
package common.dimension;
import common.world.State;
public record Lake(State state, State filler, State top, int chance, int minHeight, int maxHeight, boolean ratiod) {
}

View file

@ -1,6 +0,0 @@
package common.dimension;
import common.world.State;
public record Liquid(State state, int chance, int minHeight, int maxHeight, boolean lower) {
}

View file

@ -8,20 +8,20 @@ public final class Moon extends Dimension {
super(true);
}
public Moon(int sky, int fog, int radius, long orbit, long rotation, float gravity, float temperature, int brightness, Block surface, Block liquid, float depth, float scale) {
public Moon(int sky, int fog, int radius, long orbit, long rotation, float gravity, float temperature, int brightness, Block surface, Block liquid) {
super(false);
this.setPhysics(Planet.radiusToSize(Math.min(radius, 26000000)), orbit, rotation, 0.0f, gravity, temperature, brightness);
this.setStarBrightness(0.75f).setDeepStarBrightness(0.75f);
this.setSkyColor(sky).setFogColor(fog);
this.setPerlinGen(surface.getState(), liquid.getState(), 63, depth, scale);
this.setComposition(surface.getState(), liquid.getState(), 63);
}
public Moon(int color, int radius, long orbit, long rotation, float gravity, float temperature, Block surface, Block liquid, float depth, float scale) {
this(color, color, radius, orbit, rotation, gravity, temperature, 8, surface, liquid, depth, scale);
public Moon(int color, int radius, long orbit, long rotation, float gravity, float temperature, Block surface, Block liquid) {
this(color, color, radius, orbit, rotation, gravity, temperature, 8, surface, liquid);
}
public Moon(int radius, long orbit, long rotation, float gravity, float temperature) {
this(0x333333, radius, orbit, rotation, gravity, temperature, Blocks.moon_rock, Blocks.air, 0.125F, 0.05F);
this(0x333333, radius, orbit, rotation, gravity, temperature, Blocks.moon_rock, Blocks.air);
}
public Moon(int radius, long orbitRotation, float gravity, float temperature) {

View file

@ -1,6 +0,0 @@
package common.dimension;
import common.world.State;
public record Ore(State state, int count, int more, int size, int min, int max, boolean dist) {
}

View file

@ -1,5 +1,7 @@
package common.dimension;
import common.world.State;
public final class Planet extends Dimension {
public static int radiusToSize(int radius) {
int size = (int)(Math.sqrt((double)radius * (double)radius * 4.0 * Math.PI) / 2.0);
@ -11,33 +13,34 @@ public final class Planet extends Dimension {
}
public Planet(int sky, int fog, int clouds, int radius, long orbit, long rotation, float gravity, float temperature,
int brightness) {
this(sky, fog, clouds, radius, orbit, rotation, 0.0f, gravity, temperature, brightness);
int brightness, State surface, State liquid, int seaLevel) {
this(sky, fog, clouds, radius, orbit, rotation, 0.0f, gravity, temperature, brightness, surface, liquid, seaLevel);
}
public Planet(int sky, int fog, int clouds, int radius, long orbit, long rotation, float offset, float gravity,
float temperature) {
this(sky, fog, clouds, radius, orbit, rotation, offset, gravity, temperature, 0);
float temperature, State surface, State liquid, int seaLevel) {
this(sky, fog, clouds, radius, orbit, rotation, offset, gravity, temperature, 0, surface, liquid, seaLevel);
}
public Planet(int radius, long orbit, long rotation, float offset, float gravity, float temperature) {
this(0x7aa7ff, 0xc0d8ff, 0xffffff, radius, orbit, rotation, offset, gravity, temperature, 0);
public Planet(int radius, long orbit, long rotation, float offset, float gravity, float temperature, State surface, State liquid, int seaLevel) {
this(0x7aa7ff, 0xc0d8ff, 0xffffff, radius, orbit, rotation, offset, gravity, temperature, 0, surface, liquid, seaLevel);
}
public Planet(int sky, int fog, int clouds, int radius, long orbit, long rotation, float gravity, float temperature) {
this(sky, fog, clouds, radius, orbit, rotation, 0.0f, gravity, temperature, 0);
public Planet(int sky, int fog, int clouds, int radius, long orbit, long rotation, float gravity, float temperature, State surface, State liquid, int seaLevel) {
this(sky, fog, clouds, radius, orbit, rotation, 0.0f, gravity, temperature, 0, surface, liquid, seaLevel);
}
public Planet(int radius, long orbit, long rotation, float gravity, float temperature) {
this(radius, orbit, rotation, 0.0f, gravity, temperature);
public Planet(int radius, long orbit, long rotation, float gravity, float temperature, State surface, State liquid, int seaLevel) {
this(radius, orbit, rotation, 0.0f, gravity, temperature, surface, liquid, seaLevel);
}
public Planet(int sky, int fog, int clouds, int radius, long orbit, long rotation, float offset, float gravity,
float temperature, int brightness) {
float temperature, int brightness, State surface, State liquid, int seaLevel) {
super(false);
this.setPhysics(radiusToSize(Math.min(radius, 36750000)), orbit, rotation, offset, gravity, temperature, brightness);
this.setStarBrightness(0.5f).setDeepStarBrightness(0.0f);
this.setSkyColor(sky).setFogColor(fog).setCloudColor(clouds);
this.setComposition(surface, liquid, seaLevel);
}
public final DimType getType() {

View file

@ -1,17 +0,0 @@
package common.dimension;
import common.entity.types.EntityLiving;
import common.rng.RngItem;
public class RngSpawn extends RngItem {
public final Class<? extends EntityLiving> type;
public final int min;
public final int max;
public RngSpawn(Class<? extends EntityLiving> type, int weight, int min, int max) {
super(weight);
this.type = type;
this.min = min;
this.max = max;
}
}

View file

@ -1,7 +0,0 @@
package common.dimension;
public final class Sector extends Section {
public Sector(boolean custom) {
super(custom);
}
}

View file

@ -1,19 +1,23 @@
package common.dimension;
import common.block.Block;
import common.world.State;
public final class Semi extends Dimension {
Semi() {
super(true);
}
public Semi(int sky, int fog, int clouds, int width, float temperature, int brightness) {
public Semi(int sky, int fog, int clouds, int width, float temperature, int brightness, State surface, State liquid, int seaLevel) {
super(false);
this.setPhysics(Area.widthToSize(width), 1L, 1L, 0.0f, 10.0f, temperature, brightness);
this.setStarBrightness(0.5f).setDeepStarBrightness(0.5f);
this.setSkyColor(sky).setFogColor(fog).setCloudColor(clouds);
this.setComposition(surface, liquid, seaLevel);
}
public Semi(int color, int clouds, int width, float temperature, int brightness) {
this(color, color, clouds, width, temperature, brightness);
public Semi(int color, int clouds, int width, float temperature, int brightness, State surface, State liquid, int seaLevel) {
this(color, color, clouds, width, temperature, brightness, surface, liquid, seaLevel);
}
public final DimType getType() {

View file

@ -1,5 +1,6 @@
package common.dimension;
import common.init.Blocks;
import common.world.World;
public final class Space extends Dimension {
@ -8,7 +9,8 @@ public final class Space extends Dimension {
private Space() {
super(false);
this.setPhysics(World.MAX_SIZE, 1L, 1L, 0.0f, 0.0f, 2.7f, 15);
this.setStarBrightness(1.0f).setDeepStarBrightness(1.0f).setPopulator(PopulatorType.ASTEROIDS);
this.setStarBrightness(1.0f).setDeepStarBrightness(1.0f);
this.setComposition(Blocks.air.getState(), Blocks.air.getState(), 0);
}
public final DimType getType() {

View file

@ -12,7 +12,7 @@ public final class Star extends Dimension {
super(false);
this.setPhysics(Planet.radiusToSize(Math.min(radius, 945000000) / 25), 1L, 96000L, 0.0f, gravity, temp, 15);
this.setStarBrightness(0.75f).setDeepStarBrightness(0.75f);
this.setSkyColor(color).setFogColor(color).setFlatGen(filler.getState(), 128);
this.setSkyColor(color).setFogColor(color).setComposition(filler.getState(), Blocks.air.getState(), 128);
}
public Star(int radius, float gravity, float temp) {

View file

@ -1,182 +0,0 @@
package common.rng;
class ImprovedGen {
private static final double[] dir3X = new double[] { 1.0D, -1.0D, 1.0D, -1.0D, 1.0D, -1.0D, 1.0D, -1.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 0.0D,
-1.0D, 0.0D };
private static final double[] dir3Y = new double[] { 1.0D, 1.0D, -1.0D, -1.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, -1.0D, 1.0D, -1.0D, 1.0D, -1.0D,
1.0D, -1.0D };
private static final double[] dir3Z = new double[] { 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 1.0D, -1.0D, -1.0D, 1.0D, 1.0D, -1.0D, -1.0D, 0.0D, 1.0D, 0.0D,
-1.0D };
private static final double[] dir2X = new double[] { 1.0D, -1.0D, 1.0D, -1.0D, 1.0D, -1.0D, 1.0D, -1.0D, 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 0.0D,
-1.0D, 0.0D };
private static final double[] dir2Z = new double[] { 0.0D, 0.0D, 0.0D, 0.0D, 1.0D, 1.0D, -1.0D, -1.0D, 1.0D, 1.0D, -1.0D, -1.0D, 0.0D, 1.0D, 0.0D,
-1.0D };
private final int[] permutations;
private final double xCoord;
private final double yCoord;
private final double zCoord;
protected ImprovedGen(Random random) {
this.permutations = new int[512];
this.xCoord = random.doublev() * 256.0D;
this.yCoord = random.doublev() * 256.0D;
this.zCoord = random.doublev() * 256.0D;
for(int n = 0; n < 256; this.permutations[n] = n++) {
;
}
for(int n = 0; n < 256; ++n) {
int pos = random.zrange(256 - n) + n;
int value = this.permutations[n];
this.permutations[n] = this.permutations[pos];
this.permutations[pos] = value;
this.permutations[n + 256] = this.permutations[n];
}
}
private final double lerp(double d, double n, double m) {
return n + d * (m - n);
}
private final double grad(int n, double xm, double zm) {
int i = n & 15;
return dir2X[i] * xm + dir2Z[i] * zm;
}
private final double grad(int n, double xm, double ym, double zm) {
int i = n & 15;
return dir3X[i] * xm + dir3Y[i] * ym + dir3Z[i] * zm;
}
/**
* noiseArray should be xSize*ySize*zSize in size
*/
public void generate(double[] noise, double xoff, double yoff, double zoff, int xsize, int ysize, int zsize, double xscale, double yscale,
double zscale, double scale) {
if(ysize == 1) {
int i5 = 0;
int j5 = 0;
int j = 0;
int k5 = 0;
double d14 = 0.0D;
double d15 = 0.0D;
int l5 = 0;
double d16 = 1.0D / scale;
for(int j2 = 0; j2 < xsize; ++j2) {
double d17 = xoff + (double)j2 * xscale + this.xCoord;
int i6 = (int)d17;
if(d17 < (double)i6) {
--i6;
}
int k2 = i6 & 255;
d17 = d17 - (double)i6;
double d18 = d17 * d17 * d17 * (d17 * (d17 * 6.0D - 15.0D) + 10.0D);
for(int j6 = 0; j6 < zsize; ++j6) {
double d19 = zoff + (double)j6 * zscale + this.zCoord;
int k6 = (int)d19;
if(d19 < (double)k6) {
--k6;
}
int l6 = k6 & 255;
d19 = d19 - (double)k6;
double d20 = d19 * d19 * d19 * (d19 * (d19 * 6.0D - 15.0D) + 10.0D);
i5 = this.permutations[k2] + 0;
j5 = this.permutations[i5] + l6;
j = this.permutations[k2 + 1] + 0;
k5 = this.permutations[j] + l6;
d14 = this.lerp(d18, this.grad(this.permutations[j5], d17, d19), this.grad(this.permutations[k5], d17 - 1.0D, 0.0D, d19));
d15 = this.lerp(d18, this.grad(this.permutations[j5 + 1], d17, 0.0D, d19 - 1.0D),
this.grad(this.permutations[k5 + 1], d17 - 1.0D, 0.0D, d19 - 1.0D));
double d21 = this.lerp(d20, d14, d15);
int i7 = l5++;
noise[i7] += d21 * d16;
}
}
}
else {
int i = 0;
double d0 = 1.0D / scale;
int k = -1;
int l = 0;
int i1 = 0;
int j1 = 0;
int k1 = 0;
int l1 = 0;
int i2 = 0;
double d1 = 0.0D;
double d2 = 0.0D;
double d3 = 0.0D;
double d4 = 0.0D;
for(int l2 = 0; l2 < xsize; ++l2) {
double d5 = xoff + (double)l2 * xscale + this.xCoord;
int i3 = (int)d5;
if(d5 < (double)i3) {
--i3;
}
int j3 = i3 & 255;
d5 = d5 - (double)i3;
double d6 = d5 * d5 * d5 * (d5 * (d5 * 6.0D - 15.0D) + 10.0D);
for(int k3 = 0; k3 < zsize; ++k3) {
double d7 = zoff + (double)k3 * zscale + this.zCoord;
int l3 = (int)d7;
if(d7 < (double)l3) {
--l3;
}
int i4 = l3 & 255;
d7 = d7 - (double)l3;
double d8 = d7 * d7 * d7 * (d7 * (d7 * 6.0D - 15.0D) + 10.0D);
for(int j4 = 0; j4 < ysize; ++j4) {
double d9 = yoff + (double)j4 * yscale + this.yCoord;
int k4 = (int)d9;
if(d9 < (double)k4) {
--k4;
}
int l4 = k4 & 255;
d9 = d9 - (double)k4;
double d10 = d9 * d9 * d9 * (d9 * (d9 * 6.0D - 15.0D) + 10.0D);
if(j4 == 0 || l4 != k) {
k = l4;
l = this.permutations[j3] + l4;
i1 = this.permutations[l] + i4;
j1 = this.permutations[l + 1] + i4;
k1 = this.permutations[j3 + 1] + l4;
l1 = this.permutations[k1] + i4;
i2 = this.permutations[k1 + 1] + i4;
d1 = this.lerp(d6, this.grad(this.permutations[i1], d5, d9, d7), this.grad(this.permutations[l1], d5 - 1.0D, d9, d7));
d2 = this.lerp(d6, this.grad(this.permutations[j1], d5, d9 - 1.0D, d7),
this.grad(this.permutations[i2], d5 - 1.0D, d9 - 1.0D, d7));
d3 = this.lerp(d6, this.grad(this.permutations[i1 + 1], d5, d9, d7 - 1.0D),
this.grad(this.permutations[l1 + 1], d5 - 1.0D, d9, d7 - 1.0D));
d4 = this.lerp(d6, this.grad(this.permutations[j1 + 1], d5, d9 - 1.0D, d7 - 1.0D),
this.grad(this.permutations[i2 + 1], d5 - 1.0D, d9 - 1.0D, d7 - 1.0D));
}
double d11 = this.lerp(d10, d1, d2);
double d12 = this.lerp(d10, d3, d4);
double d13 = this.lerp(d8, d11, d12);
int j7 = i++;
noise[j7] += d13 * d0;
}
}
}
}
}
}

View file

@ -1,155 +0,0 @@
package common.rng;
class ImprovedGenOld {
private final int permutations[];
private final double xCoord;
private final double yCoord;
private final double zCoord;
protected ImprovedGenOld(Random random) {
this.permutations = new int[512];
this.xCoord = random.doublev() * 256D;
this.yCoord = random.doublev() * 256D;
this.zCoord = random.doublev() * 256D;
for(int n = 0; n < 256; n++) {
this.permutations[n] = n;
}
for(int n = 0; n < 256; n++) {
int pos = random.zrange(256 - n) + n;
int value = this.permutations[n];
this.permutations[n] = this.permutations[pos];
this.permutations[pos] = value;
this.permutations[n + 256] = this.permutations[n];
}
}
private final double lerp(double d, double n, double m) {
return n + d * (m - n);
}
private final double grad(int n, double xm, double zm) {
int i = n & 0xf;
double v = (double)(1 - ((i & 8) >> 3)) * xm;
double m = i >= 4 ? i != 12 && i != 14 ? zm : xm : 0.0D;
return ((i & 1) != 0 ? -v : v) + ((i & 2) != 0 ? -m : m);
}
private final double grad(int n, double xm, double ym, double zm) {
int i = n & 0xf;
double v = i >= 8 ? ym : xm;
double m = i >= 4 ? i != 12 && i != 14 ? zm : xm : ym;
return ((i & 1) != 0 ? -v : v) + ((i & 2) != 0 ? -m : m);
}
public void generate(double noise[], double xoff, double yoff, double zoff, int xsize, int ysize, int zsize, double xscale, double yscale,
double zscale, double scale) {
if(ysize == 1) {
boolean flag = false;
boolean flag1 = false;
boolean flag2 = false;
boolean flag3 = false;
double d8 = 0.0D;
double d10 = 0.0D;
int j3 = 0;
double d12 = 1.0D / scale;
for(int i4 = 0; i4 < xsize; i4++) {
double d14 = (xoff + (double)i4) * xscale + this.xCoord;
int j4 = (int)d14;
if(d14 < (double)j4) {
j4--;
}
int k4 = j4 & 0xff;
d14 -= j4;
double d17 = d14 * d14 * d14 * (d14 * (d14 * 6D - 15D) + 10D);
for(int l4 = 0; l4 < zsize; l4++) {
double d19 = (zoff + (double)l4) * zscale + this.zCoord;
int j5 = (int)d19;
if(d19 < (double)j5) {
j5--;
}
int l5 = j5 & 0xff;
d19 -= j5;
double d21 = d19 * d19 * d19 * (d19 * (d19 * 6D - 15D) + 10D);
int l = this.permutations[k4] + 0;
int j1 = this.permutations[l] + l5;
int k1 = this.permutations[k4 + 1] + 0;
int l1 = this.permutations[k1] + l5;
double d9 = lerp(d17, grad(this.permutations[j1], d14, d19), grad(this.permutations[l1], d14 - 1.0D, 0.0D, d19));
double d11 = lerp(d17, grad(this.permutations[j1 + 1], d14, 0.0D, d19 - 1.0D),
grad(this.permutations[l1 + 1], d14 - 1.0D, 0.0D, d19 - 1.0D));
double d23 = lerp(d21, d9, d11);
noise[j3++] += d23 * d12;
}
}
return;
}
int i1 = 0;
double d7 = 1.0D / scale;
int i2 = -1;
boolean flag4 = false;
boolean flag5 = false;
boolean flag6 = false;
boolean flag7 = false;
boolean flag8 = false;
boolean flag9 = false;
double d13 = 0.0D;
double d15 = 0.0D;
double d16 = 0.0D;
double d18 = 0.0D;
for(int i5 = 0; i5 < xsize; i5++) {
double d20 = (xoff + (double)i5) * xscale + this.xCoord;
int k5 = (int)d20;
if(d20 < (double)k5) {
k5--;
}
int i6 = k5 & 0xff;
d20 -= k5;
double d22 = d20 * d20 * d20 * (d20 * (d20 * 6D - 15D) + 10D);
for(int j6 = 0; j6 < zsize; j6++) {
double d24 = (zoff + (double)j6) * zscale + this.zCoord;
int k6 = (int)d24;
if(d24 < (double)k6) {
k6--;
}
int l6 = k6 & 0xff;
d24 -= k6;
double d25 = d24 * d24 * d24 * (d24 * (d24 * 6D - 15D) + 10D);
for(int i7 = 0; i7 < ysize; i7++) {
double d26 = (yoff + (double)i7) * yscale + this.yCoord;
int j7 = (int)d26;
if(d26 < (double)j7) {
j7--;
}
int k7 = j7 & 0xff;
d26 -= j7;
double d27 = d26 * d26 * d26 * (d26 * (d26 * 6D - 15D) + 10D);
if(i7 == 0 || k7 != i2) {
i2 = k7;
int j2 = this.permutations[i6] + k7;
int k2 = this.permutations[j2] + l6;
int l2 = this.permutations[j2 + 1] + l6;
int i3 = this.permutations[i6 + 1] + k7;
int k3 = this.permutations[i3] + l6;
int l3 = this.permutations[i3 + 1] + l6;
d13 = lerp(d22, grad(this.permutations[k2], d20, d26, d24), grad(this.permutations[k3], d20 - 1.0D, d26, d24));
d15 = lerp(d22, grad(this.permutations[l2], d20, d26 - 1.0D, d24), grad(this.permutations[l3], d20 - 1.0D, d26 - 1.0D, d24));
d16 = lerp(d22, grad(this.permutations[k2 + 1], d20, d26, d24 - 1.0D), grad(this.permutations[k3 + 1], d20 - 1.0D, d26, d24 - 1.0D));
d18 = lerp(d22, grad(this.permutations[l2 + 1], d20, d26 - 1.0D, d24 - 1.0D),
grad(this.permutations[l3 + 1], d20 - 1.0D, d26 - 1.0D, d24 - 1.0D));
}
double d28 = lerp(d27, d13, d15);
double d29 = lerp(d27, d16, d18);
double d30 = lerp(d25, d28, d29);
noise[i1++] += d30 * d7;
}
}
}
}
}

View file

@ -1,10 +0,0 @@
package common.rng;
public abstract class NoiseGen {
public abstract void generate(double[] noise, int xoff, int yoff, int zoff, int xsize, int ysize, int zsize, double xscale, double yscale,
double zscale);
public final void generate(double[] noise, int xoff, int zoff, int xsize, int zsize, double xscale, double zscale, double ue) {
this.generate(noise, xoff, 10, zoff, xsize, 1, zsize, xscale, 1.0D, zscale);
}
}

View file

@ -1,52 +0,0 @@
package common.rng;
public class OctaveGen extends NoiseGen {
private final ImprovedGen[] generators;
private final int octaves;
private static long floorLong(double value) {
long i = (long)value;
return value < (double)i ? i - 1L : i;
}
public OctaveGen(Random random, int octs) {
this.octaves = octs;
this.generators = new ImprovedGen[octs];
for(int n = 0; n < octs; ++n) {
this.generators[n] = new ImprovedGen(random);
}
}
public void generate(double[] noise, int xoff, int yoff, int zoff, int xsize, int ysize, int zsize, double xscale, double yscale,
double zscale) {
// if(noise == null) {
// noise = new double[xsize * ysize * zsize];
// }
// else {
for(int n = 0; n < noise.length; ++n) {
noise[n] = 0.0D;
}
// }
double factor = 1.0D;
for(int n = 0; n < this.octaves; ++n) {
double xo = (double)xoff * factor * xscale;
double yo = (double)yoff * factor * yscale;
double zo = (double)zoff * factor * zscale;
long xn = floorLong(xo);
long zn = floorLong(zo);
xo = xo - (double)xn;
zo = zo - (double)zn;
xn = xn % 16777216L;
zn = zn % 16777216L;
xo = xo + (double)xn;
zo = zo + (double)zn;
this.generators[n].generate(noise, xo, yo, zo, xsize, ysize, zsize, xscale * factor, yscale * factor, zscale * factor, factor);
factor /= 2.0D;
}
// return noise;
}
}

View file

@ -1,35 +0,0 @@
package common.rng;
public class OctaveGenOld extends NoiseGen {
private final ImprovedGenOld generators[];
private final int octaves;
public OctaveGenOld(Random random, int octs) {
this.octaves = octs;
this.generators = new ImprovedGenOld[octs];
for(int n = 0; n < octs; n++) {
this.generators[n] = new ImprovedGenOld(random);
}
}
public void generate(double noise[], int xoff, int yoff, int zoff, int xsize, int ysize, int zsize, double xscale, double yscale,
double zscale) {
// if(noise == null) {
// noise = new double[xsize * ysize * zsize];
// }
// else {
for(int n = 0; n < noise.length; n++) {
noise[n] = 0.0D;
}
//
// }
double factor = 1.0D;
for(int n = 0; n < this.octaves; n++) {
this.generators[n].generate(noise, xoff, yoff, zoff, xsize, ysize, zsize, xscale * factor, yscale * factor, zscale * factor, factor);
factor /= 2D;
}
// return noise;
}
}

View file

@ -1,42 +0,0 @@
package common.rng;
public class PerlinGen {
private final SimplexGen[] generators;
private final int iterations;
public PerlinGen(Random random, int iters) {
this.iterations = iters;
this.generators = new SimplexGen[iters];
for(int n = 0; n < iters; ++n) {
this.generators[n] = new SimplexGen(random);
}
}
public double generate(double x, double z) {
double sum = 0.0D;
double factor = 1.0D;
for(int n = 0; n < this.iterations; ++n) {
sum += this.generators[n].generate(x * factor, z * factor) / factor;
factor /= 2.0D;
}
return sum;
}
public void generate(double[] noise, double xoff, double zoff, int xsize, int zsize, double xscale, double zscale, double amp) {
double mult = 0.5D;
for(int n = 0; n < noise.length; ++n) {
noise[n] = 0.0D;
}
double div = 1.0D;
double scale = 1.0D;
for(int n = 0; n < this.iterations; ++n) {
this.generators[n].generate(noise, xoff, zoff, xsize, zsize, xscale * scale * div, zscale * scale * div, 0.55D / div);
scale *= amp;
div *= mult;
}
}
}

View file

@ -1,39 +0,0 @@
package common.rng;
public class PerlinGenOld {
private final SimplexGenOld generators[];
private final int iterations;
public PerlinGenOld(Random random, int iters) {
this.iterations = iters;
this.generators = new SimplexGenOld[iters];
for(int n = 0; n < iters; n++) {
this.generators[n] = new SimplexGenOld(random);
}
}
public void generate(double noise[], double xoff, double zoff, int xsize, int zsize, double xscale, double zscale, double amp) {
double mult = 0.5D;
xscale /= 1.5D;
zscale /= 1.5D;
// if(noise == null || noise.length < xsize * zsize) {
// noise = new double[xsize * zsize];
// }
// else {
for(int n = 0; n < noise.length; n++) {
noise[n] = 0.0D;
}
//
// }
double div = 1.0D;
double scale = 1.0D;
for(int n = 0; n < this.iterations; n++) {
this.generators[n].generate(noise, xoff, zoff, xsize, zsize, xscale * scale, zscale * scale, 0.55000000000000004D / div);
scale *= amp;
div *= mult;
}
// return noise;
}
}

View file

@ -1,185 +0,0 @@
package common.rng;
class SimplexGen {
private static final int[][] DIRS = new int[][] { { 1, 1, 0 }, { -1, 1, 0 }, { 1, -1, 0 }, { -1, -1, 0 }, { 1, 0, 1 }, { -1, 0, 1 }, { 1, 0, -1 },
{ -1, 0, -1 }, { 0, 1, 1 }, { 0, -1, 1 }, { 0, 1, -1 }, { 0, -1, -1 } };
private static final double SQ3 = Math.sqrt(3.0D);
private static final double SQ3NORM = 0.5D * (SQ3 - 1.0D);
private static final double SQ3INV = (3.0D - SQ3) / 6.0D;
private final int[] bitfield;
private final double xVar;
private final double zVar;
private final double unused1;
protected SimplexGen(Random random) {
this.bitfield = new int[512];
this.xVar = random.doublev() * 256.0D;
this.zVar = random.doublev() * 256.0D;
this.unused1 = random.doublev() * 256.0D;
for(int n = 0; n < 256; this.bitfield[n] = n++) {
;
}
for(int n = 0; n < 256; ++n) {
int pos = random.zrange(256 - n) + n;
int value = this.bitfield[n];
this.bitfield[n] = this.bitfield[pos];
this.bitfield[pos] = value;
this.bitfield[n + 256] = this.bitfield[n];
}
}
private static int floorClamp(double d) {
return d > 0.0D ? (int)d : (int)d - 1;
}
private static double multPair(int[] n, double xm, double zm) {
return (double)n[0] * xm + (double)n[1] * zm;
}
public double generate(double x, double z) {
double d3 = 0.5D * (SQ3 - 1.0D);
double d4 = (x + z) * d3;
int i = floorClamp(x + d4);
int j = floorClamp(z + d4);
double d5 = (3.0D - SQ3) / 6.0D;
double d6 = (double)(i + j) * d5;
double d7 = (double)i - d6;
double d8 = (double)j - d6;
double d9 = x - d7;
double d10 = z - d8;
int k;
int l;
if(d9 > d10) {
k = 1;
l = 0;
}
else {
k = 0;
l = 1;
}
double d11 = d9 - (double)k + d5;
double d12 = d10 - (double)l + d5;
double d13 = d9 - 1.0D + 2.0D * d5;
double d14 = d10 - 1.0D + 2.0D * d5;
int i1 = i & 255;
int j1 = j & 255;
int k1 = this.bitfield[i1 + this.bitfield[j1]] % 12;
int l1 = this.bitfield[i1 + k + this.bitfield[j1 + l]] % 12;
int i2 = this.bitfield[i1 + 1 + this.bitfield[j1 + 1]] % 12;
double d15 = 0.5D - d9 * d9 - d10 * d10;
double d0;
if(d15 < 0.0D) {
d0 = 0.0D;
}
else {
d15 = d15 * d15;
d0 = d15 * d15 * multPair(DIRS[k1], d9, d10);
}
double d16 = 0.5D - d11 * d11 - d12 * d12;
double d1;
if(d16 < 0.0D) {
d1 = 0.0D;
}
else {
d16 = d16 * d16;
d1 = d16 * d16 * multPair(DIRS[l1], d11, d12);
}
double d17 = 0.5D - d13 * d13 - d14 * d14;
double d2;
if(d17 < 0.0D) {
d2 = 0.0D;
}
else {
d17 = d17 * d17;
d2 = d17 * d17 * multPair(DIRS[i2], d13, d14);
}
return 70.0D * (d0 + d1 + d2);
}
public void generate(double[] noise, double xoff, double zoff, int xsize, int zsize, double xscale, double zscale, double amp) {
int o = 0;
for(int n1 = 0; n1 < zsize; ++n1) {
double zv = (zoff + (double)n1) * zscale + this.zVar;
for(int n2 = 0; n2 < xsize; ++n2) {
double xv = (xoff + (double)n2) * xscale + this.xVar;
double d5 = (xv + zv) * SQ3NORM;
int l = floorClamp(xv + d5);
int i1 = floorClamp(zv + d5);
double d6 = (double)(l + i1) * SQ3INV;
double d7 = (double)l - d6;
double d8 = (double)i1 - d6;
double d9 = xv - d7;
double d10 = zv - d8;
int j1;
int k1;
if(d9 > d10) {
j1 = 1;
k1 = 0;
}
else {
j1 = 0;
k1 = 1;
}
double d11 = d9 - (double)j1 + SQ3INV;
double d12 = d10 - (double)k1 + SQ3INV;
double d13 = d9 - 1.0D + 2.0D * SQ3INV;
double d14 = d10 - 1.0D + 2.0D * SQ3INV;
int l1 = l & 255;
int i2 = i1 & 255;
int j2 = this.bitfield[l1 + this.bitfield[i2]] % 12;
int k2 = this.bitfield[l1 + j1 + this.bitfield[i2 + k1]] % 12;
int l2 = this.bitfield[l1 + 1 + this.bitfield[i2 + 1]] % 12;
double d15 = 0.5D - d9 * d9 - d10 * d10;
double d2;
if(d15 < 0.0D) {
d2 = 0.0D;
}
else {
d15 = d15 * d15;
d2 = d15 * d15 * multPair(DIRS[j2], d9, d10);
}
double d16 = 0.5D - d11 * d11 - d12 * d12;
double d3;
if(d16 < 0.0D) {
d3 = 0.0D;
}
else {
d16 = d16 * d16;
d3 = d16 * d16 * multPair(DIRS[k2], d11, d12);
}
double d17 = 0.5D - d13 * d13 - d14 * d14;
double d4;
if(d17 < 0.0D) {
d4 = 0.0D;
}
else {
d17 = d17 * d17;
d4 = d17 * d17 * multPair(DIRS[l2], d13, d14);
}
int pos = o++;
noise[pos] += 70.0D * (d2 + d3 + d4) * amp;
}
}
}
}

View file

@ -1,107 +0,0 @@
package common.rng;
class SimplexGenOld {
private static final int DIRS[][] = { { 1, 1, 0 }, { -1, 1, 0 }, { 1, -1, 0 }, { -1, -1, 0 }, { 1, 0, 1 }, { -1, 0, 1 }, { 1, 0, -1 },
{ -1, 0, -1 }, { 0, 1, 1 }, { 0, -1, 1 }, { 0, 1, -1 }, { 0, -1, -1 } };
private static final double SQ3NORM = 0.5D * (Math.sqrt(3D) - 1.0D);
private static final double SQ3INV = (3D - Math.sqrt(3D)) / 6D;
private final int bitfield[];
private final double xVar;
private final double zVar;
private final double unused1;
protected SimplexGenOld(Random random) {
this.bitfield = new int[512];
this.xVar = random.doublev() * 256D;
this.zVar = random.doublev() * 256D;
this.unused1 = random.doublev() * 256D;
for(int n = 0; n < 256; n++) {
this.bitfield[n] = n;
}
for(int n = 0; n < 256; n++) {
int pos = random.zrange(256 - n) + n;
int value = this.bitfield[n];
this.bitfield[n] = this.bitfield[pos];
this.bitfield[pos] = value;
this.bitfield[n + 256] = this.bitfield[n];
}
}
private static int floorClamp(double d) {
return d <= 0.0D ? (int)d - 1 : (int)d;
}
private static double multPair(int n[], double xm, double zm) {
return (double)n[0] * xm + (double)n[1] * zm;
}
public void generate(double noise[], double xoff, double zoff, int xsize, int zsize, double xscale, double zscale, double amp) {
int o = 0;
for(int n1 = 0; n1 < xsize; n1++) {
double xv = (xoff + (double)n1) * xscale + this.xVar;
for(int n2 = 0; n2 < zsize; n2++) {
double zv = (zoff + (double)n2) * zscale + this.zVar;
double d10 = (xv + zv) * SQ3NORM;
int j1 = floorClamp(xv + d10);
int k1 = floorClamp(zv + d10);
double d11 = (double)(j1 + k1) * SQ3INV;
double d12 = (double)j1 - d11;
double d13 = (double)k1 - d11;
double d14 = xv - d12;
double d15 = zv - d13;
int l1;
int i2;
if(d14 > d15) {
l1 = 1;
i2 = 0;
}
else {
l1 = 0;
i2 = 1;
}
double d16 = (d14 - (double)l1) + SQ3INV;
double d17 = (d15 - (double)i2) + SQ3INV;
double d18 = (d14 - 1.0D) + 2D * SQ3INV;
double d19 = (d15 - 1.0D) + 2D * SQ3INV;
int j2 = j1 & 0xff;
int k2 = k1 & 0xff;
int l2 = this.bitfield[j2 + this.bitfield[k2]] % 12;
int i3 = this.bitfield[j2 + l1 + this.bitfield[k2 + i2]] % 12;
int j3 = this.bitfield[j2 + 1 + this.bitfield[k2 + 1]] % 12;
double d20 = 0.5D - d14 * d14 - d15 * d15;
double d7;
if(d20 < 0.0D) {
d7 = 0.0D;
}
else {
d20 *= d20;
d7 = d20 * d20 * multPair(DIRS[l2], d14, d15);
}
double d21 = 0.5D - d16 * d16 - d17 * d17;
double d8;
if(d21 < 0.0D) {
d8 = 0.0D;
}
else {
d21 *= d21;
d8 = d21 * d21 * multPair(DIRS[i3], d16, d17);
}
double d22 = 0.5D - d18 * d18 - d19 * d19;
double d9;
if(d22 < 0.0D) {
d9 = 0.0D;
}
else {
d22 *= d22;
d9 = d22 * d22 * multPair(DIRS[j3], d18, d19);
}
noise[o++] += 70D * (d7 + d8 + d9) * amp;
}
}
}
}

View file

@ -3,6 +3,7 @@ package common.world;
import java.util.List;
import common.block.Block;
import common.block.foliage.LeavesType;
import common.dimension.Dimension;
import common.entity.Entity;
import common.entity.npc.EntityNPC;
@ -52,6 +53,7 @@ public abstract class AWorldServer extends World {
public abstract void generateTree(BlockPos pos, State state, Random rand);
public abstract float getGenTemperature(int x, int z);
public abstract float getGenHumidity(int x, int z);
public abstract LeavesType getLeavesGen(BlockPos pos);
public abstract void scheduleUpdate(BlockPos pos, Block blockIn, int delay);
public abstract void notifyNeighborsOfStateChange(BlockPos pos, Block blockType);
}

View file

@ -1451,10 +1451,9 @@ public abstract class World implements IWorldAccess {
-0.125f) * (float)Math.PI * 2.0f);
}
public LeavesType getLeavesGen(BlockPos pos) {
return this.canFreezeAt(pos) ? LeavesType.SNOWY : (!this.dimension.hasSeasons() ?
this.dimension.getLeavesType() : LeavesType.values()[(int)((this.daytime %
this.dimension.getOrbitalPeriod()) * (long)LeavesType.values().length / this.dimension.getOrbitalPeriod())]);
public LeavesType getLeavesType() {
return LeavesType.values()[(int)((this.daytime %
this.dimension.getOrbitalPeriod()) * (long)LeavesType.values().length / this.dimension.getOrbitalPeriod())];
}
public float getTemperatureK(BlockPos pos) {