Refactored entity metadata handling into its own class, with type-safe methods (#1876)

This includes several other changes, including:
- SLOT data properties now accept items directly
- POS data properties now accept floored Vector3s (in future this will be block positions) or null for 0,0,0
- VECTOR3F data properties now accept Vector3s or null for 0,0,0
This commit is contained in:
Dylan K. Taylor
2018-01-20 10:52:14 +00:00
committed by GitHub
parent 8f928915d9
commit 2eb6e075ae
11 changed files with 364 additions and 108 deletions

View File

@ -297,11 +297,11 @@ abstract class Living extends Entity implements Damageable{
}
if(!empty($colors)){
$this->setDataProperty(Entity::DATA_POTION_COLOR, Entity::DATA_TYPE_INT, Color::mix(...$colors)->toARGB());
$this->setDataProperty(Entity::DATA_POTION_AMBIENT, Entity::DATA_TYPE_BYTE, $ambient ? 1 : 0);
$this->propertyManager->setInt(Entity::DATA_POTION_COLOR, Color::mix(...$colors)->toARGB());
$this->propertyManager->setByte(Entity::DATA_POTION_AMBIENT, $ambient ? 1 : 0);
}else{
$this->setDataProperty(Entity::DATA_POTION_COLOR, Entity::DATA_TYPE_INT, 0);
$this->setDataProperty(Entity::DATA_POTION_AMBIENT, Entity::DATA_TYPE_BYTE, 0);
$this->propertyManager->setInt(Entity::DATA_POTION_COLOR, 0);
$this->propertyManager->setByte(Entity::DATA_POTION_AMBIENT, 0);
}
}
@ -619,7 +619,7 @@ abstract class Living extends Entity implements Damageable{
* @return int
*/
public function getAirSupplyTicks() : int{
return $this->getDataProperty(self::DATA_AIR);
return $this->propertyManager->getShort(self::DATA_AIR);
}
/**
@ -627,7 +627,7 @@ abstract class Living extends Entity implements Damageable{
* @param int $ticks
*/
public function setAirSupplyTicks(int $ticks){
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $ticks);
$this->propertyManager->setShort(self::DATA_AIR, $ticks);
}
/**
@ -635,7 +635,7 @@ abstract class Living extends Entity implements Damageable{
* @return int
*/
public function getMaxAirSupplyTicks() : int{
return $this->getDataProperty(self::DATA_MAX_AIR);
return $this->propertyManager->getShort(self::DATA_MAX_AIR);
}
/**
@ -643,7 +643,7 @@ abstract class Living extends Entity implements Damageable{
* @param int $ticks
*/
public function setMaxAirSupplyTicks(int $ticks){
$this->setDataProperty(self::DATA_MAX_AIR, self::DATA_TYPE_SHORT, $ticks);
$this->propertyManager->setShort(self::DATA_MAX_AIR, $ticks);
}
/**