Merge branch 'master' into mcpe-1.2.5

This commit is contained in:
Dylan K. Taylor 2017-11-07 15:27:14 +00:00
commit a4e955c0a4
11 changed files with 33 additions and 30 deletions

View File

@ -980,7 +980,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
foreach($this->usedChunks as $index => $c){
Level::getXZ($index, $chunkX, $chunkZ);
foreach($this->level->getChunkEntities($chunkX, $chunkZ) as $entity){
if($entity !== $this and !$entity->isClosed() and $entity->isAlive()){
if($entity !== $this and !$entity->isClosed() and $entity->isAlive() and !$entity->isFlaggedForDespawn()){
$entity->spawnTo($this);
}
}
@ -1451,7 +1451,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
foreach($this->level->getNearbyEntities($this->boundingBox->grow(1, 0.5, 1), $this) as $entity){
$entity->scheduleUpdate();
if(!$entity->isAlive()){
if(!$entity->isAlive() or $entity->isFlaggedForDespawn()){
continue;
}
@ -3662,7 +3662,7 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
if($source->isCancelled()){
return;
}elseif($this->getLastDamageCause() === $source and $this->spawned){
$this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION);
$this->broadcastEntityEvent(EntityEventPacket::HURT_ANIMATION, null, [$this]);
if($this->isSurvival()){
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_DAMAGE);

View File

@ -1944,6 +1944,10 @@ abstract class Entity extends Location implements Metadatable, EntityIds{
$this->needsDespawn = true;
}
public function isFlaggedForDespawn() : bool{
return $this->needsDespawn;
}
/**
* Returns whether the entity has been "closed".
* @return bool

View File

@ -93,7 +93,7 @@ class FallingSand extends Entity{
$hasUpdate = parent::entityBaseTick($tickDiff);
if($this->isAlive()){
if(!$this->isFlaggedForDespawn()){
$pos = Position::fromObject($this->add(-$this->width / 2, $this->height, -$this->width / 2)->floor(), $this->getLevel());
$this->block->position($pos);

View File

@ -105,7 +105,7 @@ class Item extends Entity{
$hasUpdate = parent::entityBaseTick($tickDiff);
if($this->isAlive()){
if(!$this->isFlaggedForDespawn()){
if($this->pickupDelay > 0 and $this->pickupDelay < 32767){ //Infinite delay
$this->pickupDelay -= $tickDiff;
if($this->pickupDelay < 0){

View File

@ -87,7 +87,7 @@ class PrimedTNT extends Entity implements Explosive{
$this->setDataProperty(self::DATA_FUSE_LENGTH, self::DATA_TYPE_INT, $this->fuse);
}
if($this->isAlive()){
if(!$this->isFlaggedForDespawn()){
$this->fuse -= $tickDiff;
if($this->fuse <= 0){

View File

@ -121,7 +121,7 @@ abstract class Projectile extends Entity{
$hasUpdate = parent::entityBaseTick($tickDiff);
if($this->isAlive()){
if(!$this->isFlaggedForDespawn()){
$movingObjectPosition = null;
$moveVector = new Vector3($this->x + $this->motionX, $this->y + $this->motionY, $this->z + $this->motionZ);

View File

@ -215,9 +215,9 @@ class Item implements ItemIds, \JsonSerializable{
*
* @param CompoundTag|string $tags
*
* @return $this
* @return Item
*/
public function setCompoundTag($tags){
public function setCompoundTag($tags) : Item{
if($tags instanceof CompoundTag){
$this->setNamedTag($tags);
}else{
@ -259,9 +259,9 @@ class Item implements ItemIds, \JsonSerializable{
/**
* @param CompoundTag $compound
*
* @return $this
* @return Item
*/
public function setCustomBlockData(CompoundTag $compound){
public function setCustomBlockData(CompoundTag $compound) : Item{
$tags = clone $compound;
$tags->setName(self::TAG_BLOCK_ENTITY_TAG);
$this->setNamedTagEntry($tags);
@ -438,9 +438,9 @@ class Item implements ItemIds, \JsonSerializable{
/**
* @param string $name
*
* @return $this
* @return Item
*/
public function setCustomName(string $name){
public function setCustomName(string $name) : Item{
if($name === ""){
$this->clearCustomName();
}
@ -458,9 +458,9 @@ class Item implements ItemIds, \JsonSerializable{
}
/**
* @return $this
* @return Item
*/
public function clearCustomName(){
public function clearCustomName() : Item{
$display = $this->getNamedTagEntry(self::TAG_DISPLAY);
if($display instanceof CompoundTag){
$display->removeTag(self::TAG_DISPLAY_NAME);
@ -492,9 +492,9 @@ class Item implements ItemIds, \JsonSerializable{
/**
* @param string[] $lines
*
* @return $this
* @return Item
*/
public function setLore(array $lines){
public function setLore(array $lines) : Item{
$display = $this->getNamedTagEntry(self::TAG_DISPLAY);
if(!($display instanceof CompoundTag)){
$display = new CompoundTag(self::TAG_DISPLAY, []);
@ -547,9 +547,9 @@ class Item implements ItemIds, \JsonSerializable{
* Sets the Item's NBT from the supplied CompoundTag object.
* @param CompoundTag $tag
*
* @return $this
* @return Item
*/
public function setNamedTag(CompoundTag $tag){
public function setNamedTag(CompoundTag $tag) : Item{
if($tag->getCount() === 0){
return $this->clearNamedTag();
}
@ -564,7 +564,7 @@ class Item implements ItemIds, \JsonSerializable{
* Removes the Item's NBT.
* @return Item
*/
public function clearNamedTag(){
public function clearNamedTag() : Item{
return $this->setCompoundTag("");
}
@ -577,9 +577,9 @@ class Item implements ItemIds, \JsonSerializable{
/**
* @param int $count
* @return $this
* @return Item
*/
public function setCount(int $count){
public function setCount(int $count) : Item{
$this->count = $count;
return $this;
@ -677,9 +677,9 @@ class Item implements ItemIds, \JsonSerializable{
/**
* @param int $meta
* @return $this
* @return Item
*/
public function setDamage(int $meta){
public function setDamage(int $meta) : Item{
$this->meta = $meta !== -1 ? $meta & 0x7FFF : -1;
return $this;

View File

@ -41,9 +41,9 @@ class ItemBlock extends Item{
parent::__construct($itemId ?? $this->block->getId(), $meta, $this->block->getName());
}
public function setDamage(int $meta){
$this->meta = $meta;
$this->block->setDamage($this->meta !== -1 ? $this->meta & 0xf : 0);
public function setDamage(int $meta) : Item{
$this->block->setDamage($meta !== -1 ? $meta & 0xf : 0);
return parent::setDamage($meta);
}
public function getBlock() : Block{

View File

@ -82,7 +82,6 @@ class JsonNBTParser{
$tag = NBT::createTag($type);
if($tag instanceof NamedTag){
$tag->setName($key);
$tag->setValue($value);
$data[$key] = $tag;
}

@ -1 +1 @@
Subproject commit 268a93c575c3ffa699e8a66b854834989245bb05
Subproject commit 0e26115330808b91ac3ab0b39e54fc9f9f679189

@ -1 +1 @@
Subproject commit 3446bcc774bcc278430e2cecd9d46a47f491656f
Subproject commit ac9940c72ac2b01aaf399dc7df78f12b39630057