Pocketmine-mp: New Player Functions ?

Created on 30 Mar 2017  路  29Comments  路  Source: pmmp/PocketMine-MP

This isn't an issue but i don't know where i can contact you.
Can you add or can you give me the permission to add new Player functions to get the OS of the player, the game edition and other new things discovered in the LoginPacket like $player->getDeviceOs() ?
Thanks.

API To Do

Most helpful comment

Android => 1
iOS => 2
OSX => 3
FireOS => 4
GearVR => 5
Hololens => 6
Win10 => 7
Win32 => 8
Dedicated => 9
A more complete list (as of 1.0.4) @IrishPacks

All 29 comments

If you use the DataPacketReceiveEvent, you can access these fields in the clientData field, which is an associative array of json-decoded data from the packet.

Why you won't add them directly as functions ? It's the easiest way..

If you want i can do it (add them) @dktapps then you won't loose time

I'm currently in the middle of networking rewrites on api3/network, and large amounts of Player.php are going to be stripped apart. I haven't decided how to handle authentication and client data yet, but these will be implemented in the future. Thank you for offering to help though.

No problem tell me if you need me to do it when it will be time to do it

Stop spamming this issue incase dylan locks it.

Hello, I just checked the content of the DataPacketReceiveEvent, but there is no field stating wether the client is Android or Windows10, for example, in clientData.
Are you sure that info is there?
thanks

@ealgueiroqb9 There's no explicit "Android", "Windows10" if that's what you're expecting. You're looking for the DeviceOS field. Up to you to figure out the values, I don't know them.

Sample code

        public function onPacketReceived(\pocketmine\event\server\DataPacketReceiveEvent $e){
            if($e->getPacket() instanceof \pocketmine\network\mcpe\protocol\LoginPacket){
                safe_var_dump($e->getPacket()->clientData);
            }
        }

Sample output

array(13) {
  ["ADRole"]=>
  int(2)
  ["ClientRandomId"]=>
  int(4340844811939028985)
  ["CurrentInputMode"]=>
  int(2)
  ["DefaultInputMode"]=>
  int(2)
  ["DeviceModel"]=>
  string(11) "LGE LG-H955"
  ["DeviceOS"]=>
  int(1)
  ["GameVersion"]=>
  string(7) "1.0.6.0"
  ["GuiScale"]=>
  int(-1)
  ["ServerAddress"]=>
  string(17) "192.168.0.4:19132"
  ["SkinData"]=>
  string(21848) base64 mess
  ["SkinId"]=>
  string(13) "Standard_Alex"
  ["TenantId"]=>
  string(0) ""
  ["UIProfile"]=>
  int(1)
}

I guess 1 is android then...

No, it's actually blank :/

Then you're doing something wrong.

1=> Android
2=> iOS
7=> Windows 10

Android => 1
iOS => 2
OSX => 3
FireOS => 4
GearVR => 5
Hololens => 6
Win10 => 7
Win32 => 8
Dedicated => 9
A more complete list (as of 1.0.4) @IrishPacks

Win32? How in the... I'm not going to question it.

@IrishPacks my best guess is EDU edition is w32, since (I assume) it's not a Windows Store app.

That'd make sense, same thing with OSX I assume.

How MaxOSX ?:0 @JackNoordhuis

And it's not really called OSX anymore #blameapple. But where did you get that list from anyway? Decompiling(well, if you can call it that) minecraft shouldn't give such descriptive names.

Wait, that really makes no sense, MCPE doesn't run on macOS/OSX whatever you want to call it, does it?!

@HimbeersaftLP Edu edition does.

@HimbeersaftLP Edu edition does.

Really?! Sorry didn't know that

maybe it returns all devices type because it's running in a language of programming...

Thanks @JackNoordhuis

maybe it returns all devices type because it's running in a language of programming...

what are you trying to say, because to me it sounds like one of the most idiotic things someone has said regarding programming in a while.

Why was this closed?

@JackNoordhuis are these values still the same? Btw ty

@sero583 Here is the updated list of the os constant
```
const OS_ANDROID = 1;
const OS_IOS = 2;
const OS_OSX = 3;
const OS_FIREOS = 4;
const OS_GEARVR = 5;
const OS_HOLOLENS = 6;
const OS_WIN10 = 7;
const OS_WIN32 = 8;
const OS_DEDICATED = 9;
const OS_ORBIS = 10;
const OS_NX = 11;

Can anyone send an updated version of these constants? Or are they still the same? @MisteFr

Was this page helpful?
0 / 5 - 0 ratings

Related issues

nmo0ory picture nmo0ory  路  3Comments

SuperAdam47 picture SuperAdam47  路  3Comments

XDqrkneZ picture XDqrkneZ  路  3Comments

Muqsit picture Muqsit  路  3Comments

arfianadam picture arfianadam  路  3Comments