Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

ProtocolSupportPE has been created, and I need help

Comments in 'Plugin Development' started by MrGenga, Oct 8, 2015.

Thread Status:
Not open for further replies.
  1. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    I created ProtocolSupportPE, but now I not tested it. I want to add MCPC protocol support, and I used BigBrother. But, when I recoded this to 0.11(it is a hard job) I have two problems: first - chunks are not loaded in MCPC client, second - I don't know alternative for MESSAGE_PACKET from 20th protocol. You can answer this question? :(
    Jelly9912 likes this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    TextPacket.
  3. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    I try this, when recoding BigBrother, but chat it is full empty. I trying send message from console, not worked.
    And... Why chunks are lagged? I spawned in the angle of winter biome, and I can't move, and other part of world is invisible.
    And :)D)... How to set skin of player, before him connected to server, because when I recoded BigBrother I need to recode Server.php with this fix. Minecraft PC don't send skin, and if player don't have skin, or have not correct skin in connect packet, server close him.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Can't you just not send the skin? Why is it necessary to modify it?
    MrGenga likes this.
  5. MrGenga
    Offline

    MrGenga Active Member

    Joined:
    Jul 24, 2015
    Posts:
    75
    Minecraft User:
    MrGenga
    Oh, I know now how to cancel closing "Invalid skin."! Edit DesktopPlayer, in function close():
    PHP:
    if($reason == "disconnectionScreen.invalidSkin") {
    $skin file_get_contents("http://mrgenga.tk/skin.php?url=http://skins.minecraft.net/MinecraftSkins/"$this->getName().".png");
    $steve ""//steve skin is empty here
    if($skin == "fail") { $this->setSkin($stevefalse); }
    else { 
    $this->setSkin($skinfalse); }
    //code from Player.php

    $this->server->getPluginManager()->callEvent($ev = new PlayerPreLoginEvent($this"Plugin reason"));
    if(
    $ev->isCancelled()){
    $this->close(""$ev->getKickMessage());

    break;
    }

    if(!
    $this->server->isWhitelisted(strtolower($this->getName()))){
    $this->close($this->getLeaveMessage(), "Server is white-listed");

    break;
    }elseif(
    $this->server->getNameBans()->isBanned(strtolower($this->getName())) or $this->server->getIPBans()->isBanned($this->getAddress())){
    $this->close($this->getLeaveMessage(), "You are banned");

    break;
    }

    if(
    $this->hasPermission(Server::BROADCAST_CHANNEL_USERS)){
    $this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_USERS$this);
    }
    if(
    $this->hasPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE)){
    $this->server->getPluginManager()->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE$this);
    }

    foreach(
    $this->server->getOnlinePlayers() as $p){
    if(
    $p !== $this and strtolower($p->getName()) === strtolower($this->getName())){
    if(
    $p->kick("logged in from another location") === false){
    $this->close($this->getLeaveMessage(), "Logged in from another location");

    $timings->stopTiming();
    return;
    }
    }
    }

    $nbt $this->server->getOfflinePlayerData($this->username);
    if(!isset(
    $nbt->NameTag)){
    $nbt->NameTag = new String("NameTag"$this->username);
    }else{
    $nbt["NameTag"] = $this->username;
    }
    $this->gamemode $nbt["playerGameType"] & 0x03;
    if(
    $this->server->getForceGamemode()){
    $this->gamemode $this->server->getGamemode();
    $nbt->playerGameType = new Int("playerGameType"$this->gamemode);
    }

    $this->allowFlight $this->isCreative();


    if((
    $level $this->server->getLevelByName($nbt["Level"])) === null){
    $this->setLevel($this->server->getDefaultLevel());
    $nbt["Level"] = $this->level->getName();
    $nbt["Pos"][0] = $this->level->getSpawnLocation()->x;
    $nbt["Pos"][1] = $this->level->getSpawnLocation()->y;
    $nbt["Pos"][2] = $this->level->getSpawnLocation()->z;
    }else{
    $this->setLevel($level);
    }

    if(!(
    $nbt instanceof Compound)){
    $this->close($this->getLeaveMessage(), "Invalid data");

    break;
    }

    $this->achievements = [];

    /** @var Byte $achievement */
    foreach($nbt->Achievements as $achievement){
    $this->achievements[$achievement->getName()] = $achievement->getValue() > true false;
    }

    $nbt->lastPlayed = new Long("lastPlayed"floor(microtime(true) * 1000));
    if(
    $this->server->getAutoSave()){
    $this->server->saveOfflinePlayerData($this->username$nbttrue);
    }

    parent::__construct($this->level->getChunk($nbt["Pos"][0] >> 4$nbt["Pos"][2] >> 4true), $nbt);
    $this->loggedIn true;

    $this->server->getPluginManager()->callEvent($ev = new PlayerLoginEvent($this"Plugin reason"));
    if(
    $ev->isCancelled()){
    $this->close($this->getLeaveMessage(), $ev->getKickMessage());

    break;
    }

    if(
    $this->isCreative()){
    $this->inventory->setHeldItemSlot(0);
    }else{
    $this->inventory->setHeldItemSlot($this->inventory->getHotbarSlotIndex(0));
    }

    $pk = new PlayStatusPacket();
    $pk->status PlayStatusPacket::LOGIN_SUCCESS;
    $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));

    if(
    $this->spawnPosition === null and isset($this->namedtag->SpawnLevel) and ($level $this->server->getLevelByName($this->namedtag["SpawnLevel"])) instanceof Level){
    $this->spawnPosition = new Position($this->namedtag["SpawnX"], $this->namedtag["SpawnY"], $this->namedtag["SpawnZ"], $level);
    }

    $spawnPosition $this->getSpawn();

    $pk = new StartGamePacket();
    $pk->seed = -1;
    $pk->$this->x;
    $pk->$this->y;
    $pk->$this->z;
    $pk->spawnX = (int) $spawnPosition->x;
    $pk->spawnY = (int) $spawnPosition->y;
    $pk->spawnZ = (int) $spawnPosition->z;
    $pk->generator 1//0 old, 1 infinite, 2 flat
    $pk->gamemode $this->gamemode 0x01;
    $pk->eid 0//Always use EntityID as zero for the actual player
    $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));

    $pk = new SetTimePacket();
    $pk->time $this->level->getTime();
    $pk->started $this->level->stopTime == false;
    $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));

    $pk = new SetSpawnPositionPacket();
    $pk->= (int) $spawnPosition->x;
    $pk->= (int) $spawnPosition->y;
    $pk->= (int) $spawnPosition->z;
    $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));

    $pk = new SetHealthPacket();
    $pk->health $this->getHealth();
    $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));

    $pk = new SetDifficultyPacket();
    $pk->difficulty $this->server->getDifficulty();
    $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));

    $this->server->getLogger()->info($this->getServer()->getLanguage()->translateString("pocketmine.player.logIn", [
    TextFormat::AQUA $this->username TextFormat::WHITE,
    $this->ip,
    $this->port,
    $this->id,
    $this->level->getName(),
    round($this->x4),
    round($this->y4),
    round($this->z4)
    ]));

    if(
    $this->isOp()){
    $this->setRemoveFormat(false);
    }

    if(
    $this->gamemode === Player::SPECTATOR){
    $pk = new ContainerSetContentPacket();
    $pk->windowid ContainerSetContentPacket::SPECIAL_CREATIVE;
    $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
    }else{
    $pk = new ContainerSetContentPacket();
    $pk->windowid ContainerSetContentPacket::SPECIAL_CREATIVE;
    $pk->slots Item::getCreativeItems();
    $this->dataPacket($pk->setChannel(Network::CHANNEL_PRIORITY));
    }

    $this->forceMovement $this->teleportPosition $this->getPosition();

    $this->server->onPlayerLogin($this);

    }
    }
Thread Status:
Not open for further replies.

Share This Page

Advertisement