Passengers and vehicles not being ticked

Discussion in 'Plugin Development' started by bergerkiller, Mar 30, 2013.

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

    bergerkiller

    Disclaimer: This is not your occasional 'what is wrong with my code' question. I have a bit of an issue, and it is a tricky one and has to do with CraftBukkit/NMS internals. If you have no experience in these fields, please move on. Considering the level of knowledge of the posts I see here I have little hope of finding an answer here, but I guess it's worth trying.

    Situation: Right after adding a new Minecart to a world, I set it's passenger to the player.

    Background info: Prior to the player entering the Minecart, the Player is teleported towards the Minecart on the same world. [Code (let me warn you, it's more than just Bukkit]

    Problem: For some reason, the onTick method of the Minecart is no longer being called after setting the player passenger. When the player leaves the minecart again, ticking continues. It works 'usually' when I set the passenger after a delay (1 tick) instead of directly.

    Question: What is the reason the Minecart is no longer ticked when setting a player passenger right after spawning? Where do I look? Solutions? Ideas?

    I have looked through 80% of net.minecraft.server, focussing on mainly access to '.vehicle' and '.passenger'. The only viable thing I found was related to the Packet10Flying packet handler, where it does some strange vehicle-related logic. However, I could not find out why ticking the Minecart (which occurs in the World tick method) stopped happening.

    Another interesting fact is that the [sometimes] player can no longer interact with this Minecart after exiting it. It is immune to all damage and right-click interactions.

    Note that the cause can be many things, considering I use my own spawning methods for teleportation. Anything that somewhat gives an idea of 'why ticking is stopped' is helpful enough, I'll track down anything that could result into that.

    All right fixed it. For some reason, playerconnection 'checkMovement' is set to False after teleporting, resulting in the vehicle being disabled. I have no idea what the use of this entire thing is, but changing it to True fixes it.

    Code:
                    // For players, set checkMovement to True - some odd issue
                    if (passenger instanceof CommonPlayer) {
                        Object connection = EntityPlayerRef.playerConnection.get(passenger.getHandle());
                        if (connection != null) {
                            PlayerConnectionRef.checkMovement.set(connection, true);
                        }
                    }
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
Thread Status:
Not open for further replies.

Share This Page