Skip to content
This repository has been archived by the owner on Feb 24, 2024. It is now read-only.

[1.20.4] FakePlayer not spawning #94

Closed
enimaloc opened this issue Dec 20, 2023 · 2 comments
Closed

[1.20.4] FakePlayer not spawning #94

enimaloc opened this issue Dec 20, 2023 · 2 comments

Comments

@enimaloc
Copy link

I've updated to version 1.20.4 via a self-built minestom-ce on the 1_20_4 branch.

I try to make a FakePlayer appear with:

        MinecraftServer.getGlobalEventHandler().addListener(PlayerSpawnEvent.class, e -> {
            System.out.println("e = " + e);
            FakePlayer.initPlayer(UUID.randomUUID(), "Child", fp -> {
                fp.setInstance(container, new Pos(0, 42, 0));
                fp.setRespawnPoint(new Pos(0, 42, 0));
                fp.spawn();
                System.out.println("fp = " + fp);
            });
        });

So, e is printed e = net.minestom.server.event.player.PlayerSpawnEvent@7926d4ab.
But fp is not printed and the fake player does not appear.

@enimaloc
Copy link
Author

enimaloc commented Dec 20, 2023

With this piece of code I log all player in PLAY and CONFIGURATION state:

MinecraftServer.getSchedulerManager().scheduleTask(() -> {  
    System.out.println("MinecraftServer.getConnectionManager().getOnlinePlayers().size() = " + MinecraftServer.getConnectionManager().getOnlinePlayerCount());  
    for (Player player : MinecraftServer.getConnectionManager().getPlayers(ConnectionState.PLAY, ConnectionState.CONFIGURATION)) {  
        System.out.printf("player = %s, state = %s%n", player.getUsername(), player.getPlayerConnection().getClientState());  
    }  
}, TaskSchedule.immediate(), TaskSchedule.tick(20));  

Now, I get my fake player in state HANDSHAKE but when I get I query only PLAY and CONFIGURATION state ?

MinecraftServer.getConnectionManager().getOnlinePlayers().size() = 1  
player = Child, state = HANDSHAKE  
player = enimaloc, state = PLAY  

Anyway, It seems my fake player stuck in HANDSHAKE state.

@mworzala
Copy link

Should be fixed now. Note that you should not call setInstance in the spawn callback. FakePlayers go through the normal config->play sequence meaning you should use the config event to configure the spawning instance.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants