diff --git a/core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java b/core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java index bfa30fed4..9d5bc011c 100644 --- a/core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java +++ b/core/src/main/java/org/geysermc/geyser/entity/type/player/SessionPlayerEntity.java @@ -168,7 +168,7 @@ public class SessionPlayerEntity extends PlayerEntity { /** * Set the player's position without applying an offset or moving the bounding box - * This is used in BedrockMovePlayerTranslator which receives the player's position + * This is used in BedrockMovePlayer which receives the player's position * with the offset pre-applied * * @param position the new position of the Bedrock player diff --git a/core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java b/core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java index 19e56c8a8..1ac38aa35 100644 --- a/core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java +++ b/core/src/main/java/org/geysermc/geyser/network/UpstreamPacketHandler.java @@ -26,6 +26,7 @@ package org.geysermc.geyser.network; import io.netty.buffer.Unpooled; +import org.cloudburstmc.math.vector.Vector2f; import org.cloudburstmc.protocol.bedrock.BedrockDisconnectReasons; import org.cloudburstmc.protocol.bedrock.codec.BedrockCodec; import org.cloudburstmc.protocol.bedrock.codec.compat.BedrockCompat; @@ -38,9 +39,9 @@ import org.cloudburstmc.protocol.bedrock.netty.codec.compression.ZlibCompression import org.cloudburstmc.protocol.bedrock.packet.BedrockPacket; import org.cloudburstmc.protocol.bedrock.packet.LoginPacket; import org.cloudburstmc.protocol.bedrock.packet.ModalFormResponsePacket; -import org.cloudburstmc.protocol.bedrock.packet.MovePlayerPacket; import org.cloudburstmc.protocol.bedrock.packet.NetworkSettingsPacket; import org.cloudburstmc.protocol.bedrock.packet.PlayStatusPacket; +import org.cloudburstmc.protocol.bedrock.packet.PlayerAuthInputPacket; import org.cloudburstmc.protocol.bedrock.packet.RequestNetworkSettingsPacket; import org.cloudburstmc.protocol.bedrock.packet.ResourcePackChunkDataPacket; import org.cloudburstmc.protocol.bedrock.packet.ResourcePackChunkRequestPacket; @@ -290,8 +291,9 @@ public class UpstreamPacketHandler extends LoggingPacketHandler { } @Override - public PacketSignal handle(MovePlayerPacket packet) { // TODO - if (session.isLoggingIn()) { + public PacketSignal handle(PlayerAuthInputPacket packet) { + // This doesn't catch rotation, but for a niche case I don't exactly want to cache rotation... + if (session.isLoggingIn() && !packet.getMotion().equals(Vector2f.ZERO)) { SetTitlePacket titlePacket = new SetTitlePacket(); titlePacket.setType(SetTitlePacket.Type.ACTIONBAR); titlePacket.setText(GeyserLocale.getPlayerLocaleString("geyser.auth.login.wait", session.locale())); diff --git a/core/src/main/java/org/geysermc/geyser/registry/populator/TagRegistryPopulator.java b/core/src/main/java/org/geysermc/geyser/registry/populator/TagRegistryPopulator.java index 4e249d483..bee207a00 100644 --- a/core/src/main/java/org/geysermc/geyser/registry/populator/TagRegistryPopulator.java +++ b/core/src/main/java/org/geysermc/geyser/registry/populator/TagRegistryPopulator.java @@ -31,7 +31,6 @@ import com.google.gson.reflect.TypeToken; import it.unimi.dsi.fastutil.Hash; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; -import it.unimi.dsi.fastutil.objects.Object2ObjectMap; import it.unimi.dsi.fastutil.objects.Object2ObjectOpenCustomHashMap; import it.unimi.dsi.fastutil.objects.ObjectIntPair; import org.cloudburstmc.protocol.bedrock.codec.v671.Bedrock_v671; @@ -90,7 +89,7 @@ public final class TagRegistryPopulator { throw new AssertionError("Unable to load Bedrock runtime item IDs", e); } - Object2ObjectMap javaItemsToBedrockTag = new Object2ObjectOpenCustomHashMap<>(hashStrategy); + var javaItemsToBedrockTag = new Object2ObjectOpenCustomHashMap(hashStrategy); for (var entry : bedrockTags.entrySet()) { List value = entry.getValue(); @@ -129,6 +128,7 @@ public final class TagRegistryPopulator { javaItemsToBedrockTag.put(javaNetworkIdArray, entry.getKey()); } + javaItemsToBedrockTag.trim(); Registries.TAGS.register(palette.rightInt(), javaItemsToBedrockTag); } } diff --git a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java index ea0dc58de..ef6261ead 100644 --- a/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java +++ b/core/src/main/java/org/geysermc/geyser/session/GeyserSession.java @@ -1077,6 +1077,11 @@ public class GeyserSession implements GeyserConnection, GeyserCommandSource { // Download and load the language for the player MinecraftLocale.downloadAndLoadLocale(locale); + +// if (sentSpawnPacket && !GameProtocol.isPre1_21_2(GeyserSession.this)) { +// // Possible form to close. +// upstream.sendPacket(new ClientboundCloseFormPacket()); +// } } @Override diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockBlockActions.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockBlockActions.java similarity index 99% rename from core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockBlockActions.java rename to core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockBlockActions.java index f1b91a0a5..061a04b77 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockBlockActions.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockBlockActions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org + * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.geyser.translator.protocol.bedrock.entity.player; +package org.geysermc.geyser.translator.protocol.bedrock.entity.player.input; import org.cloudburstmc.math.vector.Vector3f; import org.cloudburstmc.math.vector.Vector3i; diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockMovePlayerTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java similarity index 98% rename from core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockMovePlayerTranslator.java rename to core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java index 1940258e4..6220b6623 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockMovePlayerTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockMovePlayer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2022 GeyserMC. http://geysermc.org + * Copyright (c) 2019-2024 GeyserMC. http://geysermc.org * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.geyser.translator.protocol.bedrock.entity.player; +package org.geysermc.geyser.translator.protocol.bedrock.entity.player.input; import org.cloudburstmc.math.vector.Vector3d; import org.cloudburstmc.math.vector.Vector3f; @@ -40,8 +40,10 @@ import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.Serv import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerRotPacket; import org.geysermc.mcprotocollib.protocol.packet.ingame.serverbound.player.ServerboundMovePlayerStatusOnlyPacket; - -public final class BedrockMovePlayerTranslator { +/** + * Holds processing input coming in from the {@link PlayerAuthInputPacket} packet. + */ +final class BedrockMovePlayer { static void translate(GeyserSession session, PlayerAuthInputPacket packet) { SessionPlayerEntity entity = session.getPlayerEntity(); diff --git a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockPlayerAuthInputTranslator.java b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java similarity index 98% rename from core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockPlayerAuthInputTranslator.java rename to core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java index 3c9b41488..02ea02232 100644 --- a/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/BedrockPlayerAuthInputTranslator.java +++ b/core/src/main/java/org/geysermc/geyser/translator/protocol/bedrock/entity/player/input/BedrockPlayerAuthInputTranslator.java @@ -23,7 +23,7 @@ * @link https://github.com/GeyserMC/Geyser */ -package org.geysermc.geyser.translator.protocol.bedrock.entity.player; +package org.geysermc.geyser.translator.protocol.bedrock.entity.player.input; import org.cloudburstmc.math.GenericMath; import org.cloudburstmc.math.vector.Vector2f; @@ -74,7 +74,7 @@ public final class BedrockPlayerAuthInputTranslator extends PacketTranslator mirroredIngredients = new ArrayList<>(ingredients.size()); for (int row = 0; row < height; row++) { for (int col = 0; col < width; col++) { - mirroredIngredients.add(ingredients.get((width - 1 - col) + (row * width))); + int index = col + (row * width); + while (mirroredIngredients.size() <= index) { + mirroredIngredients.add(null); + } + mirroredIngredients.set(index, ingredients.get((width - 1 - col) + (row * width))); } }