From 3ffaf5c0e548ff9ace1bc3c6d732a4955045d56c Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 10 Nov 2019 16:53:01 -0600 Subject: [PATCH] Attempt to fix crashes on login --- .../network/LoggingPacketHandler.java | 45 +++++++++++++++++++ .../network/session/GeyserSession.java | 24 +++++++--- .../network/session/UpstreamSession.java | 2 +- .../java/JavaJoinGameTranslator.java | 2 +- .../java/JavaRespawnTranslator.java | 2 + .../player/JavaPlayerHealthTranslator.java | 4 +- .../geysermc/connector/utils/SkinUtils.java | 2 +- 7 files changed, 70 insertions(+), 11 deletions(-) diff --git a/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java b/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java index c46aa66e..dc40fc49 100644 --- a/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java +++ b/connector/src/main/java/org/geysermc/connector/network/LoggingPacketHandler.java @@ -716,4 +716,49 @@ public class LoggingPacketHandler implements BedrockPacketHandler { public boolean handle(VideoStreamConnectPacket packet) { return defaultHandler(packet); } + + @Override + public boolean handle(EmotePacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(TickSyncPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(AnvilDamagePacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(NetworkSettingsPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(PlayerAuthInputPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(SettingsCommandPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(EducationSettingsPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(CompletedUsingItemPacket packet) { + return defaultHandler(packet); + } + + @Override + public boolean handle(MultiplayerSettingsPacket packet) { + return defaultHandler(packet); + } } \ No newline at end of file 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 4a513236..bfe3d4ce 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 @@ -43,7 +43,10 @@ import com.nukkitx.math.vector.Vector3i; import com.nukkitx.protocol.bedrock.BedrockServerSession; import com.nukkitx.protocol.bedrock.data.GamePublishSetting; import com.nukkitx.protocol.bedrock.data.GameRule; +import com.nukkitx.protocol.bedrock.packet.AvailableEntityIdentifiersPacket; +import com.nukkitx.protocol.bedrock.packet.BiomeDefinitionListPacket; import com.nukkitx.protocol.bedrock.packet.LevelChunkPacket; +import com.nukkitx.protocol.bedrock.packet.NetworkChunkPublisherUpdatePacket; import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket; import com.nukkitx.protocol.bedrock.packet.StartGamePacket; import com.nukkitx.protocol.bedrock.packet.TextPacket; @@ -131,8 +134,13 @@ public class GeyserSession implements Player { Vector3f pos = Vector3f.ZERO; int chunkX = pos.getFloorX() >> 4; int chunkZ = pos.getFloorZ() >> 4; - for (int x = -3; x < 3; x++) { - for (int z = -3; z < 3; z++) { + for (int x = -5; x < 5; x++) { + for (int z = -5; z < 5; z++) { + NetworkChunkPublisherUpdatePacket chunkPublisherUpdatePacket = new NetworkChunkPublisherUpdatePacket(); + chunkPublisherUpdatePacket.setPosition(pos.toInt()); + chunkPublisherUpdatePacket.setRadius(renderDistance << 4); + upstream.sendPacket(chunkPublisherUpdatePacket); + LevelChunkPacket data = new LevelChunkPacket(); data.setChunkX(chunkX + x); data.setChunkZ(chunkZ + z); @@ -142,6 +150,9 @@ public class GeyserSession implements Player { } } + upstream.sendPacket(new BiomeDefinitionListPacket()); + upstream.sendPacket(new AvailableEntityIdentifiersPacket()); + PlayStatusPacket playStatusPacket = new PlayStatusPacket(); playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN); upstream.sendPacket(playStatusPacket); @@ -279,15 +290,15 @@ public class GeyserSession implements Player { startGamePacket.setPlayerPosition(Vector3f.from(0, 69, 0)); startGamePacket.setRotation(Vector2f.from(1, 1)); - startGamePacket.setSeed(0); + startGamePacket.setSeed(-1); startGamePacket.setDimensionId(playerEntity.getDimension()); startGamePacket.setGeneratorId(1); startGamePacket.setLevelGamemode(0); startGamePacket.setDifficulty(1); startGamePacket.setDefaultSpawn(Vector3i.ZERO); startGamePacket.setAcheivementsDisabled(true); - startGamePacket.setTime(0); - startGamePacket.setEduLevel(false); + startGamePacket.setTime(-1); + startGamePacket.setEduEditionOffers(0); startGamePacket.setEduFeaturesEnabled(false); startGamePacket.setRainLevel(0); startGamePacket.setLightningLevel(0); @@ -313,12 +324,13 @@ public class GeyserSession implements Player { startGamePacket.setLevelId("world"); startGamePacket.setWorldName("world"); startGamePacket.setPremiumWorldTemplateId("00000000-0000-0000-0000-000000000000"); - startGamePacket.setCurrentTick(0); + // startGamePacket.setCurrentTick(0); startGamePacket.setEnchantmentSeed(0); startGamePacket.setMultiplayerCorrelationId(""); startGamePacket.setBlockPalette(Toolbox.BLOCKS); startGamePacket.setItemEntries(Toolbox.ITEMS); startGamePacket.setVanillaVersion(GeyserConnector.BEDROCK_PACKET_CODEC.getMinecraftVersion()); + // startGamePacket.setMovementServerAuthoritative(true); upstream.sendPacket(startGamePacket); } } diff --git a/connector/src/main/java/org/geysermc/connector/network/session/UpstreamSession.java b/connector/src/main/java/org/geysermc/connector/network/session/UpstreamSession.java index d14ff752..5992592f 100644 --- a/connector/src/main/java/org/geysermc/connector/network/session/UpstreamSession.java +++ b/connector/src/main/java/org/geysermc/connector/network/session/UpstreamSession.java @@ -18,7 +18,7 @@ public class UpstreamSession { public void sendPacket(@NonNull BedrockPacket packet) { if (isClosed()) return; - + session.sendPacket(packet); } 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 11644a08..87bb62e0 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 @@ -49,7 +49,7 @@ public class JavaJoinGameTranslator extends PacketTranslator session.getUpstream().sendPacket(playerGameTypePacket); session.setGameMode(packet.getGamemode()); + /* PlayStatusPacket playStatusPacket = new PlayStatusPacket(); playStatusPacket.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN); session.getUpstream().sendPacket(playStatusPacket); + */ } private int getDimension(int javaDimension) { diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerHealthTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerHealthTranslator.java index b5b655ea..1abd4c1c 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerHealthTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerHealthTranslator.java @@ -63,8 +63,8 @@ public class JavaPlayerHealthTranslator extends PacketTranslator