From d74e5635e4b0f803ae8ad1d277f22b6029ee023f Mon Sep 17 00:00:00 2001 From: bundabrg Date: Sun, 23 Aug 2020 19:29:41 +0800 Subject: [PATCH] Allow pre-downstream initialization to allow Custom Windows Also forever fix that spawn dropping feeling --- .../connector/network/session/GeyserSession.java | 14 +++++++++++++- ...drockSetLocalPlayerAsInitializedTranslator.java | 13 +------------ .../translators/java/JavaJoinGameTranslator.java | 8 ++++---- 3 files changed, 18 insertions(+), 17 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java index c2be95dab71..9463010ed4f 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/GeyserSession.java @@ -311,7 +311,10 @@ public void connect(RemoteServer remoteServer) { gamerulePacket.getGameRules().add(new GameRuleData<>("naturalregeneration", false)); upstream.sendPacket(gamerulePacket); - login(); + // Spawn the player + PlayStatusPacket playStatusPacket = new PlayStatusPacket(); + playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN); + sendUpstreamPacket(playStatusPacket); } public void login() { @@ -420,6 +423,15 @@ public void connected(ConnectedEvent event) { // Download and load the language for the player LocaleUtils.downloadAndLoadLocale(locale); + + for (Entity entity : getEntityCache().getEntities().values()) { + if (!entity.isValid()) { + if (entity instanceof PlayerEntity) { + SkinUtils.requestAndHandleSkinAndCape((PlayerEntity) entity, GeyserSession.this, null); + } + entity.spawnEntity(GeyserSession.this); + } + } } @Override diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java index a36e516b1de..380fba54e6c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/bedrock/BedrockSetLocalPlayerAsInitializedTranslator.java @@ -25,12 +25,9 @@ package org.geysermc.connector.network.translators.bedrock; -import org.geysermc.connector.entity.Entity; -import org.geysermc.connector.entity.PlayerEntity; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; import org.geysermc.connector.network.translators.Translator; -import org.geysermc.connector.utils.SkinUtils; import com.nukkitx.protocol.bedrock.packet.SetLocalPlayerAsInitializedPacket; @@ -41,15 +38,7 @@ public void translate(SetLocalPlayerAsInitializedPacket packet, GeyserSession se if (session.getPlayerEntity().getGeyserId() == packet.getRuntimeEntityId()) { if (!session.getUpstream().isInitialized()) { session.getUpstream().setInitialized(true); - - for (Entity entity : session.getEntityCache().getEntities().values()) { - if (!entity.isValid()) { - if (entity instanceof PlayerEntity) { - SkinUtils.requestAndHandleSkinAndCape((PlayerEntity) entity, session, null); - } - entity.spawnEntity(session); - } - } + session.login(); } } } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java index a8fc122bd01..e74eae11f44 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/JavaJoinGameTranslator.java @@ -74,10 +74,10 @@ public void translate(ServerJoinGamePacket packet, GeyserSession session) { session.sendUpstreamPacket(playerGameTypePacket); session.setGameMode(packet.getGameMode()); - SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); - entityDataPacket.setRuntimeEntityId(entity.getGeyserId()); - entityDataPacket.getMetadata().putAll(entity.getMetadata()); - session.sendUpstreamPacket(entityDataPacket); +// SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); +// entityDataPacket.setRuntimeEntityId(entity.getGeyserId()); +// entityDataPacket.getMetadata().putAll(entity.getMetadata()); +// session.sendUpstreamPacket(entityDataPacket); // Send if client should show respawn screen GameRulesChangedPacket gamerulePacket = new GameRulesChangedPacket();