EntityDataHelper: accept FloatTag for vector3 as well as Double

MCPE uses Float for entity positions.
This commit is contained in:
Dylan K. Taylor 2021-11-04 20:46:34 +00:00
parent 8abc952c74
commit 579ef63663
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -59,10 +59,10 @@ final class EntityDataHelper{
if($pos === null and $optional){
return new Vector3(0, 0, 0);
}
if(!($pos instanceof ListTag) or $pos->getTagType() !== NBT::TAG_Double){
throw new \UnexpectedValueException("'$tagName' should be a List<Double>");
if(!($pos instanceof ListTag) or ($pos->getTagType() !== NBT::TAG_Double && $pos->getTagType() !== NBT::TAG_Float)){
throw new \UnexpectedValueException("'$tagName' should be a List<Double> or List<Float>");
}
/** @var DoubleTag[] $values */
/** @var DoubleTag[]|FloatTag[] $values */
$values = $pos->getValue();
if(count($values) !== 3){
throw new \UnexpectedValueException("Expected exactly 3 entries in '$tagName' tag");