need help: teleport -> crashes client (sometimes)

Discussion in 'Plugin Development' started by MG127, Jun 12, 2011.

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

    MG127

    when i teleport a player anywhere where he is surrounded by blocks (only the 2 blocks for the player are air), he will be teleported to the highest block at that location, instead of the location i tried to teleport him, and crashes the client and/or kicks him cause of too fast moving

    [cobble][cobble][cobble]
    [cobble][sheep][cobble]
    [cobble][sheep][cobble]
    [cobble][cobble][cobble]
    sideview (sheep = player)


    source is in the jar (if someone wants) :)
    how to config


    with these +0.5 and +0.3 i wanted to be shure that the player will spawn in the middle on a block and not in or in the wall, if i correct Y with +0.2 the player will stuck in the block below

    to.getY()=123.3
    player lands at: 128.3
    Code:
    Location to = new Location (destWorld, Math.floor(X *worlds[i].dm) + 0.5, Y+0.3, Math.floor(Z*worlds[i].dm)+ 0.5);
    player.teleport(to);
    event.setTo(to);
    
    worlds is the actual connection, dm is the distance-modifier (int) (loaded from config.yml)
    Y is the hight, also loaded from the config

    before the one above ...

    Code:
                           if (worlds[i].cobW2) {
                               if (worlds[i].typeW2)
                                   Y=plugin.s1.bedrockceilingarrival;
                               else
                                   Y=plugin.s1.airceilingarrival;
                           }
                           else {
                               if (worlds[i].typeW2)
                                   Y=plugin.s1.bedrockbottomarrival;
                               else
                                   Y=plugin.s1.airbottomarrival;
                           }
    
    so the result is if i teleport from a normal world (bottom) to nether or cavemap (ceiling) or back, the Y is ok, its what it is supposed to be, but the player lands only on the highest block at this location
    i have a function that sets Y to the highest block at that location, but i isnt called if there is bedrock or the destination is at bottom

    so when i make the Y as output it looks like this:
    5.0
    4.7....
    4.2...
    3.4...
    you have arrived in nether
    123.3
    123.3
    ... (5 times)
    and then:
    123.28125
    128.3 <-- !!! why??

    i think i have to workaround again and make this:

    [cobble][cobble][cobble]
    [cobble][air][cobble]
    [cobble][sheep][cobble]
    [cobble][sheep][cobble]
    [cobble][cobble][cobble]
     
Thread Status:
Not open for further replies.

Share This Page