void translate(Class
clazz, P p) { + public
void translate(Class
clazz, P p, GeyserSession s) { try { - ((Consumer
) JAVA.MAP.get(clazz)).accept(p); + ((BiConsumer
) JAVA.MAP.get(clazz)).accept(p, s); } catch (NullPointerException e) { System.err.println("could not translate packet" + p.getClass().getSimpleName()); } diff --git a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java index 0c50411c2..7498c8a70 100644 --- a/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java +++ b/connector/src/main/java/org/geysermc/connector/network/translators/TranslatorsInit.java @@ -4,23 +4,34 @@ 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.ServerPlayerAbilitiesPacket; import com.nukkitx.protocol.bedrock.data.GamePublishSetting; import com.nukkitx.protocol.bedrock.data.GameRule; -import com.nukkitx.protocol.bedrock.packet.StartGamePacket; +import com.nukkitx.protocol.bedrock.packet.*; +import com.nukkitx.protocol.bedrock.v340.serializer.FullChunkDataSerializer_v340; +import com.nukkitx.protocol.bedrock.v340.serializer.ResourcePackChunkDataSerializer_v340; import org.geysermc.connector.utils.Toolbox; public class TranslatorsInit { public static void start() { - + addLoginPackets(); } private static void addLoginPackets() { - Registry.add(ServerJoinGamePacket.class, (x) -> { + Registry.add(ServerJoinGamePacket.class, (x, y) -> { + AdventureSettingsPacket bedrockPacket = new AdventureSettingsPacket(); + + bedrockPacket.setUniqueEntityId(x.getEntityId()); + + y.getUpstream().sendPacketImmediately(bedrockPacket); + + System.out.println(y.getUpstream().isClosed()); + StartGamePacket startGamePacket = new StartGamePacket(); startGamePacket.setUniqueEntityId(x.getEntityId()); startGamePacket.setRuntimeEntityId(x.getEntityId()); startGamePacket.setPlayerGamemode(x.getGameMode().ordinal()); - startGamePacket.setPlayerPosition(new Vector3f(-249, 67, -275)); + startGamePacket.setPlayerPosition(new Vector3f(0, 0, 0)); startGamePacket.setRotation(new Vector2f(1, 1)); startGamePacket.setSeed(1111); @@ -28,7 +39,7 @@ public class TranslatorsInit { startGamePacket.setGeneratorId(0); startGamePacket.setLevelGamemode(x.getGameMode().ordinal()); startGamePacket.setDifficulty(1); - startGamePacket.setDefaultSpawn(new Vector3i(-249, 67, -275)); + startGamePacket.setDefaultSpawn(new Vector3i(0, 0, 0)); startGamePacket.setAcheivementsDisabled(true); startGamePacket.setTime(1300); startGamePacket.setEduLevel(false); @@ -61,6 +72,44 @@ public class TranslatorsInit { startGamePacket.setEnchantmentSeed(1); startGamePacket.setMultiplayerCorrelationId(""); startGamePacket.setCachedPalette(Toolbox.CACHED_PALLETE); + + y.getUpstream().sendPacketImmediately(startGamePacket); + + System.out.println(y.getUpstream().isClosed()); + + Vector3f pos = new Vector3f(0, 0, 0); + + int chunkX = pos.getFloorX() >> 4; + + int chunkZ = pos.getFloorX() >> 4; + + for (int x1 = -3; x1 < 3; x1++) { + + for (int z = -3; z < 3; z++) { + + LevelChunkPacket data = new LevelChunkPacket(); + + data.setChunkX(chunkX + x1); + + data.setChunkZ(chunkZ + z); + + data.setData(new byte[0]); + + y.getUpstream().sendPacketImmediately(data); + + System.out.println(y.getUpstream().isClosed()); + + } + + } + + PlayStatusPacket packet = new PlayStatusPacket(); + + packet.setStatus(PlayStatusPacket.Status.PLAYER_SPAWN); + + y.getUpstream().sendPacket(packet); + + System.out.println(y.getUpstream().isClosed()); }); } } diff --git a/connector/src/main/java/org/geysermc/connector/plugin/GeyserPluginLoader.java b/connector/src/main/java/org/geysermc/connector/plugin/GeyserPluginLoader.java index c0d9e0d97..7df06ee88 100644 --- a/connector/src/main/java/org/geysermc/connector/plugin/GeyserPluginLoader.java +++ b/connector/src/main/java/org/geysermc/connector/plugin/GeyserPluginLoader.java @@ -27,6 +27,7 @@ package org.geysermc.connector.plugin; import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; +import com.nukkitx.protocol.bedrock.handler.BedrockPacketHandler; import org.geysermc.api.Connector; import org.geysermc.api.plugin.Plugin; import java.io.File;