mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-23 21:19:44 +00:00
packet added, small fixes to rail block
This commit is contained in:
parent
53102e027e
commit
819803c634
5 changed files with 24 additions and 32 deletions
|
|
@ -1784,19 +1784,12 @@ class Player{
|
||||||
if($target->linkedEntity != null){
|
if($target->linkedEntity != null){
|
||||||
break;
|
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;
|
$target->linkedEntity = $this->entity;
|
||||||
$this->entity->isInMinecart = true;
|
$this->entity->isInMinecart = true;
|
||||||
$pk = new SetEntityLinkPacket();
|
$pk = new SetEntityLinkPacket();
|
||||||
$pk->rider = $target->eid;
|
$pk->rider = $target->eid;
|
||||||
$pk->riding = $this->entity->eid;
|
$pk->riding = $this->entity->eid;
|
||||||
$pk->type = 2;
|
$pk->type = 1;
|
||||||
$this->dataPacket($pk);
|
$this->dataPacket($pk);
|
||||||
$needsBreak = true;
|
$needsBreak = true;
|
||||||
|
|
||||||
|
|
@ -2272,6 +2265,8 @@ class Player{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case ProtocolInfo::PLAYER_INPUT_PACKET:
|
||||||
|
break; //TODO player input-
|
||||||
default:
|
default:
|
||||||
console("[DEBUG] Unhandled 0x" . dechex($packet->pid()) . " data packet for " . $this->username . " (" . $this->clientID . "): " . print_r($packet, true), true, true, 2);
|
console("[DEBUG] Unhandled 0x" . dechex($packet->pid()) . " data packet for " . $this->username . " (" . $this->clientID . "): " . print_r($packet, true), true, true, 2);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,6 @@ require_once(FILE_PATH . "/src/material/Item.php");
|
||||||
|
|
||||||
require_once(FILE_PATH . "/src/material/item/armor/ArmorItem.php");
|
require_once(FILE_PATH . "/src/material/item/armor/ArmorItem.php");
|
||||||
|
|
||||||
|
|
||||||
require_all(FILE_PATH . "src/");
|
require_all(FILE_PATH . "src/");
|
||||||
|
|
||||||
$inc = get_included_files();
|
$inc = get_included_files();
|
||||||
|
|
|
||||||
|
|
@ -2,23 +2,16 @@
|
||||||
|
|
||||||
class RailBlock extends FlowableBlock{
|
class RailBlock extends FlowableBlock{
|
||||||
public function __construct($meta = 0){
|
public function __construct($meta = 0){
|
||||||
parent::__construct(RAIL, 0, "Rail");
|
parent::__construct(RAIL, $meta, "Rail");
|
||||||
$this->hardness = 0.7;
|
$this->hardness = 0.7;
|
||||||
$this->isFullBlock = false;
|
$this->isFullBlock = false;
|
||||||
$this->isSolid = true;
|
$this->isSolid = false;
|
||||||
$this->meta = $meta;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static $shouldconnectrails = false;
|
public static $shouldconnectrails = false;
|
||||||
|
|
||||||
private function isRailBlock($id){
|
private function isRailBlock($id){
|
||||||
switch($id){
|
return $id === RAIL || $id === POWERED_RAIL;
|
||||||
case RAIL:
|
|
||||||
case POWERED_RAIL:
|
|
||||||
return true;
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isValidRailMeta($meta){
|
private function isValidRailMeta($meta){
|
||||||
|
|
@ -61,14 +54,15 @@ class RailBlock extends FlowableBlock{
|
||||||
$rail->getFloorY() + $y,
|
$rail->getFloorY() + $y,
|
||||||
$rail->getFloorZ() + $blocks[0][1]
|
$rail->getFloorZ() + $blocks[0][1]
|
||||||
);
|
);
|
||||||
$idToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getID();
|
$railBlock = $rail->level->getBlock($v3);
|
||||||
$metaToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getMetadata();
|
$idToConnect = $railBlock->getID();
|
||||||
|
$metaToConnect = $railBlock->getMetadata();
|
||||||
if (!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
|
if (!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
|
||||||
$xDiff = $damage - $v3->getFloorX();
|
$xDiff = $this->getFloorX() - $v3->getFloorX();
|
||||||
$zDiff = $damage - $v3->getFloorZ();
|
$zDiff = $this->getFloorZ() - $v3->getFloorZ();
|
||||||
foreach($blocks as $xz) {
|
foreach($blocks as $xz) {
|
||||||
if($xz[0] !== xDiff || $xz[1] !== zDiff) continue;
|
if($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
|
||||||
array_push($connected[], $v3);
|
$connected[] = $v3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach($deltaY as $y){
|
foreach($deltaY as $y){
|
||||||
|
|
@ -77,14 +71,15 @@ class RailBlock extends FlowableBlock{
|
||||||
$rail->getFloorY() + $y,
|
$rail->getFloorY() + $y,
|
||||||
$rail->getFloorZ() + $blocks[1][1]
|
$rail->getFloorZ() + $blocks[1][1]
|
||||||
);
|
);
|
||||||
$idToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getID();
|
$railBlock = $rail->level->getBlock($v3);
|
||||||
$metaToConnect = $rail->level->getBlock(v3.getFloorX(), v3.getFloorY(), v3.getFloorZ())->getMetadata();
|
$idToConnect = $railBlock->getID();
|
||||||
|
$metaToConnect = $railBlock->getMetadata();
|
||||||
if(!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
|
if(!$this->isRailBlock($idToConnect) || !$this->isValidRailMeta($metaToConnect)) continue;
|
||||||
$xDiff = $damage - $v3.getFloorX();
|
$xDiff = $this->getFloorX() - $v3->getFloorX();
|
||||||
$zDiff = $damage - $v3.getFloorZ();
|
$zDiff = $this->getFloorZ() - $v3->getFloorZ();
|
||||||
foreach($blocks as $xz){
|
foreach($blocks as $xz){
|
||||||
if ($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
|
if ($xz[0] !== $xDiff || $xz[1] !== $zDiff) continue;
|
||||||
array_push($connected[], $v3);
|
$connected[] = $v3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $connected;
|
return $connected;
|
||||||
|
|
@ -111,7 +106,7 @@ class RailBlock extends FlowableBlock{
|
||||||
$this->meta = $subtract[0]->x === 0 ? 0 : 1;
|
$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){
|
public function place(Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ abstract class ProtocolInfo{
|
||||||
const CHAT_PACKET = 0xb6;
|
const CHAT_PACKET = 0xb6;
|
||||||
const ADVENTURE_SETTINGS_PACKET = 0xb7;
|
const ADVENTURE_SETTINGS_PACKET = 0xb7;
|
||||||
const ENTITY_DATA_PACKET = 0xb8;
|
const ENTITY_DATA_PACKET = 0xb8;
|
||||||
//const PLAYER_INPUT_PACKET = 0xb9;
|
const PLAYER_INPUT_PACKET = 0xb9;
|
||||||
|
|
||||||
}
|
}
|
||||||
/*Unused:
|
/*Unused:
|
||||||
|
|
|
||||||
|
|
@ -325,6 +325,9 @@ class RakNetParser{
|
||||||
break;
|
break;
|
||||||
case ProtocolInfo::SET_ENTITY_LINK_PACKET:
|
case ProtocolInfo::SET_ENTITY_LINK_PACKET:
|
||||||
$data = new SetEntityLinkPacket;
|
$data = new SetEntityLinkPacket;
|
||||||
|
case ProtocolInfo::PLAYER_INPUT_PACKET:
|
||||||
|
$data = new PlayerInputPacket;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
$data = new UnknownPacket();
|
$data = new UnknownPacket();
|
||||||
$data->packetID = $pid;
|
$data->packetID = $pid;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue