przemykomo / simple-planes

Planes mod for minecraft forge.
GNU Lesser General Public License v3.0
26 stars 26 forks source link

client-server desync on dismounting plane #3

Closed przemykomo closed 4 years ago

przemykomo commented 4 years ago

If player dismounts the plane while it's flying, the plane on client side teleports back to where it was on ground, but server mantains correct position of plane like seen on this video: https://www.youtube.com/watch?v=5Aa07bt0yqI

@adoxentor could you help? I'm out of ideas what could be the cause of this bug.

przemykomo commented 4 years ago

Okay so I made plane not teleport to it's previous location using this:

    @SubscribeEvent
    public static void dismountPlane(EntityMountEvent event) {
        if (event.isDismounting() && event.getEntityBeingMounted() instanceof FurnacePlaneEntity
                && event.getEntityMounting() instanceof ServerPlayerEntity) {
            MinecraftServer minecraftServer = event.getWorldObj().getServer();
            if (minecraftServer != null) {
                new CMoveVehiclePacket(event.getEntityBeingMounted()).processPacket(
                        new ServerPlayNetHandler(minecraftServer, new NetworkManager(PacketDirection.SERVERBOUND),
                                (ServerPlayerEntity) event.getEntityMounting()));
            }
        }
    }

But after unmounting the plane, entire server-client desynchronisation happens. My only idea now is to get ServerPlayNetHandler instance from somewhere instead of creating new.

adoxentor commented 4 years ago

I actually recorded a video myself to ask for help... 🤷‍♂️