3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-11-03 14:50:19 +01:00

Add precaution if lectern container is not open

Dieser Commit ist enthalten in:
Camotoy 2021-01-22 13:36:27 -05:00
Ursprung 3dc5890649
Commit 1676242c4f
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 7EEFB66FE798081F

Datei anzeigen

@ -31,7 +31,6 @@ import com.github.steveice10.mc.protocol.data.game.world.block.BlockFace;
import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.player.ClientPlayerPlaceBlockPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientClickWindowButtonPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientClickWindowButtonPacket;
import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket; import com.github.steveice10.mc.protocol.packet.ingame.client.window.ClientCloseWindowPacket;
import com.nukkitx.math.vector.Vector3f;
import com.nukkitx.protocol.bedrock.packet.LecternUpdatePacket; import com.nukkitx.protocol.bedrock.packet.LecternUpdatePacket;
import org.geysermc.connector.inventory.LecternContainer; import org.geysermc.connector.inventory.LecternContainer;
import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.GeyserSession;
@ -60,6 +59,10 @@ public class BedrockLecternUpdateTranslator extends PacketTranslator<LecternUpda
session.sendDownstreamPacket(blockPacket); session.sendDownstreamPacket(blockPacket);
} else { } else {
// Bedrock wants to either move a page or exit // Bedrock wants to either move a page or exit
if (!(session.getOpenInventory() instanceof LecternContainer)) {
session.getConnector().getLogger().debug("Expected lectern but it wasn't open!");
return;
}
LecternContainer lecternContainer = (LecternContainer) session.getOpenInventory(); LecternContainer lecternContainer = (LecternContainer) session.getOpenInventory();
if (lecternContainer.getCurrentBedrockPage() == packet.getPage()) { if (lecternContainer.getCurrentBedrockPage() == packet.getPage()) {
// The same page means Bedrock is closing the window // The same page means Bedrock is closing the window