Fixed sheep color

This commit is contained in:
ArkQuark 2022-01-21 14:13:34 +03:00
parent aefaf6a651
commit 9e4d6ee479
8 changed files with 4 additions and 2982 deletions

File diff suppressed because it is too large Load diff

View file

@ -1,85 +0,0 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
define("PMF_LEVEL_DEFLATE_LEVEL", 6);
//Gamemodes
define("SURVIVAL", 0);
define("CREATIVE", 1);
define("ADVENTURE", 2);
define("VIEW", 3);
define("VIEWER", 3);
define("SPECTATOR", 3);
//Players
define("MAX_CHUNK_RATE", 60 / arg("max-chunks-per-second", 16)); //Default rate ~256 kB/s
define("PLAYER_MAX_QUEUE", 1024);
define("PLAYER_SURVIVAL_SLOTS", 36);
define("PLAYER_CREATIVE_SLOTS", 112);
//Block Updates
define("BLOCK_UPDATE_NORMAL", 1);
define("BLOCK_UPDATE_RANDOM", 2);
define("BLOCK_UPDATE_SCHEDULED", 3);
define("BLOCK_UPDATE_WEAK", 4);
define("BLOCK_UPDATE_TOUCH", 5);
//Entities
define("ENTITY_PLAYER", 1);
define("ENTITY_MOB", 2);
define("MOB_CHICKEN", 10);
define("MOB_COW", 11);
define("MOB_PIG", 12);
define("MOB_SHEEP", 13);
define("MOB_ZOMBIE", 32);
define("MOB_CREEPER", 33);
define("MOB_SKELETON", 34);
define("MOB_SPIDER", 35);
define("MOB_PIGMAN", 36);
define("ENTITY_OBJECT", 3);
define("OBJECT_TRIPOD_CAMERA", 62);
define("OBJECT_PRIMEDTNT", 65);
define("OBJECT_ARROW", 80);
define("OBJECT_SNOWBALL", 81);
define("OBJECT_EGG", 82);
define("OBJECT_PAINTING", 83);
define("OBJECT_MINECART", 84);
define("ENTITY_ITEM", 4);
define("ENTITY_FALLING", 5);
define("FALLING_SAND", 66);
//TileEntities
define("TILE_SIGN", "Sign");
define("TILE_CHEST", "Chest");
define("CHEST_SLOTS", 27);
define("TILE_FURNACE", "Furnace");
define("FURNACE_SLOTS", 3);

View file

@ -164,7 +164,7 @@ class Entity extends Position{
}
public function getDrops(){
if($this->class === ENTITY_PLAYER and ($this->player->gamemode & 0x01) === 0){
if($this->class === ENTITY_PLAYER and $this->player instanceof Player and ($this->player->gamemode & 0x01) === 0){
$inv = array();
for($i = 0; $i < PLAYER_SURVIVAL_SLOTS; ++$i){
$slot = $this->player->getSlot($i);
@ -201,6 +201,7 @@ class Entity extends Position{
case MOB_PIGMAN:
return array(
array(COOKED_PORKCHOP, 0, mt_rand(0,2)),
array(GOLD_INGOT, 0, mt_rand(0,2)),
);
case MOB_CREEPER:
return array(
@ -227,7 +228,7 @@ class Entity extends Position{
);
case MOB_SHEEP:
return array(
array(WOOL, $this->data["Color"] & 0x0F, 1),
array(WOOL, 2 & 0x0F, 1),
);
}
}
@ -296,7 +297,7 @@ class Entity extends Position{
}
}
if($this->class !== ENTITY_PLAYER and ($this->y >= 128 or $this->y <= 0)){
if($this->class !== ENTITY_PLAYER and ($this->x <= 0 or $this->z <= 0 or $this->x >= 256 or $this->z >= 256 or $this->y >= 128 or $this->y <= 0)){
$this->close();
return false;
}

View file

@ -1,169 +0,0 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
/***REM_START***/
require_once("LevelGenerator.php");
/***REM_END***/
class NormalGenerator implements LevelGenerator{
private $populators = array();
private $level;
private $random;
private $worldHeight = 66;
private $waterHeight = 63;
private $noiseHills;
private $noisePatches;
private $noisePatchesSmall;
private $noiseBase;
public function __construct(array $options = array()){
}
public function getSettings(){
return array();
}
public function init(Level $level, Random $random){
$this->level = $level;
$this->random = $random;
$this->random->setSeed($this->level->getSeed());
$this->noiseHills = new NoiseGeneratorSimplex($this->random, 3);
$this->noisePatches = new NoiseGeneratorSimplex($this->random, 2);
$this->noisePatchesSmall = new NoiseGeneratorSimplex($this->random, 2);
$this->noiseBase = new NoiseGeneratorSimplex($this->random, 16);
$ores = new OrePopulator();
$ores->setOreTypes(array(
new OreType(new CoalOreBlock(), 20, 16, 0, 128),
new OreType(New IronOreBlock(), 20, 8, 0, 64),
new OreType(new RedstoneOreBlock(), 8, 7, 0, 16),
new OreType(new LapisOreBlock(), 1, 6, 0, 32),
new OreType(new GoldOreBlock(), 2, 8, 0, 32),
new OreType(new DiamondOreBlock(), 1, 7, 0, 16),
new OreType(new DirtBlock(), 20, 32, 0, 128),
new OreType(new GravelBlock(), 10, 16, 0, 128),
));
$this->populators[] = $ores;
$trees = new TreePopulator();
$trees->setBaseAmount(3);
$trees->setRandomAmount(0);
$this->populators[] = $trees;
$tallGrass = new TallGrassPopulator();
$tallGrass->setBaseAmount(5);
$tallGrass->setRandomAmount(0);
$this->populators[] = $tallGrass;
}
public function generateChunk($chunkX, $chunkZ){
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
$hills = array();
$patchesSmall = array();
$base = array();
for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){
$i = ($z << 4) + $x;
$hills[$i] = $this->noiseHills->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.11, 12, true);
$patches[$i] = $this->noisePatches->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.03, 16, true);
$patchesSmall[$i] = $this->noisePatchesSmall->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.5, 4, true);
$base[$i] = $this->noiseBase->noise2D($x + ($chunkX << 4), $z + ($chunkZ << 4), 0.7, 16, true);
if($base[$i] < 0){
$base[$i] *= 0.5;
}
}
}
for($chunkY = 0; $chunkY < 8; ++$chunkY){
$chunk = "";
$startY = $chunkY << 4;
$endY = $startY + 16;
for($z = 0; $z < 16; ++$z){
for($x = 0; $x < 16; ++$x){
$i = ($z << 4) + $x;
$height = $this->worldHeight + $hills[$i] * 14 + $base[$i] * 7;
$height = (int) $height;
for($y = $startY; $y < $endY; ++$y){
$diff = $height - $y;
if($y <= 4 and ($y === 0 or $this->random->nextFloat() < 0.75)){
$chunk .= "\x07"; //bedrock
}elseif($diff > 2){
$chunk .= "\x01"; //stone
}elseif($diff > 0){
if($patches[$i] > 0.7){
$chunk .= "\x01"; //stone
}elseif($patches[$i] < -0.8){
$chunk .= "\x0d"; //gravel
}else{
$chunk .= "\x03"; //dirt
}
}elseif($y <= $this->waterHeight){
if(($this->waterHeight - $y) <= 1 and $diff === 0){
$chunk .= "\x0c"; //sand
}elseif($diff === 0){
if($patchesSmall[$i] > 0.3){
$chunk .= "\x0d"; //gravel
}elseif($patchesSmall[$i] < -0.45){
$chunk .= "\x0c"; //sand
}else{
$chunk .= "\x03"; //dirt
}
}else{
$chunk .= "\x09"; //still_water
}
}elseif($diff === 0){
if($patches[$i] > 0.7){
$chunk .= "\x01"; //stone
}elseif($patches[$i] < -0.8){
$chunk .= "\x0d"; //gravel
}else{
$chunk .= "\x02"; //grass
}
}else{
$chunk .= "\x00";
}
}
$chunk .= "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00";
}
}
$this->level->setMiniChunk($chunkX, $chunkZ, $chunkY, $chunk);
}
}
public function populateChunk($chunkX, $chunkZ){
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
foreach($this->populators as $populator){
$this->random->setSeed(0xdeadbeef ^ ($chunkX << 8) ^ $chunkZ ^ $this->level->getSeed());
$populator->populate($this->level, $chunkX, $chunkZ, $this->random);
}
}
public function getSpawn(){
return $this->level->getSafeSpawn(new Vector3(127.5, 128, 127.5));
}
}

View file

@ -1,43 +0,0 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
class TallGrassObject{
public static function growGrass(Level $level, Vector3 $pos, Random $random, $count = 15, $radius = 10){
$arr = array(
BlockAPI::get(DANDELION, 0),
BlockAPI::get(CYAN_FLOWER, 0),
BlockAPI::get(TALL_GRASS, 1),
BlockAPI::get(TALL_GRASS, 2),
BlockAPI::get(TALL_GRASS, 1),
BlockAPI::get(TALL_GRASS, 1)
);
$arrC = count($arr) - 1;
for($c = 0; $c < $count; ++$c){
$x = $random->nextRange($pos->x - $radius, $pos->x + $radius);
$z = $random->nextRange($pos->z - $radius, $pos->z + $radius);
if($level->level->getBlockID($x, $pos->y + 1, $z) === AIR and $level->level->getBlockID($x, $pos->y, $z) === GRASS){
$t = $arr[$random->nextRange(0, $arrC)];
$level->setBlockRaw(new Vector3($x, $pos->y + 1, $z), $t);
}
}
}
}

View file

@ -1,104 +0,0 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
/***REM_START***/
require_once("TreeObject.php");
/***REM_END***/
class SmallTreeObject extends TreeObject{
public $type = 0;
private $trunkHeight = 5;
private static $leavesHeight = 4; // All trees appear to be 4 tall
private static $leafRadii = array( 1, 1.41, 2.83, 2.24 );
private $addLeavesVines = false;
private $addLogVines = false;
private $addCocoaPlants = false;
public function canPlaceObject(Level $level, Vector3 $pos, Random $random){
$radiusToCheck = 0;
for ($yy = 0; $yy < $this->trunkHeight + 3; ++$yy) {
if($yy == 1 or $yy === $this->trunkHeight) {
++$radiusToCheck;
}
for($xx = -$radiusToCheck; $xx < ($radiusToCheck + 1); ++$xx){
for($zz = -$radiusToCheck; $zz < ($radiusToCheck + 1); ++$zz){
if(!isset($this->overridable[$level->level->getBlockID($pos->x + $xx, $pos->y + $yy, $pos->z + $zz)])){
return false;
}
}
}
}
return true;
}
public function placeObject(Level $level, Vector3 $pos, Random $random){
// The base dirt block
$dirtpos = new Vector3( $pos->x, $pos->y - 1, $pos->z );
$level->setBlockRaw( $dirtpos, new DirtBlock() );
// Adjust the tree trunk's height randomly
// plot [-14:11] int( x / 8 ) + 5
// - min=4 (all leaves are 4 tall, some trunk must show)
// - max=6 (top leaves are within ground-level whacking range
// on all small trees)
$heightPre = $random->nextRange(-14, 11);
$this->trunkHeight = intval( $heightPre / 8 ) + 5;
// Adjust the starting leaf density using the trunk height as a
// starting position (tall trees with skimpy leaves don't look
// too good)
$leafPre = $random->nextRange($this->trunkHeight, 10) / 20; // (TODO: seed may apply)
// Now build the tree (from the top down)
$leaflevel = 0;
for( $yy = ($this->trunkHeight + 1); $yy >= 0; --$yy )
{
if( $leaflevel < self::$leavesHeight )
{
// The size is a slight variation on the trunkheight
$radius = self::$leafRadii[ $leaflevel ] + $leafPre;
$bRadius = 2;
for( $xx = -$bRadius; $xx <= $bRadius; ++ $xx )
{
for( $zz = -$bRadius; $zz <= $bRadius; ++ $zz )
{
if( sqrt(($xx * $xx) + ($zz * $zz)) <= $radius )
{
$leafpos = new Vector3( $pos->x + $xx,
$pos->y + $yy,
$pos->z + $zz );
$level->setBlockRaw($leafpos, new LeavesBlock( $this->type ) );
}
}
}
$leaflevel ++;
}
// Place the trunk last
if($leaflevel > 1)
{
$trunkpos = new Vector3( $pos->x, $pos->y + $yy, $pos->z );
$level->setBlockRaw($trunkpos, new WoodBlock( $this->type ) );
}
}
}
}

View file

@ -1,75 +0,0 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
class TallGrassPopulator extends Populator{
private $level;
private $randomAmount;
private $baseAmount;
public function setRandomAmount($amount){
$this->randomAmount = $amount;
}
public function setBaseAmount($amount){
$this->baseAmount = $amount;
}
public function populate(Level $level, $chunkX, $chunkZ, Random $random){
$this->level = $level;
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
for($i = 0; $i < $amount; ++$i){
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
for($size = 30; $size > 0; --$size){
$xx = $x - 7 + $random->nextRange(0, 15);
$zz = $z - 7 + $random->nextRange(0, 15);
$yy = $this->getHighestWorkableBlock($xx, $zz);
$vector = new Vector3($xx, $yy, $zz);
if($yy !== -1 and $this->canTallGrassStay($this->level->getBlockRaw($vector))){
if(mt_rand(1,4) == 1){
$this->level->setBlockRaw($vector, new TallGrassBlock(2));
}else{
$this->level->setBlockRaw($vector, new TallGrassBlock(1);
}
}
}
}
}
private function canTallGrassStay(Block $block){
return $block->getID() === AIR and $block->getSide(0)->getID() === GRASS;
}
private function getHighestWorkableBlock($x, $z){
for($y = 128; $y > 0; --$y){
$b = $this->level->getBlockRaw(new Vector3($x, $y, $z));
if($b->getID() === AIR or $b->getID() === LEAVES){
if(--$y <= 0){
return -1;
}
}else{
break;
}
}
return ++$y;
}
}

View file

@ -1,69 +0,0 @@
<?php
/**
*
* ____ _ _ __ __ _ __ __ ____
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* @author PocketMine Team
* @link http://www.pocketmine.net/
*
*
*/
class TreePopulator extends Populator{
private $level;
private $randomAmount;
private $baseAmount;
public function setRandomAmount($amount){
$this->randomAmount = $amount;
}
public function setBaseAmount($amount){
$this->baseAmount = $amount;
}
public function populate(Level $level, $chunkX, $chunkZ, Random $random){
$this->level = $level;
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
for($i = 0; $i < $amount; ++$i){
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
$y = $this->getHighestWorkableBlock($x, $z);
if($y === -1){
continue;
}
if($random->nextFloat() > 0.75){
$meta = SaplingBlock::BIRCH;
}elseif(($random->nextFloat() < 0.75) and ($random->nextFloat() > 0.25)){
$meta = SaplingBlock::OAK;
}else{
$meta = SaplingBlock::JUNGLE;
}
TreeObject::growTree($this->level, new Vector3($x, $y, $z), $random, $meta);
}
}
private function getHighestWorkableBlock($x, $z){
for($y = 128; $y > 0; --$y){
$b = $this->level->getBlockRaw(new Vector3($x, $y, $z));
if($b->getID() !== DIRT and $b->getID() !== GRASS){
if(--$y <= 0){
return -1;
}
}else{
break;
}
}
return ++$y;
}
}