Moved the player init call

This commit is contained in:
Felix Cravic 2020-05-26 16:14:52 +02:00
parent b797967151
commit 8ef5a0b394
3 changed files with 23 additions and 30 deletions

View File

@ -160,6 +160,8 @@ public class EntityManager {
while ((waitingPlayer = waitingPlayers.poll()) != null) {
final Player playerCache = waitingPlayer;
playersPool.execute(() -> {
playerCache.init();
PlayerLoginEvent loginEvent = new PlayerLoginEvent();
playerCache.callEvent(PlayerLoginEvent.class, loginEvent);
Instance spawningInstance = loginEvent.getSpawningInstance();

View File

@ -137,42 +137,27 @@ public class Player extends LivingEntity {
setRespawnPoint(new Position(0, 0, 0));
// FakePlayer init its connection there
playerConnectionInit();
init();
// Some client update
getPlayerConnection().sendPacket(getPropertiesPacket()); // Send default properties
refreshHealth();
refreshAbilities();
sendUpdateHealthPacket();
this.settings = new PlayerSettings();
this.inventory = new PlayerInventory(this);
setCanPickupItem(true); // By default
this.gameMode = GameMode.SURVIVAL;
this.dimension = Dimension.OVERWORLD;
this.levelType = LevelType.DEFAULT;
refreshPosition(0, 0, 0);
// FakePlayer init its connection there
playerConnectionInit();
MinecraftServer.getEntityManager().addWaitingPlayer(this);
}
/**
* Used when the player is created
* Used when the player is created ({@link EntityManager#waitingPlayersTick()})
* Init the player and spawn him
*/
protected void init() {
GameMode gameMode = GameMode.SURVIVAL;
Dimension dimension = Dimension.OVERWORLD;
LevelType levelType = LevelType.DEFAULT;
final float x = 0;
final float y = 0;
final float z = 0;
this.dimension = dimension;
this.gameMode = gameMode;
refreshLevelType(levelType);
refreshPosition(x, y, z);
// TODO complete login sequence with optionals packets
JoinGamePacket joinGamePacket = new JoinGamePacket();
@ -249,6 +234,13 @@ public class Player extends LivingEntity {
}
}
// Recipes end
// Some client update
playerConnection.sendPacket(getPropertiesPacket()); // Send default properties
refreshHealth();
refreshAbilities();
sendUpdateHealthPacket();
}
/**
@ -1389,10 +1381,6 @@ public class Player extends LivingEntity {
sendPacketToViewersAndSelf(playerInfoPacket);
}
protected void refreshLevelType(LevelType levelType) {
this.levelType = levelType;
}
public void refreshOnGround(boolean onGround) {
this.onGround = onGround;
}

View File

@ -16,8 +16,11 @@ public class LoginStartPacket implements ClientPreplayPacket {
@Override
public void process(PlayerConnection connection, ConnectionManager connectionManager) {
// TODO send encryption request OR directly login success
UUID adam = UUID.fromString("58ffa9d8-aee1-4587-8b79-41b754f6f238");
UUID playerUuid = UUID.fromString("ab70ecb4-2346-4c14-a52d-7a091507c24e");//UUID.randomUUID();
// TODO: Skin
//UUID adam = UUID.fromString("58ffa9d8-aee1-4587-8b79-41b754f6f238");
//UUID mode = UUID.fromString("ab70ecb4-2346-4c14-a52d-7a091507c24e");
UUID playerUuid = UUID.randomUUID();
LoginSuccessPacket successPacket = new LoginSuccessPacket(playerUuid, username);
connection.sendPacket(successPacket);