packet added, small fixes to rail block

This commit is contained in:
GameHerobrine 2022-09-13 20:12:56 +03:00
parent 53102e027e
commit 819803c634
5 changed files with 24 additions and 32 deletions

View file

@ -1784,19 +1784,12 @@ class Player{
if($target->linkedEntity != null){
break;
}
$players = $this->server->api->player->getAll($this->level);
$pk = new SetEntityLinkPacket;
$pk->rider = $target->eid;
$pk->riding = $this->entity->eid;
$pk->type = 2;
$this->server->api->player->broadcastPacket([$this], $pk);
$target->linkedEntity = $this->entity;
$this->entity->isInMinecart = true;
$pk = new SetEntityLinkPacket();
$pk->rider = $target->eid;
$pk->riding = $this->entity->eid;
$pk->type = 2;
$pk->type = 1;
$this->dataPacket($pk);
$needsBreak = true;
@ -2272,6 +2265,8 @@ class Player{
}
}
break;
case ProtocolInfo::PLAYER_INPUT_PACKET:
break; //TODO player input-
default:
console("[DEBUG] Unhandled 0x" . dechex($packet->pid()) . " data packet for " . $this->username . " (" . $this->clientID . "): " . print_r($packet, true), true, true, 2);
break;

View file

@ -96,7 +96,6 @@ require_once(FILE_PATH . "/src/material/Item.php");
require_once(FILE_PATH . "/src/material/item/armor/ArmorItem.php");
require_all(FILE_PATH . "src/");
$inc = get_included_files();

View file

@ -2,23 +2,16 @@
class RailBlock extends FlowableBlock{
public function __construct($meta = 0){
parent::__construct(RAIL, 0, "Rail");
parent::__construct(RAIL, $meta, "Rail");
$this->hardness = 0.7;
$this->isFullBlock = false;
$this->isSolid = true;
$this->meta = $meta;
$this->isSolid = false;
}
public static $shouldconnectrails = false;
private function isRailBlock($id){
switch($id){
case RAIL:
case POWERED_RAIL:
return true;
default:
return false;
}
return $id === RAIL || $id === POWERED_RAIL;
}
private function isValidRailMeta($meta){
@ -61,14 +54,15 @@ class RailBlock extends FlowableBlock{
$rail->getFloorY() + $y,
$rail->getFloorZ() + $blocks[0][1]
);
$idToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getID();
$metaToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getMetadata();
$railBlock = $rail->level->getBlock($v3);
$idToConnect = $railBlock->getID();
$metaToConnect = $railBlock->getMetadata();
if (!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
$xDiff = $damage - $v3->getFloorX();
$zDiff = $damage - $v3->getFloorZ();
$xDiff = $this->getFloorX() - $v3->getFloorX();
$zDiff = $this->getFloorZ() - $v3->getFloorZ();
foreach($blocks as $xz) {
if($xz[0] !== xDiff || $xz[1] !== zDiff) continue;
array_push($connected[], $v3);
if($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
$connected[] = $v3;
}
}
foreach($deltaY as $y){
@ -77,14 +71,15 @@ class RailBlock extends FlowableBlock{
$rail->getFloorY() + $y,
$rail->getFloorZ() + $blocks[1][1]
);
$idToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getID();
$metaToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getMetadata();
$railBlock = $rail->level->getBlock($v3);
$idToConnect = $railBlock->getID();
$metaToConnect = $railBlock->getMetadata();
if(!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
$xDiff = $damage - $v3.getFloorX();
$zDiff = $damage - $v3.getFloorZ();
$xDiff = $this->getFloorX() - $v3->getFloorX();
$zDiff = $this->getFloorZ() - $v3->getFloorZ();
foreach($blocks as $xz){
if ($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
array_push($connected[], $v3);
$connected[] = $v3;
}
}
return $connected;
@ -111,7 +106,7 @@ class RailBlock extends FlowableBlock{
$this->meta = $subtract[0]->x === 0 ? 0 : 1;
}
}
$this->level->setBlock($rail, new RailBlock($this.getDamage()), true, true);
$this->level->setBlock($rail, new RailBlock($this->meta), true, true);
}
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){

View file

@ -73,7 +73,7 @@ abstract class ProtocolInfo{
const CHAT_PACKET = 0xb6;
const ADVENTURE_SETTINGS_PACKET = 0xb7;
const ENTITY_DATA_PACKET = 0xb8;
//const PLAYER_INPUT_PACKET = 0xb9;
const PLAYER_INPUT_PACKET = 0xb9;
}
/*Unused:

View file

@ -325,6 +325,9 @@ class RakNetParser{
break;
case ProtocolInfo::SET_ENTITY_LINK_PACKET:
$data = new SetEntityLinkPacket;
case ProtocolInfo::PLAYER_INPUT_PACKET:
$data = new PlayerInputPacket;
break;
default:
$data = new UnknownPacket();
$data->packetID = $pid;