Merge branch 'stable'

This commit is contained in:
Dylan K. Taylor
2020-02-07 18:13:55 +00:00
88 changed files with 543 additions and 283 deletions

View File

@@ -48,7 +48,7 @@ class AttributeMap{
* @return Attribute[]
*/
public function needSend() : array{
return array_filter($this->attributes, function(Attribute $attribute){
return array_filter($this->attributes, function(Attribute $attribute) : bool{
return $attribute->isSyncable() and $attribute->isDesynchronized();
});
}

View File

@@ -265,9 +265,9 @@ final class EntityFactory{
new DoubleTag($pos->z)
]))
->setTag("Motion", new ListTag([
new DoubleTag($motion ? $motion->x : 0.0),
new DoubleTag($motion ? $motion->y : 0.0),
new DoubleTag($motion ? $motion->z : 0.0)
new DoubleTag($motion !== null ? $motion->x : 0.0),
new DoubleTag($motion !== null ? $motion->y : 0.0),
new DoubleTag($motion !== null ? $motion->z : 0.0)
]))
->setTag("Rotation", new ListTag([
new FloatTag($yaw),

View File

@@ -245,9 +245,9 @@ class ExperienceManager{
$equipment[$mainHandIndex] = $item;
}
//TODO: check offhand
foreach($this->entity->getArmorInventory()->getContents() as $k => $item){
if($item instanceof Durable and $item->hasEnchantment(Enchantment::MENDING())){
$equipment[$k] = $item;
foreach($this->entity->getArmorInventory()->getContents() as $k => $armorItem){
if($armorItem instanceof Durable and $armorItem->hasEnchantment(Enchantment::MENDING())){
$equipment[$k] = $armorItem;
}
}

View File

@@ -182,7 +182,7 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
public function getXpDropAmount() : int{
//this causes some XP to be lost on death when above level 1 (by design), dropping at most enough points for
//about 7.5 levels of XP.
return (int) min(100, 7 * $this->xpManager->getXpLevel());
return min(100, 7 * $this->xpManager->getXpLevel());
}
/**

View File

@@ -126,7 +126,7 @@ abstract class Living extends Entity{
$this->setAirSupplyTicks($nbt->getShort("Air", self::DEFAULT_BREATH_TICKS));
/** @var CompoundTag[]|ListTag $activeEffectsTag */
/** @var CompoundTag[]|ListTag|null $activeEffectsTag */
$activeEffectsTag = $nbt->getListTag("ActiveEffects");
if($activeEffectsTag !== null){
foreach($activeEffectsTag as $e){

View File

@@ -75,6 +75,6 @@ abstract class ExperienceUtils{
$x = Math::solveQuadratic($a, $b, $c - $xp);
return (float) max($x); //we're only interested in the positive solution
return max($x); //we're only interested in the positive solution
}
}