Java Code Examples for cn.nukkit.math.NukkitRandom#nextDouble()
The following examples show how to use
cn.nukkit.math.NukkitRandom#nextDouble() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Simplex.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public Simplex(NukkitRandom random, double octaves, double persistence) { super(random, octaves, persistence); this.offsetW = random.nextDouble() * 256; SQRT_3 = Math.sqrt(3); SQRT_5 = Math.sqrt(5); F2 = 0.5 * (SQRT_3 - 1); G2 = (3 - SQRT_3) / 6; G22 = G2 * 2.0 - 1; F3 = 1.0 / 3.0; G3 = 1.0 / 6.0; F4 = (SQRT_5 - 1.0) / 4.0; G4 = (5.0 - SQRT_5) / 20.0; G42 = G4 * 2.0; G43 = G4 * 3.0; G44 = G4 * 4.0 - 1.0; }
Example 2
Source File: Simplex.java From Jupiter with GNU General Public License v3.0 | 6 votes |
public Simplex(NukkitRandom random, double octaves, double persistence, double expansion) { super(random, octaves, persistence, expansion); this.offsetW = random.nextDouble() * 256; SQRT_3 = Math.sqrt(3); SQRT_5 = Math.sqrt(5); F2 = 0.5 * (SQRT_3 - 1); G2 = (3 - SQRT_3) / 6; G22 = G2 * 2.0 - 1; F3 = 1.0 / 3.0; G3 = 1.0 / 6.0; F4 = (SQRT_5 - 1.0) / 4.0; G4 = (5.0 - SQRT_5) / 20.0; G42 = G4 * 2.0; G43 = G4 * 3.0; G44 = G4 * 4.0 - 1.0; }
Example 3
Source File: SimplexD.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public SimplexD(NukkitRandom random, double octaves, double persistence) { super(random, octaves, persistence); this.offsetW = random.nextDouble() * 256; SQRT_3 = Math.sqrt(3); SQRT_5 = Math.sqrt(5); F2 = 0.5 * (SQRT_3 - 1); G2 = (3 - SQRT_3) / 6; G22 = G2 * 2.0 - 1; F3 = 1.0 / 3.0; G3 = 1.0 / 6.0; F4 = (SQRT_5 - 1.0) / 4.0; G4 = (5.0 - SQRT_5) / 20.0; G42 = G4 * 2.0; G43 = G4 * 3.0; G44 = G4 * 4.0 - 1.0; }
Example 4
Source File: SimplexD.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public SimplexD(NukkitRandom random, double octaves, double persistence, double expansion) { super(random, octaves, persistence, expansion); this.offsetW = random.nextDouble() * 256; SQRT_3 = Math.sqrt(3); SQRT_5 = Math.sqrt(5); F2 = 0.5 * (SQRT_3 - 1); G2 = (3 - SQRT_3) / 6; G22 = G2 * 2.0 - 1; F3 = 1.0 / 3.0; G3 = 1.0 / 6.0; F4 = (SQRT_5 - 1.0) / 4.0; G4 = (5.0 - SQRT_5) / 20.0; G42 = G4 * 2.0; G43 = G4 * 3.0; G44 = G4 * 4.0 - 1.0; }
Example 5
Source File: NoiseGeneratorImprovedD.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public NoiseGeneratorImprovedD(NukkitRandom random) { this.permutations = new int[512]; this.xCoord = random.nextDouble() * 256.0D; this.yCoord = random.nextDouble() * 256.0D; this.zCoord = random.nextDouble() * 256.0D; int i = 0; while (i < 256) { this.permutations[i] = i++; } for (int l = 0; l < 256; ++l) { int j = random.nextBoundedInt(256 - l) + l; int k = this.permutations[l]; this.permutations[l] = this.permutations[j]; this.permutations[j] = k; this.permutations[l + 256] = this.permutations[l]; } }
Example 6
Source File: NoiseGeneratorSimplexD.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public NoiseGeneratorSimplexD(NukkitRandom p_i45471_1_) { this.p = new int[512]; this.xo = p_i45471_1_.nextDouble() * 256.0D; this.yo = p_i45471_1_.nextDouble() * 256.0D; this.zo = p_i45471_1_.nextDouble() * 256.0D; int i = 0; while (i < 256) { this.p[i] = i++; } for (int l = 0; l < 256; ++l) { int j = p_i45471_1_.nextBoundedInt(256 - l) + l; int k = this.p[l]; this.p[l] = this.p[j]; this.p[j] = k; this.p[l + 256] = this.p[l]; } }
Example 7
Source File: Simplex.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Simplex(NukkitRandom random, double octaves, double persistence) { super(random, octaves, persistence); this.offsetW = random.nextDouble() * 256; SQRT_3 = Math.sqrt(3); SQRT_5 = Math.sqrt(5); F2 = 0.5 * (SQRT_3 - 1); G2 = (3 - SQRT_3) / 6; G22 = G2 * 2.0 - 1; F3 = 1.0 / 3.0; G3 = 1.0 / 6.0; F4 = (SQRT_5 - 1.0) / 4.0; G4 = (5.0 - SQRT_5) / 20.0; G42 = G4 * 2.0; G43 = G4 * 3.0; G44 = G4 * 4.0 - 1.0; }
Example 8
Source File: Simplex.java From Nukkit with GNU General Public License v3.0 | 6 votes |
public Simplex(NukkitRandom random, double octaves, double persistence, double expansion) { super(random, octaves, persistence, expansion); this.offsetW = random.nextDouble() * 256; SQRT_3 = Math.sqrt(3); SQRT_5 = Math.sqrt(5); F2 = 0.5 * (SQRT_3 - 1); G2 = (3 - SQRT_3) / 6; G22 = G2 * 2.0 - 1; F3 = 1.0 / 3.0; G3 = 1.0 / 6.0; F4 = (SQRT_5 - 1.0) / 4.0; G4 = (5.0 - SQRT_5) / 20.0; G42 = G4 * 2.0; G43 = G4 * 3.0; G44 = G4 * 4.0 - 1.0; }
Example 9
Source File: OreType.java From Nukkit with GNU General Public License v3.0 | 4 votes |
public boolean spawn(ChunkManager level, NukkitRandom rand, int replaceId, int x, int y, int z) { float piScaled = rand.nextFloat() * (float) Math.PI; double scaleMaxX = (double) ((float) (x + 8) + MathHelper.sin(piScaled) * (float) clusterSize / 8.0F); double scaleMinX = (double) ((float) (x + 8) - MathHelper.sin(piScaled) * (float) clusterSize / 8.0F); double scaleMaxZ = (double) ((float) (z + 8) + MathHelper.cos(piScaled) * (float) clusterSize / 8.0F); double scaleMinZ = (double) ((float) (z + 8) - MathHelper.cos(piScaled) * (float) clusterSize / 8.0F); double scaleMaxY = (double) (y + rand.nextBoundedInt(3) - 2); double scaleMinY = (double) (y + rand.nextBoundedInt(3) - 2); for (int i = 0; i < clusterSize; ++i) { float sizeIncr = (float) i / (float) clusterSize; double scaleX = scaleMaxX + (scaleMinX - scaleMaxX) * (double) sizeIncr; double scaleY = scaleMaxY + (scaleMinY - scaleMaxY) * (double) sizeIncr; double scaleZ = scaleMaxZ + (scaleMinZ - scaleMaxZ) * (double) sizeIncr; double randSizeOffset = rand.nextDouble() * (double) clusterSize / 16.0D; double randVec1 = (double) (MathHelper.sin((float) Math.PI * sizeIncr) + 1.0F) * randSizeOffset + 1.0D; double randVec2 = (double) (MathHelper.sin((float) Math.PI * sizeIncr) + 1.0F) * randSizeOffset + 1.0D; int minX = MathHelper.floor(scaleX - randVec1 / 2.0D); int minY = MathHelper.floor(scaleY - randVec2 / 2.0D); int minZ = MathHelper.floor(scaleZ - randVec1 / 2.0D); int maxX = MathHelper.floor(scaleX + randVec1 / 2.0D); int maxY = MathHelper.floor(scaleY + randVec2 / 2.0D); int maxZ = MathHelper.floor(scaleZ + randVec1 / 2.0D); for (int xSeg = minX; xSeg <= maxX; ++xSeg) { double xVal = ((double) xSeg + 0.5D - scaleX) / (randVec1 / 2.0D); if (xVal * xVal < 1.0D) { for (int ySeg = minY; ySeg <= maxY; ++ySeg) { double yVal = ((double) ySeg + 0.5D - scaleY) / (randVec2 / 2.0D); if (xVal * xVal + yVal * yVal < 1.0D) { for (int zSeg = minZ; zSeg <= maxZ; ++zSeg) { double zVal = ((double) zSeg + 0.5D - scaleZ) / (randVec1 / 2.0D); if (xVal * xVal + yVal * yVal + zVal * zVal < 1.0D) { if (level.getBlockIdAt(xSeg, ySeg, zSeg) == replaceBlockId) { level.setBlockFullIdAt(xSeg, ySeg, zSeg, fullId); } } } } } } } } return true; }