48 $this->type = Byte::readUnsigned($in);
49 for($i = 0, $i2 = VarInt::readUnsignedInt($in); $i < $i2; ++$i){
51 $entry->scoreboardId = VarInt::readSignedLong($in);
52 $entry->objectiveName = CommonTypes::getString($in);
53 $entry->score = LE::readSignedInt($in);
54 if($this->type !== self::TYPE_REMOVE){
55 $entry->type = Byte::readUnsigned($in);
57 case ScorePacketEntry::TYPE_PLAYER:
58 case ScorePacketEntry::TYPE_ENTITY:
59 $entry->actorUniqueId = CommonTypes::getActorUniqueId($in);
61 case ScorePacketEntry::TYPE_FAKE_PLAYER:
62 $entry->customName = CommonTypes::getString($in);
68 $this->entries[] = $entry;
73 Byte::writeUnsigned($out, $this->type);
74 VarInt::writeUnsignedInt($out, count($this->entries));
75 foreach($this->entries as $entry){
76 VarInt::writeSignedLong($out, $entry->scoreboardId);
77 CommonTypes::putString($out, $entry->objectiveName);
78 LE::writeSignedInt($out, $entry->score);
79 if($this->type !== self::TYPE_REMOVE){
80 Byte::writeUnsigned($out, $entry->type);
82 case ScorePacketEntry::TYPE_PLAYER:
83 case ScorePacketEntry::TYPE_ENTITY:
84 CommonTypes::putActorUniqueId($out, $entry->actorUniqueId);
86 case ScorePacketEntry::TYPE_FAKE_PLAYER:
87 CommonTypes::putString($out, $entry->customName);
90 throw new \InvalidArgumentException(
"Unknown entry type $entry->type");