1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Disable collision for player.

Discussion in 'Development' started by kriskotooBG, Aug 21, 2019.

  1. kriskotooBG

    kriskotooBG Spider Jockey

    Messages:
    46
    GitHub:
    kriskotoobg
    What I'm trying to do is basically disable a player's collision; you can imagine it as gamemode spectator, but in gamemode creative. I looked through the Player class but didn't see anything that could help me...

    Any help is appreciated!
     
  2. Fadhel

    Fadhel Witch

    Messages:
    68
    GitHub:
    dimbis
    like you are trying to give players noclip?
     
  3. kriskotooBG

    kriskotooBG Spider Jockey

    Messages:
    46
    GitHub:
    kriskotoobg
    yeah basically
     
  4. GamakCZ

    GamakCZ Zombie Pigman

    Messages:
    598
    GitHub:
    GamakCZ
    PHP:
    $pk = new AdventureSettingsPacket();
    $pk->setFlag(AdventureSettingsPacket::NO_CLIPtrue);
    $player->dataPacket($pk);
     
    Muqsit and Fadhel like this.
  5. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Not really the perfect solution but something along those lines.
    Toggling auto jump, respawning, changing op status, toggling flight or changing gamemode are some of the things that'll override that.
    Better handle DataPacketSendEvent where you modify that packet.
     
    kriskotooBG and GamakCZ like this.
  6. kriskotooBG

    kriskotooBG Spider Jockey

    Messages:
    46
    GitHub:
    kriskotoobg
    Unfortunately that did not seem to work correctly, even produced some weird results, But thanks for the suggestion anyways!
     
  7. kriskotooBG

    kriskotooBG Spider Jockey

    Messages:
    46
    GitHub:
    kriskotoobg
    I will look into that! Thanks!
     
  8. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Fadhel likes this.
  9. kriskotooBG

    kriskotooBG Spider Jockey

    Messages:
    46
    GitHub:
    kriskotoobg
    I haven't tested it on a clean install, i did have some plugi installed, but they should not effect it since they aren't really doing anything with entities... but anyways one of the biggest issues is that this code:
    ,
    PHP:
    $sender->setGamemode(1);
                                           
    $packet = new AdventureSettingsPacket();
    $packet ->setFlag(AdventureSettingsPacket::NO_CLIPtrue);
    $packet ->setFlag(AdventureSettingsPacket::NO_PVPtrue);
    $sender->dataPacket($packet);
    does not work, no errors or warnings are given,
    if i remove the setGamemode(1), the code above lets you build and break blocks in gamemode 3, but they don't actually break or place if you try to go in a hole you made in that state in survival mode, you will get damaged as if suffocating, and placing a block in a normal gamemode like creative or survival updates the blocks around it, makes makes them re-appear, as if they ware never broken.
    I'm thinking it's because I'm setting these flags while in creative or survival.. but i honestly don't know
     
    Last edited: Aug 23, 2019
    HimbeersaftLP likes this.
  10. HimbeersaftLP

    HimbeersaftLP Fish

    Messages:
    2,402
    GitHub:
    HimbeersaftLP
    Thank you for your detailed explanation, very interesting indeed.
    I wonder if this is a client or server bug.
     
  11. kriskotooBG

    kriskotooBG Spider Jockey

    Messages:
    46
    GitHub:
    kriskotoobg
    Ok so I did a bit of testing on a clean new pocketmine v3.9.4, using the following code:
    PHP:
    $packet = new AdventureSettingsPacket();
    $packet->setFlag(AdventureSettingsPacket::NO_CLIPtrue);
    $sender->dataPacket($packet);
    Executing the code in the following gamemodes results in:

    Gamemode 0: Normal behavior.
    Gamemode 1: Normal behavior.
    Gamemode 2: Normal behavior.
    Gamemode 3: When the code gets executed, it allows the player to place and break blocks, placing blocks does not seem to remove them from the inventory as if in creative gamemode, also placing blocks has no animation, or sound. Changing the gamemode back to survival, trying to break the blocks results in the breaking sound being played, but no breaking animation, upon the block being broken, no sound is played, the block disappears and if there are other blocks on any side of the block placed in the same way (with the weird gamemode 3) removes them as well, without sound or item drops, interacting aka right clicking the blocks seems to update them the same way, making them disappear, and any surrounding blocks (that ware placed in the weird gamemode 3) as well. Mining blocks in the weird gamemode 3 produces the following: Blocks are broken instantly as if in gamemode 1, but without any particles, sounds, or animations. Changing the gamemode back to survival and walking in the "invisible" blocks damages the player as if they are suffocating, trying to break the surrounding blocks while standing inside the "invisible" blocks, breaks the real blocks normally but has no effect on the "invisible" ones, as if they don't exist, item drops freely move through the "invisible" blocks, placing a block "inside" the invisible blocks (by placing it on a "real" block) updates the "invisible" blocks directly touching the newly placed "real" block, and they re-appear as if never broken. Flowing water blocks do not go inside the "invisible" blocks instead it flows around them as if they are there, placing a water source block or any other block inside an area of "invisible" blocks makes the blocks update as said above, on interaction aka right clicking the blocks they update as said above, reloading the server has no effect on the blocks, reloading the chunks (by walking away from them and coming back) removes all of the "weird" blocks, relogging does the same most likely just because the chunks get reloaded. Restarting the server does the same.

    I know this is a bit of-topic but I think its good to share what I found.
     
    HimbeersaftLP likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.