Thanks to @Gameherobrine at NostalgiaCore-BackPort at commit #48c317a

This commit is contained in:
yefengeeeeeeeeeee 2026-04-11 15:41:47 +08:00
parent 1b25bd4694
commit dcb8732335
7 changed files with 97 additions and 35 deletions

View file

@ -3535,6 +3535,10 @@ class Player{
$t->spawn($this); $t->spawn($this);
}else{ }else{
$nbt = new NBT(); $nbt = new NBT();
if($this->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12) {
$t->setText($packet->line1, $packet->line2, $packet->line3, $packet->line4);
break;
}
$nbt->load($packet->namedtag); $nbt->load($packet->namedtag);
$d = array_shift($nbt->tree); $d = array_shift($nbt->tree);
if($d["id"] !== TILE_SIGN){ if($d["id"] !== TILE_SIGN){

View file

@ -17,7 +17,7 @@ class ChatPacket extends RakNetDataPacket{
} }
public function decode(){ public function decode(){
console($this->getString());
} }
public function encode(){ public function encode(){

View file

@ -5,6 +5,10 @@ class EntityDataPacket extends RakNetDataPacket{
public $y; public $y;
public $z; public $z;
public $namedtag; public $namedtag;
public $line1;
public $line2;
public $line3;
public $line4;
public function pid(){ public function pid(){
if($this->PROTOCOL < ProtocolInfo8::CURRENT_PROTOCOL_8){ if($this->PROTOCOL < ProtocolInfo8::CURRENT_PROTOCOL_8){
@ -23,6 +27,19 @@ class EntityDataPacket extends RakNetDataPacket{
$this->x = $this->getShort(); $this->x = $this->getShort();
$this->y = $this->getByte(); $this->y = $this->getByte();
$this->z = $this->getShort(); $this->z = $this->getShort();
if($this->PROTOCOL < 11){
$this->line1 = $this->get(Utils::readLShort($this->get(2), false));
$this->line2 = $this->get(Utils::readLShort($this->get(2), false));
$this->line3 = $this->get(Utils::readLShort($this->get(2), false));
$this->line4 = $this->get(Utils::readLShort($this->get(2), false));
return;
}elseif($this->PROTOCOL === 11){
$this->line1 = $this->getString();
$this->line2 = $this->getString();
$this->line3 = $this->getString();
$this->line4 = $this->getString();
return;
}
$this->namedtag = $this->get(true); $this->namedtag = $this->get(true);
} }
@ -31,8 +48,23 @@ class EntityDataPacket extends RakNetDataPacket{
$this->putShort($this->x); $this->putShort($this->x);
$this->putByte($this->y); $this->putByte($this->y);
$this->putShort($this->z); $this->putShort($this->z);
if($this->PROTOCOL < 11){
$this->putLShort(strlen($this->line1));
$this->put($this->line1);
$this->putLShort(strlen($this->line2));
$this->put($this->line2);
$this->putLShort(strlen($this->line3));
$this->put($this->line3);
$this->putLShort(strlen($this->line4));
$this->put($this->line4);
}elseif($this->PROTOCOL === 11){
$this->putString($this->line1);
$this->putString($this->line2);
$this->putString($this->line3);
$this->putString($this->line4);
return;
}
$this->put($this->namedtag); $this->put($this->namedtag);
console($this->namedtag);
} }
} }

View file

@ -11,6 +11,8 @@ class MessagePacket extends RakNetDataPacket{
public function decode(){ public function decode(){
if($this->PROTOCOL > ProtocolInfo9::CURRENT_PROTOCOL_9){ //0.6.1 and below From NostalgiaCore-BackPort Author:Gameherobrine if($this->PROTOCOL > ProtocolInfo9::CURRENT_PROTOCOL_9){ //0.6.1 and below From NostalgiaCore-BackPort Author:Gameherobrine
$this->source = $this->getString(); $this->source = $this->getString();
}else {
$this->source = "";
} }
$this->message = $this->getString(); $this->message = $this->getString();
} }

View file

@ -162,6 +162,10 @@ abstract class RakNetDataPacket extends stdClass{
$this->buffer .= Utils::writeShort($v); $this->buffer .= Utils::writeShort($v);
} }
protected function putLShort($v){
$this->buffer .= Utils::writeLShort($v);
}
protected function putByte($v){ protected function putByte($v){
$this->buffer .= chr((int)$v); $this->buffer .= chr((int)$v);
} }

View file

@ -412,6 +412,26 @@ class Tile extends Position{
$nbt->write(chr(NBT::TAG_END)); $nbt->write(chr(NBT::TAG_END));
if($player->PROTOCOL < ProtocolInfo12::CURRENT_PROTOCOL_12){
$line1 = mb_substr($this->data["Text1"], 0, 15);
$line2 = mb_substr($this->data["Text2"], 0, 15);
$line3 = mb_substr($this->data["Text3"], 0, 15);
$line4 = mb_substr($this->data["Text4"], 0, 15);
$pk = new EntityDataPacket;
$pk->x = $this->x;
$pk->y = $this->y;
$pk->z = $this->z;
$pk->line1 = $line1;
$pk->line2 = $line2;
$pk->line3 = $line3;
$pk->line4 = $line4;
$player->blockQueueDataPacket($pk);
break;
}
$pk = new EntityDataPacket; $pk = new EntityDataPacket;
$pk->x = $this->x; $pk->x = $this->x;
$pk->y = $this->y; $pk->y = $this->y;