Permalink
Browse files

UpdateBlockPacket fixed and changed skinName to skinId

  • Loading branch information...
1 parent df8e1e8 commit 6fb41c5c7f2cf51e1ad08c1e68397257c46f0fc1 @Intyre Intyre committed Jun 21, 2016
@@ -567,14 +567,14 @@ public function getDisplayName(){
public function setDisplayName($name){
$this->displayName = $name;
if($this->spawned){
- $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getDisplayName(), $this->getSkinName(), $this->getSkinData());
+ $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getDisplayName(), $this->getSkinId(), $this->getSkinData());
}
}
- public function setSkin($str, $skinName){
- parent::setSkin($str, $skinName);
+ public function setSkin($str, $skinId){
+ parent::setSkin($str, $skinId);
if($this->spawned){
- $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getDisplayName(), $skinName, $str);
+ $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getDisplayName(), $skinId, $str);
}
}
@@ -1850,7 +1850,7 @@ public function handleDataPacket(DataPacket $packet){
break;
}
- $this->setSkin($packet->skin, $packet->skinID);
+ $this->setSkin($packet->skin, $packet->skinId);
$this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this, "Plugin reason"));
if($ev->isCancelled()){
@@ -2180,7 +2180,7 @@ public function addPlayer($identifier, Player $player){
public function addOnlinePlayer(Player $player){
$this->playerList[$player->getRawUniqueId()] = $player;
- $this->updatePlayerListData($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinName(), $player->getSkinData());
+ $this->updatePlayerListData($player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinId(), $player->getSkinData());
}
public function removeOnlinePlayer(Player $player){
@@ -2194,10 +2194,10 @@ public function removeOnlinePlayer(Player $player){
}
}
- public function updatePlayerListData(UUID $uuid, $entityId, $name, $skinName, $skinData, array $players = null){
+ public function updatePlayerListData(UUID $uuid, $entityId, $name, $skinId, $skinData, array $players = null){
$pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_ADD;
- $pk->entries[] = [$uuid, $entityId, $name, $skinName, $skinData];
+ $pk->entries[] = [$uuid, $entityId, $name, $skinId, $skinData];
@thebigsmileXD
thebigsmileXD Jun 24, 2016 Contributor

Well, list won't get updated anyways, especially when players are leaving

Server::broadcastPacket($players === null ? $this->playerList : $players, $pk);
}
@@ -2212,7 +2212,7 @@ public function sendFullPlayerListData(Player $p){
$pk = new PlayerListPacket();
$pk->type = PlayerListPacket::TYPE_ADD;
foreach($this->playerList as $player){
- $pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinName(), $player->getSkinData()];
+ $pk->entries[] = [$player->getUniqueId(), $player->getId(), $player->getDisplayName(), $player->getSkinId(), $player->getSkinData()];
}
$p->dataPacket($pk);
@@ -60,7 +60,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
public $height = 1.8;
public $eyeHeight = 1.62;
- protected $skinName;
+ protected $skinId;
protected $skin;
protected $foodTickTimer = 0;
@@ -72,8 +72,8 @@ public function getSkinData(){
return $this->skin;
}
- public function getSkinName(){
- return $this->skinName;
+ public function getSkinId(){
+ return $this->skinId;
}
/**
@@ -92,11 +92,11 @@ public function getRawUniqueId(){
/**
* @param string $str
- * @param string $skinName
+ * @param string $skinId
*/
- public function setSkin($str, $skinName){
+ public function setSkin($str, $skinId){
$this->skin = $str;
- $this->skinName = $skinName;
+ $this->skinId = $skinId;
}
public function getFood() : float{
@@ -443,7 +443,7 @@ public function saveNBT(){
if(strlen($this->getSkinData()) > 0){
$this->namedtag->Skin = new CompoundTag("Skin", [
"Data" => new StringTag("Data", $this->getSkinData()),
- "Name" => new StringTag("Name", $this->getSkinName())
+ "Name" => new StringTag("Name", $this->getSkinId())
]);
}
}
@@ -457,7 +457,7 @@ public function spawnTo(Player $player){
}
if(!($this instanceof Player)){
- $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $this->skinName, $this->skin, [$player]);
+ $this->server->updatePlayerListData($this->getUniqueId(), $this->getId(), $this->getName(), $this->skinId, $this->skin, [$player]);
}
$pk = new AddPlayerPacket();
@@ -796,11 +796,10 @@ public function sendBlockExtraData(int $x, int $y, int $z, int $id, int $data, a
* @param bool $optimizeRebuilds
*/
public function sendBlocks(array $target, array $blocks, $flags = UpdateBlockPacket::FLAG_NONE, bool $optimizeRebuilds = false){
- $pk = new UpdateBlockPacket();
-
if($optimizeRebuilds){
$chunks = [];
foreach($blocks as $b){
+ $pk = new UpdateBlockPacket();
if($b === null){
continue;
}
@@ -812,28 +811,48 @@ public function sendBlocks(array $target, array $blocks, $flags = UpdateBlockPac
}
if($b instanceof Block){
- $pk->records[] = [$b->x, $b->z, $b->y, $b->getId(), $b->getDamage(), $first ? $flags : UpdateBlockPacket::FLAG_NONE];
+ $pk->x = $b->x;
+ $pk->z = $b->z;
+ $pk->y = $b->y;
+ $pk->blockId = $b->getId();
+ $pk->blockData = $b->getDamage();
+ $pk->flags = $first ? $flags : UpdateBlockPacket::FLAG_NONE;
}else{
$fullBlock = $this->getFullBlock($b->x, $b->y, $b->z);
- $pk->records[] = [$b->x, $b->z, $b->y, $fullBlock >> 4, $fullBlock & 0xf, $first ? $flags : UpdateBlockPacket::FLAG_NONE];
+ $pk->x = $b->x;
+ $pk->z = $b->z;
+ $pk->y = $b->y;
+ $pk->blockId = $fullBlock >> 4;
+ $pk->blockData = $fullBlock & 0xf;
+ $pk->flags = $first ? $flags : UpdateBlockPacket::FLAG_NONE;
}
+ Server::broadcastPacket($target, $pk);
}
}else{
foreach($blocks as $b){
+ $pk = new UpdateBlockPacket();
if($b === null){
continue;
}
if($b instanceof Block){
- $pk->records[] = [$b->x, $b->z, $b->y, $b->getId(), $b->getDamage(), $flags];
+ $pk->x = $b->x;
+ $pk->z = $b->z;
+ $pk->y = $b->y;
+ $pk->blockId = $b->getId();
+ $pk->blockData = $b->getDamage();
+ $pk->flags = $flags;
}else{
$fullBlock = $this->getFullBlock($b->x, $b->y, $b->z);
- $pk->records[] = [$b->x, $b->z, $b->y, $fullBlock >> 4, $fullBlock & 0xf, $flags];
+ $pk->x = $b->x;
+ $pk->z = $b->z;
+ $pk->y = $b->y;
+ $pk->blockId = $fullBlock >> 4;
+ $pk->blockData = $fullBlock & 0xf;
+ $pk->flags = $flags;
}
+ Server::broadcastPacket($target, $pk);
}
}
-
-
- Server::broadcastPacket($target, $pk);
}
public function clearCache(bool $full = false){
@@ -35,7 +35,7 @@ class LoginPacket extends DataPacket{
public $identityPublicKey;
public $serverAddress;
- public $skinID;
+ public $skinId;
public $skin = null;
public function decode(){
@@ -36,22 +36,24 @@ class UpdateBlockPacket extends DataPacket{
const FLAG_ALL = (self::FLAG_NEIGHBORS | self::FLAG_NETWORK);
const FLAG_ALL_PRIORITY = (self::FLAG_ALL | self::FLAG_PRIORITY);
- public $records = []; //x, z, y, blockId, blockData, flags
+ public $x;
+ public $z;
+ public $y;
+ public $blockId;
+ public $blockData;
+ public $flags;
public function decode(){
}
public function encode(){
$this->reset();
- $this->putInt(count($this->records));
- foreach($this->records as $r){
- $this->putInt($r[0]);
- $this->putInt($r[1]);
- $this->putByte($r[2]);
- $this->putByte($r[3]);
- $this->putByte(($r[5] << 4) | $r[4]);
- }
+ $this->putInt($this->x);
+ $this->putInt($this->z);
+ $this->putByte($this->y);
+ $this->putByte($this->blockId);
+ $this->putByte(($this->flags << 4) | $this->blockData);
}
}

1 comment on commit 6fb41c5

@XtremePlayzCODE

Does this add support for 0.15.1?

Please sign in to comment.