From c926c7d8fadb429639638414abe1a3ad304e8f4a Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Mon, 5 Aug 2019 15:30:56 -0500 Subject: [PATCH] Remove unnecessary duplicate of StartGamePacket --- .../network/session/GeyserSession.java | 10 +-- .../java/JavaJoinGameTranslator.java | 1 + .../JavaPlayerPositionRotationTranslator.java | 68 ++++--------------- 3 files changed, 19 insertions(+), 60 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 3333d650..74c4d14a 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 @@ -245,15 +245,15 @@ public class GeyserSession implements PlayerSession, Player { private void startGame() { StartGamePacket startGamePacket = new StartGamePacket(); - startGamePacket.setUniqueEntityId(1); - startGamePacket.setRuntimeEntityId(1); + startGamePacket.setUniqueEntityId(playerEntity.getGeyserId()); + startGamePacket.setRuntimeEntityId(playerEntity.getGeyserId()); startGamePacket.setPlayerGamemode(0); - startGamePacket.setPlayerPosition(new Vector3f(0, 0, 0)); + startGamePacket.setPlayerPosition(new Vector3f(0, 69, 0)); startGamePacket.setRotation(new Vector2f(1, 1)); startGamePacket.setSeed(0); - startGamePacket.setDimensionId(0); - startGamePacket.setGeneratorId(0); + startGamePacket.setDimensionId(playerEntity.getDimension()); + startGamePacket.setGeneratorId(1); startGamePacket.setLevelGamemode(0); startGamePacket.setDifficulty(1); startGamePacket.setDefaultSpawn(new Vector3i(0, 0, 0)); 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 81ff5639..29c4b4b2 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 @@ -46,6 +46,7 @@ public class JavaJoinGameTranslator extends PacketTranslator> 4; diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerPositionRotationTranslator.java b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerPositionRotationTranslator.java index 15f4e9b1..65c5e379 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerPositionRotationTranslator.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/java/entity/player/JavaPlayerPositionRotationTranslator.java @@ -25,20 +25,17 @@ package org.geysermc.connector.network.translators.java.entity.player; -import com.flowpowered.math.vector.Vector2f; import com.flowpowered.math.vector.Vector3f; -import com.flowpowered.math.vector.Vector3i; import com.github.steveice10.mc.protocol.packet.ingame.server.ServerJoinGamePacket; import com.github.steveice10.mc.protocol.packet.ingame.server.entity.player.ServerPlayerPositionRotationPacket; -import com.nukkitx.protocol.bedrock.data.GamePublishSetting; -import com.nukkitx.protocol.bedrock.data.GameRule; import com.nukkitx.protocol.bedrock.packet.MovePlayerPacket; +import com.nukkitx.protocol.bedrock.packet.PlayStatusPacket; import com.nukkitx.protocol.bedrock.packet.SetEntityDataPacket; -import com.nukkitx.protocol.bedrock.packet.StartGamePacket; +import com.nukkitx.protocol.bedrock.packet.SetPlayerGameTypePacket; +import org.geysermc.connector.console.GeyserLogger; import org.geysermc.connector.entity.Entity; import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.translators.PacketTranslator; -import org.geysermc.connector.utils.Toolbox; public class JavaPlayerPositionRotationTranslator extends PacketTranslator { @@ -54,63 +51,24 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator("showcoordinates", true)); - startGamePacket.setPlatformBroadcastMode(GamePublishSetting.PUBLIC); - startGamePacket.setXblBroadcastMode(GamePublishSetting.PUBLIC); - startGamePacket.setCommandsEnabled(true); - startGamePacket.setTexturePacksRequired(false); - startGamePacket.setBonusChestEnabled(false); - startGamePacket.setStartingWithMap(false); - startGamePacket.setTrustingPlayers(true); - startGamePacket.setDefaultPlayerPermission(1); - startGamePacket.setServerChunkTickRange(4); - startGamePacket.setBehaviorPackLocked(false); - startGamePacket.setResourcePackLocked(false); - startGamePacket.setFromLockedWorldTemplate(false); - startGamePacket.setUsingMsaGamertagsOnly(false); - startGamePacket.setFromWorldTemplate(false); - startGamePacket.setWorldTemplateOptionLocked(false); - - startGamePacket.setLevelId("world"); - startGamePacket.setWorldName("world"); - startGamePacket.setPremiumWorldTemplateId("00000000-0000-0000-0000-000000000000"); - startGamePacket.setCurrentTick(0); - startGamePacket.setEnchantmentSeed(0); - startGamePacket.setMultiplayerCorrelationId(""); - startGamePacket.setCachedPalette(Toolbox.CACHED_PALLETE); - startGamePacket.setItemEntries(Toolbox.ITEMS); - session.getUpstream().sendPacket(startGamePacket); + PlayStatusPacket playStatus = new PlayStatusPacket(); + playStatus.setStatus(PlayStatusPacket.Status.LOGIN_SUCCESS); + session.getUpstream().sendPacketImmediately(playStatus); entity.moveAbsolute(new Vector3f(packet.getX(), packet.getY(), packet.getZ()), packet.getPitch(), packet.getYaw()); + SetPlayerGameTypePacket playerGameTypePacket = new SetPlayerGameTypePacket(); + playerGameTypePacket.setGamemode(javaJoinPacket.getGameMode().ordinal()); + session.getUpstream().sendPacket(playerGameTypePacket); + SetEntityDataPacket entityDataPacket = new SetEntityDataPacket(); entityDataPacket.setRuntimeEntityId(entity.getGeyserId()); entityDataPacket.getMetadata().putAll(entity.getMetadata()); session.getUpstream().sendPacket(entityDataPacket); + session.getPlayerEntity().setEntityId(javaJoinPacket.getEntityId()); MovePlayerPacket movePlayerPacket = new MovePlayerPacket(); movePlayerPacket.setRuntimeEntityId(entity.getGeyserId()); @@ -123,6 +81,6 @@ public class JavaPlayerPositionRotationTranslator extends PacketTranslator