mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Merge branch 'stable'
This commit is contained in:
@ -1352,6 +1352,9 @@ abstract class Entity extends Location{
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated WARNING: Despite what its name implies, this function DOES NOT return all the blocks around the entity.
|
||||
* Instead, it returns blocks which have reactions for an entity intersecting with them.
|
||||
*
|
||||
* @return Block[]
|
||||
*/
|
||||
public function getBlocksAround() : array{
|
||||
@ -1646,6 +1649,9 @@ abstract class Entity extends Location{
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated WARNING: This function DOES NOT permanently hide the entity from the player. As soon as the entity or
|
||||
* player moves, the player will once again be able to see the entity.
|
||||
*
|
||||
* @param Player $player
|
||||
* @param bool $send
|
||||
*/
|
||||
@ -1659,6 +1665,10 @@ abstract class Entity extends Location{
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated WARNING: This function DOES NOT permanently hide the entity from viewers. As soon as the entity or
|
||||
* player moves, viewers will once again be able to see the entity.
|
||||
*/
|
||||
public function despawnFromAll() : void{
|
||||
foreach($this->hasSpawned as $player){
|
||||
$this->despawnFrom($player);
|
||||
|
@ -23,40 +23,45 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types\entity;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\TreeRoot;
|
||||
use pocketmine\network\mcpe\serializer\NetworkBinaryStream;
|
||||
use pocketmine\network\mcpe\serializer\NetworkNbtSerializer;
|
||||
|
||||
final class ItemStackMetadataProperty implements MetadataProperty{
|
||||
/** @var Item */
|
||||
final class CompoundTagMetadataProperty implements MetadataProperty{
|
||||
/** @var CompoundTag */
|
||||
private $value;
|
||||
|
||||
/**
|
||||
* @param Item $value
|
||||
* @param CompoundTag $value
|
||||
*/
|
||||
public function __construct(Item $value){
|
||||
public function __construct(CompoundTag $value){
|
||||
$this->value = clone $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Item
|
||||
* @return CompoundTag
|
||||
*/
|
||||
public function getValue() : Item{
|
||||
public function getValue() : CompoundTag{
|
||||
return clone $this->value;
|
||||
}
|
||||
|
||||
public static function id() : int{
|
||||
return EntityMetadataTypes::SLOT;
|
||||
return EntityMetadataTypes::COMPOUND_TAG;
|
||||
}
|
||||
|
||||
public function equals(MetadataProperty $other) : bool{
|
||||
return $other instanceof $this and $other->value->equalsExact($this->value);
|
||||
return $other instanceof $this and $other->value->equals($this->value);
|
||||
}
|
||||
|
||||
public static function read(NetworkBinaryStream $in) : self{
|
||||
return new self($in->getSlot());
|
||||
$offset = $in->getOffset();
|
||||
$result = new self((new NetworkNbtSerializer())->read($in->getBuffer(), $offset, 512)->getTag());
|
||||
$in->setOffset($offset);
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function write(NetworkBinaryStream $out) : void{
|
||||
$out->putSlot($this->value);
|
||||
$out->put((new NetworkNbtSerializer())->write(new TreeRoot($this->value)));
|
||||
}
|
||||
}
|
@ -23,8 +23,8 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types\entity;
|
||||
|
||||
use pocketmine\item\Item;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use function get_class;
|
||||
|
||||
class EntityMetadataCollection{
|
||||
@ -85,12 +85,12 @@ class EntityMetadataCollection{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $key
|
||||
* @param Item $value
|
||||
* @param bool $force
|
||||
* @param int $key
|
||||
* @param CompoundTag $value
|
||||
* @param bool $force
|
||||
*/
|
||||
public function setItem(int $key, Item $value, bool $force = false) : void{
|
||||
$this->set($key, new ItemStackMetadataProperty($value), $force);
|
||||
public function setCompoundTag(int $key, CompoundTag $value, bool $force = false) : void{
|
||||
$this->set($key, new CompoundTagMetadataProperty($value), $force);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ final class EntityMetadataTypes{
|
||||
public const INT = 2;
|
||||
public const FLOAT = 3;
|
||||
public const STRING = 4;
|
||||
public const SLOT = 5;
|
||||
public const COMPOUND_TAG = 5;
|
||||
public const POS = 6;
|
||||
public const LONG = 7;
|
||||
public const VECTOR3F = 8;
|
||||
|
@ -42,7 +42,7 @@ use pocketmine\network\mcpe\protocol\types\entity\ByteMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\EntityLink;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\FloatMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\IntMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\ItemStackMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\CompoundTagMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\LongMetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\MetadataProperty;
|
||||
use pocketmine\network\mcpe\protocol\types\entity\ShortMetadataProperty;
|
||||
@ -258,7 +258,7 @@ class NetworkBinaryStream extends BinaryStream{
|
||||
case IntMetadataProperty::id(): return IntMetadataProperty::read($this);
|
||||
case FloatMetadataProperty::id(): return FloatMetadataProperty::read($this);
|
||||
case StringMetadataProperty::id(): return StringMetadataProperty::read($this);
|
||||
case ItemStackMetadataProperty::id(): return ItemStackMetadataProperty::read($this);
|
||||
case CompoundTagMetadataProperty::id(): return CompoundTagMetadataProperty::read($this);
|
||||
case BlockPosMetadataProperty::id(): return BlockPosMetadataProperty::read($this);
|
||||
case LongMetadataProperty::id(): return LongMetadataProperty::read($this);
|
||||
case Vec3MetadataProperty::id(): return Vec3MetadataProperty::read($this);
|
||||
|
@ -31,8 +31,8 @@ use pocketmine\world\ChunkManager;
|
||||
class TallGrass extends Populator{
|
||||
/** @var ChunkManager */
|
||||
private $world;
|
||||
private $randomAmount;
|
||||
private $baseAmount;
|
||||
private $randomAmount = 1;
|
||||
private $baseAmount = 0;
|
||||
|
||||
public function setRandomAmount(int $amount) : void{
|
||||
$this->randomAmount = $amount;
|
||||
@ -44,7 +44,7 @@ class TallGrass extends Populator{
|
||||
|
||||
public function populate(ChunkManager $world, int $chunkX, int $chunkZ, Random $random) : void{
|
||||
$this->world = $world;
|
||||
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
|
||||
$amount = $random->nextRange(0, $this->randomAmount) + $this->baseAmount;
|
||||
|
||||
$block = VanillaBlocks::TALL_GRASS();
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
|
@ -32,8 +32,8 @@ use pocketmine\world\generator\object\Tree as ObjectTree;
|
||||
class Tree extends Populator{
|
||||
/** @var ChunkManager */
|
||||
private $world;
|
||||
private $randomAmount;
|
||||
private $baseAmount;
|
||||
private $randomAmount = 1;
|
||||
private $baseAmount = 0;
|
||||
|
||||
/** @var TreeType */
|
||||
private $type;
|
||||
@ -55,7 +55,7 @@ class Tree extends Populator{
|
||||
|
||||
public function populate(ChunkManager $world, int $chunkX, int $chunkZ, Random $random) : void{
|
||||
$this->world = $world;
|
||||
$amount = $random->nextRange(0, $this->randomAmount + 1) + $this->baseAmount;
|
||||
$amount = $random->nextRange(0, $this->randomAmount) + $this->baseAmount;
|
||||
for($i = 0; $i < $amount; ++$i){
|
||||
$x = $random->nextRange($chunkX << 4, ($chunkX << 4) + 15);
|
||||
$z = $random->nextRange($chunkZ << 4, ($chunkZ << 4) + 15);
|
||||
|
Reference in New Issue
Block a user