mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-21 12:09:43 +00:00
hm
This commit is contained in:
parent
2ad5a5650e
commit
a21e532d2a
9 changed files with 104 additions and 152 deletions
|
|
@ -4,7 +4,7 @@
|
|||
class Player{
|
||||
|
||||
public static $smallChunks = false;
|
||||
|
||||
/** @var Config */
|
||||
public $data;
|
||||
/** @var Entity */
|
||||
public $entity = false;
|
||||
|
|
|
|||
|
|
@ -40,13 +40,14 @@ class FarmlandBlock extends TransparentBlock{
|
|||
|
||||
|
||||
}
|
||||
|
||||
public static function checkWaterStatic(Level $level, $x, $y, $z){
|
||||
for($bx = $x - 4; $bx <= $x + 4; $bx++){
|
||||
for($by = $y; $by <= $y + 1; $by++){
|
||||
for($bz = $z - 4; $bz <= $z + 4; $bz++){
|
||||
|
||||
public static function checkWaterStatic(Level $level, $x, $y, $z)
|
||||
{
|
||||
for ($bx = $x - 4; $bx <= $x + 4; $bx++) {
|
||||
for ($by = $y; $by <= $y + 1; $by++) {
|
||||
for ($bz = $z - 4; $bz <= $z + 4; $bz++) {
|
||||
$id = $level->level->getBlockID($bx, $by, $bz);
|
||||
if($id === 8 || $id === 9){
|
||||
if ($id === 8 || $id === 9) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,10 +44,15 @@ define("MASK32", $val);
|
|||
|
||||
|
||||
class MersenneTwister{
|
||||
|
||||
|
||||
|
||||
static $MAG_01 = [0, MATRIX_A];
|
||||
|
||||
const N = N;
|
||||
# the class constant is not used anywhere in this namespace,
|
||||
# but it makes the API cleaner.
|
||||
//the class constant is not used anywhere in this namespace,
|
||||
//but it makes the API cleaner.
|
||||
|
||||
//^^ u probably wanted to say makes code look weirder
|
||||
|
||||
function __construct(){
|
||||
$this->bits32 = PHP_INT_MAX == 2147483647;
|
||||
|
|
@ -59,21 +64,10 @@ class MersenneTwister{
|
|||
|
||||
function init_with_integer($integer_seed){
|
||||
$integer_seed = force_32_bit_int($integer_seed);
|
||||
|
||||
$mt = &$this->mt;
|
||||
$mti = &$this->mti;
|
||||
|
||||
$mt = array_fill(0, N, 0);
|
||||
|
||||
$mt[0] = $integer_seed;
|
||||
|
||||
for($mti = 1; $mti < N; $mti++){
|
||||
$mt[$mti] = add_2(mul(1812433253,
|
||||
($mt[$mti - 1] ^ (($mt[$mti - 1] >> 30) & 3))), $mti);
|
||||
/*
|
||||
mt[mti] =
|
||||
(1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti);
|
||||
*/
|
||||
$this->mt = array_fill(0, N, 0);
|
||||
$this->mt[0] = $integer_seed;
|
||||
for($this->mti = 1; $this->mti < N; ++$this->mti){
|
||||
$this->mt[$this->mti] = add_2(mul(1812433253, ($this->mt[$this->mti - 1] ^ (($this->mt[$this->mti - 1] >> 30) & 3))), $this->mti);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -125,7 +119,6 @@ class MersenneTwister{
|
|||
array_map("force_32_bit_int", $integer_array);
|
||||
|
||||
$mt = &$this->mt;
|
||||
$mti = &$this->mti;
|
||||
|
||||
$key_length = count($integer_array);
|
||||
|
||||
|
|
@ -173,28 +166,22 @@ class MersenneTwister{
|
|||
}
|
||||
|
||||
function int32(){
|
||||
static $mag01 = [0, MATRIX_A];
|
||||
|
||||
$mt = &$this->mt;
|
||||
$mti = &$this->mti;
|
||||
|
||||
if($mti >= N){ /* generate N words all at once */
|
||||
for($kk = 0; $kk < N - M; $kk++){
|
||||
$y = ($mt[$kk] & UPPER_MASK) | ($mt[$kk + 1] & LOWER_MASK);
|
||||
$mt[$kk] = $mt[$kk + M] ^ (($y >> 1) & MASK31) ^ $mag01[$y & 1];
|
||||
if($this->mti >= N){ /* generate N words all at once */
|
||||
for($kk = 0; $kk < N - M; ++$kk){
|
||||
$y = ($this->mt[$kk] & UPPER_MASK) | ($this->mt[$kk + 1] & LOWER_MASK);
|
||||
$this->mt[$kk] = $this->mt[$kk + M] ^ (($y >> 1) & MASK31) ^ self::$MAG_01[$y & 1];
|
||||
}
|
||||
for(; $kk < N - 1; $kk++){
|
||||
$y = ($mt[$kk] & UPPER_MASK) | ($mt[$kk + 1] & LOWER_MASK);
|
||||
$mt[$kk] =
|
||||
$mt[$kk + (M - N)] ^ (($y >> 1) & MASK31) ^ $mag01[$y & 1];
|
||||
for(; $kk < N - 1; ++$kk){
|
||||
$y = ($this->mt[$kk] & UPPER_MASK) | ($this->mt[$kk + 1] & LOWER_MASK);
|
||||
$this->mt[$kk] = $this->mt[$kk + (M - N)] ^ (($y >> 1) & MASK31) ^ self::$MAG_01[$y & 1];
|
||||
}
|
||||
$y = ($mt[N - 1] & UPPER_MASK) | ($mt[0] & LOWER_MASK);
|
||||
$mt[N - 1] = $mt[M - 1] ^ (($y >> 1) & MASK31) ^ $mag01[$y & 1];
|
||||
$y = ($this->mt[N - 1] & UPPER_MASK) | ($this->mt[0] & LOWER_MASK);
|
||||
$this->mt[N - 1] = $this->mt[M - 1] ^ (($y >> 1) & MASK31) ^ self::$MAG_01[$y & 1];
|
||||
|
||||
$mti = 0;
|
||||
$this->mti = 0;
|
||||
}
|
||||
|
||||
$y = $mt[$mti++];
|
||||
$y = $this->mt[$this->mti++];
|
||||
|
||||
/* Tempering */
|
||||
$y ^= ($y >> 11) & MASK21;
|
||||
|
|
@ -202,7 +189,7 @@ class MersenneTwister{
|
|||
$y ^= ($y << 15) & (0xefc6 << 16);
|
||||
$y ^= ($y >> 18) & MASK14;
|
||||
|
||||
return $y;
|
||||
return $y & 0xFFFFFFFF;
|
||||
}
|
||||
|
||||
/* generates a random number on [0,1]-real-interval */
|
||||
|
|
@ -332,13 +319,15 @@ class MersenneTwister{
|
|||
($this->int32() & MASK26)) *
|
||||
(1.0 / 9007199254740992.0);
|
||||
}
|
||||
|
||||
function nextIntBndn($bound){
|
||||
return ($this->int32() % $bound);
|
||||
}
|
||||
function nextInt($bound = null){
|
||||
return $bound == null ? ($this->int32() >> 1) : ($this->int32() % $bound);
|
||||
}
|
||||
|
||||
function nextFloat(){
|
||||
return $this->int32() * 2.3283064365386963E-010;
|
||||
return $this->int32() * 2.32830644e-10;
|
||||
}
|
||||
|
||||
function setSeed($seed){
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ class NoiseGeneratorPerlin extends NoiseGenerator{
|
|||
$this->zCoord = $random->nextFloat() * 256;
|
||||
|
||||
for($i = 0; $i < 512; ++$i){
|
||||
$this->permutations[$i] = 0;
|
||||
}
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
$this->permutations[$i] = $i;
|
||||
$this->permutations[$i] = $i < 256 ? $i : 0;
|
||||
}
|
||||
|
||||
for($i = 0; $i < 256; ++$i){
|
||||
|
|
@ -58,14 +55,14 @@ class NoiseGeneratorPerlin extends NoiseGenerator{
|
|||
$k2 = (int) ($this->permutations[$j2] + $j1);
|
||||
$l2 = (int) ($this->permutations[$j2 + 1] + $j1);
|
||||
|
||||
return $this->curve($d8,
|
||||
$this->curve($d7,
|
||||
$this->curve($d6, $this->grad3D($this->permutations[$l1], $d3, $d4, $d5), $this->grad3D($this->permutations[$k2], $d3 - 1, $d4, $d5)),
|
||||
$this->curve($d6, $this->grad3D($this->permutations[$i2], $d3, $d4 - 1, $d5), $this->grad3D($this->permutations[$l2], $d3 - 1, $d4 - 1, $d5))
|
||||
return self::curve($d8,
|
||||
self::curve($d7,
|
||||
self::curve($d6, self::grad3D($this->permutations[$l1], $d3, $d4, $d5), self::grad3D($this->permutations[$k2], $d3 - 1, $d4, $d5)),
|
||||
self::curve($d6, self::grad3D($this->permutations[$i2], $d3, $d4 - 1, $d5), self::grad3D($this->permutations[$l2], $d3 - 1, $d4 - 1, $d5))
|
||||
),
|
||||
$this->curve($d7,
|
||||
$this->curve($d6, $this->grad3D($this->permutations[$l1 + 1], $d3, $d4, $d5 - 1), $this->grad3D($this->permutations[$k2 + 1], $d3 - 1, $d4, $d5 - 1)),
|
||||
$this->curve($d6, $this->grad3D($this->permutations[$i2 + 1], $d3, $d4 - 1, $d5 - 1), $this->grad3D($this->permutations[$l2 + 1], $d3 - 1, $d4 - 1, $d5 - 1))
|
||||
self::curve($d7,
|
||||
self::curve($d6, self::grad3D($this->permutations[$l1 + 1], $d3, $d4, $d5 - 1), self::grad3D($this->permutations[$k2 + 1], $d3 - 1, $d4, $d5 - 1)),
|
||||
self::curve($d6, self::grad3D($this->permutations[$i2 + 1], $d3, $d4 - 1, $d5 - 1), self::grad3D($this->permutations[$l2 + 1], $d3 - 1, $d4 - 1, $d5 - 1))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
@ -76,20 +73,14 @@ class NoiseGeneratorPerlin extends NoiseGenerator{
|
|||
$d3 = 1 / $par7;
|
||||
for($i1 = 0; $i1 < $int1; ++$i1){
|
||||
$d4 = $par1 + $i1 * $par4 + $this->xCoord;
|
||||
$i2 = (int) $d4;
|
||||
if($d4 < $i2){
|
||||
--$i2;
|
||||
}
|
||||
$i2 = floor($d4);
|
||||
$i3 = $i2 & 0xFF;
|
||||
$d4 -= $i2;
|
||||
$d5 = $d4 * $d4 * $d4 * ($d4 * ($d4 * 6 - 15) + 10);
|
||||
|
||||
for($i4 = 0; $i4 < $int3; ++$i4){
|
||||
$d6 = $par3 + $i4 * $par6 + $this->zCoord;
|
||||
$i5 = (int) $d6;
|
||||
if($d6 < $i5){
|
||||
--$i5;
|
||||
}
|
||||
$i5 = floor($d6);
|
||||
$i6 = $i5 & 0xFF;
|
||||
$d6 -= $i5;
|
||||
$d7 = $d6 * $d6 * $d6 * ($d6 * ($d6 * 6 - 15) + 10);
|
||||
|
|
@ -98,10 +89,10 @@ class NoiseGeneratorPerlin extends NoiseGenerator{
|
|||
$j = $this->permutations[$i] + $i6;
|
||||
$k = $this->permutations[$i3 + 1];
|
||||
$m = $this->permutations[$k] + $i6;
|
||||
$d1 = $this->curve($d5, $this->grad2D($this->permutations[$j], $d4, $d6), $this->grad3D($this->permutations[$m], $d4 - 1, 0, $d6));
|
||||
$d2 = $this->curve($d5, $this->grad3D($this->permutations[$j + 1], $d4, 0, $d6 - 1), $this->grad3D($this->permutations[$m + 1], $d4 - 1, 0, $d6 - 1));
|
||||
$d1 = self::curve($d5, self::grad2D($this->permutations[$j], $d4, $d6), self::grad3D($this->permutations[$m], $d4 - 1, 0, $d6));
|
||||
$d2 = self::curve($d5, self::grad3D($this->permutations[$j + 1], $d4, 0, $d6 - 1), self::grad3D($this->permutations[$m + 1], $d4 - 1, 0, $d6 - 1));
|
||||
|
||||
$d8 = $this->curve($d7, $d1, $d2);
|
||||
$d8 = self::curve($d7, $d1, $d2);
|
||||
$floats[$n++] += $d8 * $d3;
|
||||
}
|
||||
}
|
||||
|
|
@ -115,35 +106,26 @@ class NoiseGeneratorPerlin extends NoiseGenerator{
|
|||
|
||||
for($i4 = 0; $i4 < $int1; ++$i4){
|
||||
$d6 = $par1 + $i4 * $par4 + $this->xCoord;
|
||||
$i5 = (int) $d6;
|
||||
if($d6 < $i5){
|
||||
--$i5;
|
||||
}
|
||||
$i5 = floor($d6);
|
||||
$i6 = $i5 & 0xFF;
|
||||
$d6 -= $i5;
|
||||
$d7 = $d6 * $d6 * $d6 * ($d6 * ($d6 * 6 - 15) + 10);
|
||||
|
||||
for($i12 = 0; $i12 < $int3; ++$i12){
|
||||
$d12 = $par3 + $i12 * $par6 + $this->zCoord;
|
||||
$i13 = (int) $d12;
|
||||
if($d12 < $i13){
|
||||
--$i13;
|
||||
}
|
||||
$i13 = floor($d12);
|
||||
$i14 = $i13 & 0xFF;
|
||||
$d12 -= $i13;
|
||||
$d13 = $d12 * $d12 * $d12 * ($d12 * ($d12 * 6 - 15) + 10);
|
||||
|
||||
for($i15 = 0; $i15 < $int2; ++$i15){
|
||||
$d14 = $par2 + $i15 * $par5 + $this->yCoord;
|
||||
$i16 = (int) $d14;
|
||||
if($d14 < $i16){
|
||||
--$i16;
|
||||
}
|
||||
$i16 = floor($d14);
|
||||
$i17 = $i16 & 0xff;
|
||||
$d14 -= $i16;
|
||||
$d15 = $d14 * $d14 * $d14 * ($d14 * ($d14 * 6 - 15) + 10);
|
||||
|
||||
if($i15 === 0 or $i17 !== $m){
|
||||
if($i15 == 0 or $i17 != $m){
|
||||
$m = $i17;
|
||||
$i7 = $this->permutations[$i6] + $i17;
|
||||
$i8 = $this->permutations[$i7] + $i14;
|
||||
|
|
@ -151,38 +133,37 @@ class NoiseGeneratorPerlin extends NoiseGenerator{
|
|||
$i10 = $this->permutations[$i6 + 1] + $i17;
|
||||
$n = $this->permutations[$i10] + $i14;
|
||||
$i11 = $this->permutations[$i10 + 1] + $i14;
|
||||
$d10 = $this->curve($d7, $this->grad3D($this->permutations[$i8], $d6, $d14, $d12), $this->grad3D($this->permutations[$n], $d6 - 1, $d14, $d12));
|
||||
$d4 = $this->curve($d7, $this->grad3D($this->permutations[$i9], $d6, $d14 - 1, $d12), $this->grad3D($this->permutations[$i11], $d6 - 1, $d14 - 1, $d12));
|
||||
$d11 = $this->curve($d7, $this->grad3D($this->permutations[$i8 + 1], $d6, $d14, $d12 - 1), $this->grad3D($this->permutations[$n + 1], $d6 - 1, $d14, $d12 - 1));
|
||||
$d5 = $this->curve($d7, $this->grad3D($this->permutations[$i9 + 1], $d6, $d14 - 1, $d12 - 1), $this->grad3D($this->permutations[$i11 + 1], $d6 - 1, $d14 - 1, $d12 - 1));
|
||||
$d10 = self::curve($d7, self::grad3D($this->permutations[$i8], $d6, $d14, $d12), self::grad3D($this->permutations[$n], $d6 - 1, $d14, $d12));
|
||||
$d4 = self::curve($d7, self::grad3D($this->permutations[$i9], $d6, $d14 - 1, $d12), self::grad3D($this->permutations[$i11], $d6 - 1, $d14 - 1, $d12));
|
||||
$d11 = self::curve($d7, self::grad3D($this->permutations[$i8 + 1], $d6, $d14, $d12 - 1), self::grad3D($this->permutations[$n + 1], $d6 - 1, $d14, $d12 - 1));
|
||||
$d5 = self::curve($d7, self::grad3D($this->permutations[$i9 + 1], $d6, $d14 - 1, $d12 - 1), self::grad3D($this->permutations[$i11 + 1], $d6 - 1, $d14 - 1, $d12 - 1));
|
||||
}
|
||||
|
||||
$d16 = $this->curve($d15, $d10, $d4);
|
||||
$d17 = $this->curve($d15, $d11, $d5);
|
||||
$d18 = $this->curve($d13, $d16, $d17);
|
||||
$d16 = $d10 + $d15 * ($d4 - $d10);
|
||||
$d17 = $d11 + $d15 * ($d5 - $d11);
|
||||
$d18 = $d16 + $d13 * ($d17 - $d16);
|
||||
$floats[$i++] += $d18 * $d9;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final function curve($par1, $par2, $par3){
|
||||
public static final function curve($par1, $par2, $par3){
|
||||
return $par2 + $par1 * ($par3 - $par2);
|
||||
}
|
||||
|
||||
public function grad2D($int, $par1, $par2){
|
||||
public static function grad2D($int, $par1, $par2){
|
||||
$i = $int & 0x0F;
|
||||
$d1 = (1 - (($i & 0x08) >> 3)) * $par1;
|
||||
$d2 = ($i === 12 or $i === 14) ? $par1 : ($i < 4 ? 0 : $par2);
|
||||
|
||||
return (($i & 0x01) === 0 ? $d1 : -$d1) + (($i & 0x02) === 0 ? $d2 : -$d2);
|
||||
$d2 = ($i == 12 || $i == 14) ? $par1 : (($i >= 4)*$par2);
|
||||
return (($i & 0x01) ? -$d1 : $d1) + (($i & 0x02) ? -$d2 : $d2);
|
||||
}
|
||||
|
||||
public function grad3D($int, $par1, $par2, $par3){
|
||||
public static function grad3D($int, $par1, $par2, $par3){
|
||||
$i = $int & 0x0F;
|
||||
$d1 = $i < 8 ? $par1 : $par2;
|
||||
$d2 = ($i === 12 or $i === 14) ? $par1 : ($i < 4 ? $par2 : $par3);
|
||||
$d2 = ($i == 12 or $i == 14) ? $par1 : ($i < 4 ? $par2 : $par3);
|
||||
|
||||
return (($i & 0x01) === 0 ? $d1 : -$d1) + (($i & 0x02) === 0 ? $d2 : -$d2);
|
||||
return (($i & 0x01) ? -$d1 : $d1) + (($i & 0x02) ? -$d2 : $d2);
|
||||
}
|
||||
}
|
||||
|
|
@ -59,9 +59,7 @@ class BiomeSource
|
|||
|
||||
for($blockX = 0; $blockX < $xSize; ++$blockX){
|
||||
for($blockZ = 0; $blockZ < $zSize; ++$blockZ){
|
||||
//rain =((($this->detailNoises[$index] * 1.1) + 0.5) * 0.002) + ((($this->rainfallNoises[$index] * 0.15) + 0.5) * 0.998);
|
||||
$rain = ((($this->detailNoises[$index] * 1.1) + 0.5) * 0.002) + ((($this->rainfallNoises[$index] * 0.15) + 0.5) * 0.998);
|
||||
//1 - ((((this.detailNoises[index] * 1.1f) + 0.5f) * 0.01f) + (((this.temperatureNoises[index] * 0.15f) + 0.7f) * 0.99f));
|
||||
$f1 = 1 - ((((($this->detailNoises[$index]) * 1.1) + 0.5) * 0.01) + ((($this->temperatureNoises[$index] * 0.15) + 0.7) * 0.99));
|
||||
$blockTemp = 1 - ($f1 * $f1);
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class VanillaGenerator implements LevelGenerator
|
|||
$this->rand->setSeed($this->level->getSeed());
|
||||
$i1 = (int)(((int)($this->rand->nextInt() / 2)) * 2 + 1); //why php integers are so big....???????????????????????????????????????
|
||||
$j1 = (int)(((int)($this->rand->nextInt() / 2)) * 2 + 1);
|
||||
$this->rand->setSeed(Utils::sint32($chunkX * $i1 + $chunkZ * $j1) ^ $this->level->getSeed());
|
||||
$this->rand->setSeed((($chunkX * $i1 + $chunkZ * $j1) & 0xffffffff) ^ $this->level->getSeed());
|
||||
for($i2 = 0; $i2 < 10; ++$i2){
|
||||
ClayFeature::place($this->level, $this->rand, $chunkXWorld + $this->rand->nextInt(16), $this->rand->nextInt(128), $chunkZWorld + $this->rand->nextInt(16));
|
||||
}
|
||||
|
|
@ -98,12 +98,12 @@ class VanillaGenerator implements LevelGenerator
|
|||
for($i8 = 0; $i8 < 8; ++$i8){
|
||||
OreFeature::place($this->level, $this->rand, $chunkXWorld + $this->rand->nextInt(16), $this->rand->nextInt(16), $chunkZWorld + $this->rand->nextInt(16), REDSTONE_ORE, 7);
|
||||
}
|
||||
for($i9 = 0; $i9 < 1; ++$i9){ //TODO loop is not neccessary
|
||||
OreFeature::place($this->level, $this->rand, $chunkXWorld + $this->rand->nextInt(16), $this->rand->nextInt(16), $chunkZWorld + $this->rand->nextInt(16), DIAMOND_ORE, 7);
|
||||
}
|
||||
for($i10 = 0; $i10 < 1; ++$i10){
|
||||
OreFeature::place($this->level, $this->rand, $chunkXWorld + $this->rand->nextInt(16), $this->rand->nextInt(16) + $this->rand->nextInt(16), $chunkZWorld + $this->rand->nextInt(16), LAPIS_ORE, 6);
|
||||
}
|
||||
//for($i9 = 0; $i9 < 1; ++$i9){ //TODO loop is not neccessary
|
||||
OreFeature::place($this->level, $this->rand, $chunkXWorld + $this->rand->nextInt(16), $this->rand->nextInt(16), $chunkZWorld + $this->rand->nextInt(16), DIAMOND_ORE, 7);
|
||||
//}
|
||||
//for($i10 = 0; $i10 < 1; ++$i10){
|
||||
OreFeature::place($this->level, $this->rand, $chunkXWorld + $this->rand->nextInt(16), $this->rand->nextInt(16) + $this->rand->nextInt(16), $chunkZWorld + $this->rand->nextInt(16), LAPIS_ORE, 6);
|
||||
//}
|
||||
//sample= (int) ((((this.treeNoise.getValue(chunkXWorld * 0.5f, chunkZWorld * 0.5f) / 8.0f) + (this.rand.nextFloat() * 4.0f)) + 4.0f) / 3.0f);
|
||||
$sample = (int) (((($this->treeNoise->getValue($chunkXWorld * 0.5, $chunkZWorld * 0.5) / 8) + ($this->rand->nextFloat() * 4)) + 4) / 3);
|
||||
$treesAmount = $this->rand->nextInt(10) == 0;
|
||||
|
|
@ -156,7 +156,6 @@ class VanillaGenerator implements LevelGenerator
|
|||
$chunkz = array_fill(0, 8, EMPTY_MINI_CHUNK); //[$blockY >> 4][($blockY & 0xf) + ($blockX << 5) + ($blockZ << 9)]. y&f+x&f+z&f
|
||||
$this->prepareHeights($chunkX, $chunkZ, $chunkz, $this->biomes, $this->biomeSource->temperatureNoises);
|
||||
$this->buildSurfaces($chunkX, $chunkZ, $chunkz, $this->biomes);
|
||||
//c.generateHeightMap(); my 0.1.3 core also has this for easier top block search...
|
||||
$this->generateHeightmap($chunkX, $chunkZ, $chunkz);
|
||||
|
||||
for($Y = 0; $Y < 8; ++$Y){
|
||||
|
|
@ -230,8 +229,7 @@ class VanillaGenerator implements LevelGenerator
|
|||
$b = $biome->topBlock;
|
||||
$b2 = $biome->fillerBlock;
|
||||
for($blockY = 127; $blockY >= 0; --$blockY){
|
||||
$i2 = ((($blockZ * 16) + $blockX) * 128) + $blockY;
|
||||
if($blockY <= (0 + $this->rand->nextInt(5))){
|
||||
if($blockY <= $this->rand->nextIntBndn(5)){
|
||||
$chunks[$blockY >> 4][($blockY & 0xf) + ($blockZ << 5) + ($blockX << 9)] = "\x07";
|
||||
}else{
|
||||
$b3 = ord($chunks[$blockY >> 4][($blockY & 0xf) + ($blockZ << 5) + ($blockX << 9)]);
|
||||
|
|
@ -240,16 +238,15 @@ class VanillaGenerator implements LevelGenerator
|
|||
}elseif($b3 == STONE){
|
||||
if($i == -1){
|
||||
if($nextFloat > 0){
|
||||
if($blockY >= 64-4 && $blockY <= 64+1){
|
||||
$b = $biome->topBlock;
|
||||
$b2 = $biome->fillerBlock;
|
||||
if($z2){
|
||||
if($blockY >= 60 && $blockY <= 65){
|
||||
if($z){
|
||||
$b2 = $b = SAND;
|
||||
}elseif($z2){
|
||||
$b = 0;
|
||||
$b2 = GRAVEL;
|
||||
}
|
||||
if($z){
|
||||
$b = SAND;
|
||||
$b2 = SAND;
|
||||
}else{
|
||||
$b = $biome->topBlock;
|
||||
$b2 = $biome->fillerBlock;
|
||||
}
|
||||
}
|
||||
}else{
|
||||
|
|
@ -257,20 +254,14 @@ class VanillaGenerator implements LevelGenerator
|
|||
$b2 = STONE;
|
||||
}
|
||||
|
||||
if($blockY < 64 && $b == 0){
|
||||
$b = STILL_WATER;
|
||||
}
|
||||
$b = $blockY < 64 && $b == 0 ? STILL_WATER : $b;
|
||||
$i = $nextFloat;
|
||||
if($blockY >= 64 - 1){
|
||||
$chunks[$blockY >> 4][($blockY & 0xf) + ($blockZ << 5) + ($blockX << 9)] = chr($b);
|
||||
}else{
|
||||
$chunks[$blockY >> 4][($blockY & 0xf) + ($blockZ << 5) + ($blockX << 9)] = chr($b2);
|
||||
}
|
||||
$chunks[$blockY >> 4][($blockY & 0xf) + ($blockZ << 5) + ($blockX << 9)] = $blockY >= 63 ? chr($b) : chr($b2);
|
||||
}elseif($i > 0){
|
||||
--$i;
|
||||
$chunks[$blockY >> 4][($blockY & 0xf) + ($blockZ << 5) + ($blockX << 9)] = chr($b2);
|
||||
if($i == 0 && $b2 == SAND){
|
||||
$i = $this->rand->nextInt(4);
|
||||
$i = $this->rand->nextIntBndn(4);
|
||||
$b2 = SANDSTONE;
|
||||
}
|
||||
}
|
||||
|
|
@ -288,14 +279,14 @@ class VanillaGenerator implements LevelGenerator
|
|||
for($unkX = 0; $unkX < 4; ++$unkX){
|
||||
for($unkZ = 0; $unkZ < 4; ++$unkZ){
|
||||
for($unkY = 0; $unkY < 16; ++$unkY){
|
||||
$f = $this->heights[(((($unkX + 0) * 5) + $unkZ + 0) * 17) + $unkY + 0];
|
||||
$f2 = $this->heights[(((($unkX + 0) * 5) + $unkZ + 1) * 17) + $unkY + 0];
|
||||
$f3 = $this->heights[(((($unkX + 1) * 5) + $unkZ + 0) * 17) + $unkY + 0];
|
||||
$f4 = $this->heights[(((($unkX + 1) * 5) + $unkZ + 1) * 17) + $unkY + 0];
|
||||
$f = $this->heights[(((($unkX) * 5) + $unkZ) * 17) + $unkY];
|
||||
$f2 = $this->heights[(((($unkX) * 5) + $unkZ + 1) * 17) + $unkY];
|
||||
$f3 = $this->heights[(((($unkX + 1) * 5) + $unkZ) * 17) + $unkY];
|
||||
$f4 = $this->heights[(((($unkX + 1) * 5) + $unkZ + 1) * 17) + $unkY];
|
||||
|
||||
$f5 = ($this->heights[(((($unkX + 0) * 5) + ($unkZ + 0)) * 17) + ($unkY + 1)] - $f) * 0.125;
|
||||
$f6 = ($this->heights[(((($unkX + 0) * 5) + ($unkZ + 1)) * 17) + ($unkY + 1)] - $f2) * 0.125;
|
||||
$f7 = ($this->heights[(((($unkX + 1) * 5) + ($unkZ + 0)) * 17) + ($unkY + 1)] - $f3) * 0.125;
|
||||
$f5 = ($this->heights[(((($unkX) * 5) + ($unkZ)) * 17) + ($unkY + 1)] - $f) * 0.125;
|
||||
$f6 = ($this->heights[(((($unkX) * 5) + ($unkZ + 1)) * 17) + ($unkY + 1)] - $f2) * 0.125;
|
||||
$f7 = ($this->heights[(((($unkX + 1) * 5) + ($unkZ)) * 17) + ($unkY + 1)] - $f3) * 0.125;
|
||||
$f8 = ($this->heights[(((($unkX + 1) * 5) + ($unkZ + 1)) * 17) + ($unkY + 1)] - $f4) * 0.125;
|
||||
|
||||
for($unkYY = 0; $unkYY < 8; ++$unkYY){
|
||||
|
|
@ -304,28 +295,20 @@ class VanillaGenerator implements LevelGenerator
|
|||
$f11 = ($f3 - $f) * 0.25;
|
||||
$f12 = ($f4 - $f2) * 0.25;
|
||||
for($unkXX = 0; $unkXX < 4; ++$unkXX){
|
||||
//int i2 = ((unkXX + (unkX * 4)) << 11) | ((0 + (unkZ * 4)) << 7) | ((unkY * 8) + unkYY);
|
||||
$i2 = (($unkXX + ($unkX * 4)) << 11) | ((0 + ($unkZ * 4)) << 7) | (($unkY * 8) + $unkYY);
|
||||
$f13 = $f9;
|
||||
$f14 = ($f10 - $f9) * 0.25;
|
||||
for($unkZZ = 0; $unkZZ < 4; ++$unkZZ){
|
||||
$d15 = $temperatures[((($unkX * 4) + $unkXX) * 16) + ($unkZ * 4) + $unkZZ];
|
||||
$i3 = 0;
|
||||
if(($unkY * 8) + $unkYY < 64){
|
||||
if($d15 < 0.5 && (($unkY * 8) + $unkYY) >= 63){ //64-1
|
||||
$i3 = ICE;
|
||||
}else{
|
||||
$i3 = STILL_WATER;
|
||||
}
|
||||
$i3 = $f13 > 0; //true -> STONE, false -> AIR
|
||||
|
||||
if(!$i3 && ($unkY * 8) + $unkYY < 64){
|
||||
$i3 = $d15 < 0.5 && (($unkY * 8) + $unkYY) >= 63 ? ICE : STILL_WATER;
|
||||
}
|
||||
if($f13 > 0) $i3 = STONE;
|
||||
|
||||
$fx = ($unkXX + ($unkX * 4));
|
||||
$fy = (($unkY * 8) + $unkYY);
|
||||
$fz = ($unkZZ + ($unkZ * 4));
|
||||
//if($fx == 0 && $fy == 20 && $fz == 0) console("P:".$i3);
|
||||
$chunks[$fy >> 4][($fy & 0xf) + ($fx << 5) + ($fz << 9)] = chr($i3); // ($aY + ($aX << 5) + ($aZ << 9))
|
||||
//$this->level->level->setBlockID(($chunkX * 16) + ($unkXX + ($unkX * 4)), (($unkY * 8) + $unkYY), ($unkZZ + ($unkZ * 4)), $i3);
|
||||
$i2 += 128;
|
||||
$chunks[$fy >> 4][($fy & 0xf) + ($fx << 5) + ($fz << 9)] = chr($i3);
|
||||
$f13 += $f14;
|
||||
}
|
||||
$f9 += $f11;
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ class BirchFeature extends Feature
|
|||
if($i >= 0 && $i < 128){
|
||||
$blockID = $level->level->getBlockID($i3, $i, $i4);
|
||||
if($blockID != 0 && $blockID != LEAVES){
|
||||
$z2 = false;
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
$z2 = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ class PineFeature extends Feature
|
|||
if($l1 >= 0 && $l1 < 128){
|
||||
$j4 = $level->level->getBlockID($l2, $l1, $k3);
|
||||
if($j4 != 0 && $j4 != LEAVES){
|
||||
$flag = false;
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
$flag = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@ class TreeFeature extends Feature
|
|||
if($i >= 0 && $i < 128){
|
||||
$tileID = $level->level->getBlockID($i3, $i, $i4);
|
||||
if($tileID != 0 && $tileID != LEAVES){
|
||||
$z2 = false;
|
||||
return;
|
||||
}
|
||||
}else{
|
||||
$z2 = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue