25 private const Y_INDEX_MULTIPLIER = 128;
27 public function __construct(
33 public function getColor() :
Color{
return $this->color; }
35 public function getX() :
int{
return $this->x; }
37 public function getY() :
int{
return $this->y; }
39 public static function read(ByteBufferReader $in) :
self{
40 $color = LE::readUnsignedInt($in);
41 $index = LE::readUnsignedShort($in);
43 $x = $index % self::Y_INDEX_MULTIPLIER;
44 $y = intdiv($index, self::Y_INDEX_MULTIPLIER);
46 return new self(Color::fromRGBA($color), $x, $y);
49 public function write(ByteBufferWriter $out) :
void{
50 LE::writeUnsignedInt($out, $this->color->toRGBA());
51 LE::writeUnsignedShort($out, $this->x + ($this->y * self::Y_INDEX_MULTIPLIER));