mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-20 11:39:43 +00:00
fixes related to packets and entities
This commit is contained in:
parent
abe7846bb9
commit
1ecbc1d308
6 changed files with 12 additions and 16 deletions
|
|
@ -1266,7 +1266,6 @@ class Player{
|
|||
if(EventHandler::callEvent(new DataPacketReceiveEvent($this, $packet)) === BaseEvent::DENY){
|
||||
return;
|
||||
}
|
||||
|
||||
switch($packet->pid()){
|
||||
case 0x01:
|
||||
break;
|
||||
|
|
@ -1359,8 +1358,6 @@ class Player{
|
|||
return;
|
||||
}
|
||||
|
||||
$this->server->send2Discord($this->username . " joined the game");
|
||||
|
||||
$this->auth = true;
|
||||
if(!$this->data->exists("inventory") or ($this->gamemode & 0x01) === 0x01){
|
||||
if(($this->gamemode & 0x01) === 0x01){
|
||||
|
|
@ -1610,7 +1607,10 @@ class Player{
|
|||
//$this->lastChunk = [$packet->chunkX, $packet->chunkZ];
|
||||
break;
|
||||
case ProtocolInfo::UPDATE_BLOCK_PACKET:
|
||||
$this->level->setBlock(new Vector3($packet->x, $packet->y, $packet->z), BlockAPI::get($packet->block, $packet->meta));
|
||||
if($this->gamemode & 0x01 === 0){
|
||||
$this->level->setBlock(new Vector3($packet->x, $packet->y, $packet->z), BlockAPI::get($packet->block, $packet->meta));
|
||||
}
|
||||
|
||||
break;
|
||||
case ProtocolInfo::USE_ITEM_PACKET:
|
||||
if(!($this->entity instanceof Entity)){
|
||||
|
|
@ -1658,7 +1658,6 @@ class Player{
|
|||
$data["posX"] = $packet->posX;
|
||||
$data["posY"] = $packet->posY;
|
||||
$data["posZ"] = $packet->posZ;
|
||||
|
||||
if($packet->face >= 0 and $packet->face <= 5){ //Use Block, place
|
||||
if($this->entity->inAction === true){
|
||||
$this->entity->inAction = false;
|
||||
|
|
|
|||
|
|
@ -628,9 +628,9 @@ class Entity extends Position
|
|||
$fall = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y)), intval($this->z - 0.5)));
|
||||
$down = $this->level->getBlock(new Vector3(intval($this->x - 0.5), intval(ceil($this->y) - 1), intval($this->z - 0.5)));
|
||||
if($fall->isFullBlock === false or $down->isFullBlock === false){
|
||||
$this->server->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"] & 0xFFFF, 0, 1), true);
|
||||
$this->server->api->entity->drop($this, BlockAPI::getItem($this->data["Tile"] & 0xFFFF, $this->data["Metadata"], 1), true);
|
||||
} else{
|
||||
$this->level->setBlock($fall, BlockAPI::get($this->data["Tile"]), true, false, true);
|
||||
$this->level->setBlock($fall, BlockAPI::get($this->data["Tile"], $this->data["Metadata"]), true, false, true);
|
||||
}
|
||||
$this->server->api->handle("entity.motion", $this);
|
||||
$this->close();
|
||||
|
|
@ -969,13 +969,13 @@ class Entity extends Position
|
|||
$player->dataPacket($pk);
|
||||
break;
|
||||
case ENTITY_FALLING:
|
||||
$pk = new AddEntityPacket();
|
||||
$pk = new AddEntityPacket(); //TODO fix
|
||||
$pk->eid = $this->eid;
|
||||
$pk->type = $this->type;
|
||||
$pk->x = $this->x;
|
||||
$pk->y = $this->y;
|
||||
$pk->z = $this->z;
|
||||
$pk->did = - $this->data["Tile"];
|
||||
$pk->did = -($this->data["Tile"] | $this->data["Metadata"] << 0x10);
|
||||
$player->dataPacket($pk);
|
||||
|
||||
$pk = new SetEntityMotionPacket();
|
||||
|
|
@ -1251,10 +1251,7 @@ class Entity extends Position
|
|||
public function sendMotion()
|
||||
{
|
||||
$pk = new SetEntityMotionPacket();
|
||||
$pk->eid = $this->eid;
|
||||
$pk->speedX = $this->speedX;
|
||||
$pk->speedY = $this->speedY;
|
||||
$pk->speedZ = $this->speedZ;
|
||||
$pk->entities = [[$this->eid, $this->speedX, $this->speedY, $this->speedZ]];
|
||||
$this->server->api->player->broadcastPacket($this->level->players, $pk);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ class EntityAI
|
|||
}
|
||||
|
||||
public function updateTasks(){
|
||||
if(!isset($entity) or !($this->entity instanceof Entity)){
|
||||
if(!isset($this->entity) or !($this->entity instanceof Entity)){
|
||||
return;
|
||||
}
|
||||
foreach($this->tasks as $t){
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ class GenericBlock extends Block{
|
|||
"y" => $this->y + 0.5,
|
||||
"z" => $this->z + 0.5,
|
||||
"Tile" => $this->id,
|
||||
"Metadata" => $this->getMetadata()
|
||||
);
|
||||
$server = ServerAPI::request();
|
||||
$this->level->setBlock($this, new AirBlock(), false, false, true);
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ class UpdateBlockPacket extends RakNetDataPacket{
|
|||
}
|
||||
|
||||
public function decode(){
|
||||
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class UseItemPacket extends RakNetDataPacket{
|
|||
$this->z = $this->getInt();
|
||||
$this->face = $this->getInt();
|
||||
$this->item = $this->getShort();
|
||||
$this->meta = $this->getByte(); //Mojang: fix this
|
||||
$this->meta = $this->getShort();
|
||||
$this->eid = $this->getInt();
|
||||
$this->fx = $this->getFloat();
|
||||
$this->fy = $this->getFloat();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue