NostalgiaCore/src/network/protocol/packet/PlaceBlockPacket.php
2026-07-11 16:51:14 +08:00

44 lines
No EOL
1.1 KiB
PHP

<?php
class PlaceBlockPacket extends RakNetDataPacket{
public $eid;
public $x;
public $z;
public $y;
public $block;
public $meta;
public $face;
public function pid(){
if($this->PROTOCOL < ProtocolInfo4::CURRENT_PROTOCOL_4){
return ProtocolInfo3::PLACE_BLOCK_PACKET;
}elseif($this->PROTOCOL < ProtocolInfo6::CURRENT_PROTOCOL_6){
return ProtocolInfo5::PLACE_BLOCK_PACKET;
}elseif($this->PROTOCOL < ProtocolInfo::CURRENT_PROTOCOL) {
return ProtocolInfo12::PLACE_BLOCK_PACKET;
}
return ProtocolInfo::PLACE_BLOCK_PACKET;
}
public function decode(){
$this->eid = $this->getInt();
$this->x = $this->getInt();
$this->z = $this->getInt();
$this->y = $this->getByte();
$this->block = $this->getByte();
$this->meta = $this->getByte();
$this->face = $this->getByte();
}
public function encode(){
$this->reset();
$this->putInt($this->eid);
$this->putInt($this->x);
$this->putInt($this->z);
$this->putByte($this->y);
$this->putByte(BlockAPI::convertHighItemIdsToOldItemIds($this->PROTOCOL, $this->block));
$this->putByte($this->meta);
$this->putByte($this->face);
}
}