Package org.geysermc.geyser.session
Class GeyserSession
java.lang.Object
org.geysermc.geyser.session.GeyserSession
- All Implemented Interfaces:
org.geysermc.api.connection.Connection,org.geysermc.geyser.api.command.CommandSource,org.geysermc.geyser.api.connection.GeyserConnection,GeyserCommandSource
public class GeyserSession
extends Object
implements org.geysermc.geyser.api.connection.GeyserConnection, GeyserCommandSource
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionGeyserSession(GeyserImpl geyser, org.cloudburstmc.protocol.bedrock.BedrockServerSession bedrockServerSession, io.netty.channel.EventLoop tickEventLoop) -
Method Summary
Modifier and TypeMethodDescriptionvoidStarts ticking the amount of time that the Bedrock client has been swinging their arm, and disables blocking if blocking.voidaddCommandEnum(String name, String enums) voidauthenticate(String username) voidauthenticateWithAuthChain(String authChain) voidvoidauthenticateWithMicrosoftCode(boolean offlineAccess) Present a form window to the user asking to log in with another web browser@NonNull String@NonNull org.geysermc.geyser.api.bedrock.camera.CameraDatacamera()booleanvoidvoidconfirmTeleport(org.cloudburstmc.math.vector.Vector3d position) voidconnect()Send all necessary packets to load Bedrock into the servervoiddisconnect(String reason) voiddisconnect(net.kyori.adventure.text.Component reason) voidensureInEventLoop(Runnable runnable) Moves task to the session event loop if already not in it.@NonNull org.geysermc.geyser.api.entity.EntityDataentities()@NonNull CompletableFuture<@Nullable org.geysermc.geyser.api.entity.type.GeyserEntity>entityByJavaId(@org.checkerframework.checker.index.qual.NonNegative int javaId) voidexecuteInEventLoop(Runnable runnable) Executes a task and prints a stack trace if an error occurs.intCounts how many ticks have occurred since an arm animation started.doubleThe current attack speed of the player.Which dimension Bedrock understands themselves to be in.The overworld dimension which Bedrock Edition uses.longStores when the player started to break a block.Stores the block mappings for this specific version.intUsed for Floodgate skin uploadingintStores session collisionStores cookies sent by the Java server.it.unimi.dsi.fastutil.ints.Int2ObjectMap<GeyserRecipe>@Nullable org.cloudburstmc.protocol.bedrock.data.inventory.ItemDataStores the book that is currently being read.@MonotonicNonNull JavaDimensionThe dimension of the player.@NonNull AbstractGeyserboundPacketHandlerfloatfloatorg.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode@Nullable InventoryHolder<? extends Inventory>Stores the current open Bedrock inventory, including the correct translator.Map<org.cloudburstmc.math.vector.Vector3i,ItemFrameEntity> A map of Vector3i positions to Java entities.Stores the item translations for this specific version.Stores all Java recipes by ID, and matches them to all possible Bedrock recipe identifiers.A cache of IDs from ClientboundKeepAlivePackets that have been sent to the Bedrock client, but haven't been returned to the server.intThe tick in which the player last hit air.org.cloudburstmc.math.vector.Vector3iorg.cloudburstmc.math.vector.Vector2iit.unimi.dsi.fastutil.Pair<org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.CraftingRecipeData,GeyserRecipe> longThe time of the last hit.org.cloudburstmc.math.vector.Vector3iStores the last position of the block the player interacted with.org.cloudburstmc.math.vector.Vector3fStores the position of the player the last time they interacted.longStore the last time the player interacted.String[]As of Java 1.19.3, the client only uses these for commands.Used to return the player to their original rotation after using an item in BedrockInventoryTransactionTranslatorfloatUsed to return players back to their vehicles if the server doesn't want them unmounting.The entity that the client is currently looking at.intint@Nullable InventoryintThe op permission level set by the serverintStores the bedrock inventory id of the pending inventory, or -1 if no inventory is pending.@NonNull PlayerInventoryStores the player inventory and player inventory translatorA map of all players (and their heads) that are wearing a player head with a custom texture.org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.PosegetPose()Stores the Java pose that the server and/or Geyser believes the player currently has.floatCaches current rain strength.intit.unimi.dsi.fastutil.objects.Object2IntMap<org.geysermc.mcprotocollib.protocol.data.game.statistic.Statistic>Stores a map of all statistics sent from the server.intThe amount of ticks requested by the server that the game should proceed with, even if the game tick loop is frozen.it.unimi.dsi.fastutil.ints.Int2ObjectMap<GeyserStonecutterData>Saves a list of all stonecutter recipes, for use in a stonecutter inventory.floatCaches current thunder strength.io.netty.channel.EventLoopThe loop where all packets and ticking is processed to prevent concurrency issues.intgetTicks()The number of ticks that have elapsed since the start of this sessionThe thread that will run every game tick.floatnet.kyori.adventure.key.KeyKeeps track of the world name for respawning.longThe world time in ticks according to the serverbooleanhasPermission(String permission) @NonNull org.geysermc.api.util.InputModebooleanWhether advanced tooltips will be added to the player's items.booleanisCanFly()If the current player can flybooleanisClosed()Accessed on the initial Java and Bedrock packet processing threadsbooleanWhether the client is currently closing an inventory.booleanbooleanControls whether the daylight cycle gamerule has been sent to the client, so the sun/moon remain motionless.booleanbooleanWhether to work around 1.13's different behavior in villager trading menus.booleanStarting in 1.17, Java servers expect thecarriedItemparameter of the serverbound click container packet to be the current contents of the mouse after the transaction has been done.booleanbooleanisFlying()If the current player is flyingbooleanYou can't break blocks, attack entities, or use items while driving in a boatbooleanbooleanbooleanWhether simulated fog has been sent to the client or not.booleanisLinked()booleanbooleanbooleanWhether to emulate pre-1.20 smithing table behavior.booleanStores whether the player intended to place a bucket.booleanbooleanbooleanbooleanbooleanbooleanbooleanSaves if the client is steering left on a boat.booleanSaves if the client is steering right on a boat.booleanbooleanbooleanWhether to use the minecart_improvements experimentbooleanWhether we're expecting statistics to be sent back to us.@MonotonicNonNull StringjavaUuid()@NonNull Stringlocale()voidlockInputs(boolean camera, boolean movement) name()booleanIf successful, also begins connecting to the Java server.intping()@NonNull org.geysermc.api.util.BedrockPlatformplatform()voidplaySoundEvent(org.cloudburstmc.protocol.bedrock.data.SoundEvent sound, org.cloudburstmc.math.vector.Vector3f position) intvoidrefreshEmotes(List<UUID> emotes) voidorg.geysermc.geyser.api.network.RemoteServerremoteServer(org.geysermc.geyser.api.network.RemoteServer remoteServer) voidremoveCommandEnum(String name, String enums) voidvoidscheduleInEventLoop(Runnable runnable, long duration, TimeUnit timeUnit) Schedules a task and prints a stack trace if an error occurs.voidSend an AdventureSettingsPacket to the client with the latest flagsvoidSends a chat message to the Java server.voidsendCommand(String command) Sends a command to the Java server.voidsendDownstreamGamePacket(org.geysermc.mcprotocollib.network.packet.Packet packet) Send a packet to the remote server if in the game state.voidsendDownstreamLoginPacket(org.geysermc.mcprotocollib.network.packet.Packet packet) Send a packet to the remote server if in the login state.voidsendDownstreamPacket(org.geysermc.mcprotocollib.network.packet.Packet packet) Send a packet to the remote server.voidsendDownstreamPacket(org.geysermc.mcprotocollib.network.packet.Packet packet, org.geysermc.mcprotocollib.protocol.data.ProtocolState intendedState) Send a packet to the remote server if in the specified state.voidbooleansendForm(@NonNull org.geysermc.cumulus.form.Form form) booleansendForm(@NonNull org.geysermc.cumulus.form.util.FormBuilder<?, ?, ?> formBuilder) voidsendForm(org.geysermc.cumulus.Form<?> form) Deprecated.since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases.voidsendForm(org.geysermc.cumulus.util.FormBuilder<?, ?> formBuilder) Deprecated.since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases.voidsendGameRule(String gameRule, Object value) Send a gamerule value to the clientvoidSend a packet to the server to indicate client render distance, locale, skin parts, and hand preference.voidsendMessage(@NonNull String message) voidsendUpstreamPacket(org.cloudburstmc.protocol.bedrock.packet.BedrockPacket packet) Queue a packet to be sent to player.voidsendUpstreamPacketImmediately(org.cloudburstmc.protocol.bedrock.packet.BedrockPacket packet) Send a packet immediately to the player.voidsetAdvancedTooltips(boolean advancedTooltips) Whether advanced tooltips will be added to the player's items.voidsetAttackSpeed(double attackSpeed) The current attack speed of the player.voidsetAuthData(AuthData authData) voidsetBedrockDimension(BedrockDimension bedrockDimension) Which dimension Bedrock understands themselves to be in.voidsetBlockBreakStartTime(long blockBreakStartTime) Stores when the player started to break a block.voidsetBlockMappings(BlockMappings blockMappings) Stores the block mappings for this specific version.voidsetBreakingBlock(int breakingBlock) voidsetCanFly(boolean canFly) If the current player can flyvoidsetCertChainData(List<String> certChainData) Used for Floodgate skin uploadingvoidvoidsetClientRenderDistance(int clientRenderDistance) voidsetClosingInventory(boolean closingInventory) Whether the client is currently closing an inventory.voidsetContainerOutputFuture(ScheduledFuture<?> containerOutputFuture) voidsetCookies(Map<String, byte[]> cookies) Stores cookies sent by the Java server.voidsetCrawling(boolean crawling) voidsetCurrentBook(@Nullable org.cloudburstmc.protocol.bedrock.data.inventory.ItemData currentBook) Stores the book that is currently being read.voidsetDaylightCycle(boolean doCycle) Changes the daylight cycle gamerule on the client This is used in the login screen along-side normal usagevoidsetDimensionType(@MonotonicNonNull JavaDimension dimensionType) The dimension of the player.voidsetDroppingLecternBook(boolean droppingLecternBook) voidsetEmulatePost1_13Logic(boolean emulatePost1_13Logic) Whether to work around 1.13's different behavior in villager trading menus.voidsetEmulatePost1_16Logic(boolean emulatePost1_16Logic) Starting in 1.17, Java servers expect thecarriedItemparameter of the serverbound click container packet to be the current contents of the mouse after the transaction has been done.voidsetEmulatePost1_18Logic(boolean emulatePost1_18Logic) voidsetErosionHandler(@NonNull AbstractGeyserboundPacketHandler erosionHandler) voidsetFlying(boolean flying) voidsetFlySpeed(float flySpeed) voidsetGameMode(org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode newGamemode) voidsetGliding(boolean gliding) voidsetInstabuild(boolean instabuild) voidsetInteracting(boolean interacting) voidsetInventoryHolder(@Nullable InventoryHolder<? extends Inventory> inventoryHolder) Stores the current open Bedrock inventory, including the correct translator.voidsetItemMappings(ItemMappings itemMappings) Stores the item translations for this specific version.voidsetLastAirHitTick(int lastAirHitTick) The tick in which the player last hit air.voidsetLastBlockPlaced(BlockItem lastBlockPlaced) voidsetLastBlockPlacePosition(org.cloudburstmc.math.vector.Vector3i lastBlockPlacePosition) voidsetLastChunkPosition(org.cloudburstmc.math.vector.Vector2i lastChunkPosition) voidsetLastCreatedRecipe(it.unimi.dsi.fastutil.Pair<org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.CraftingRecipeData, GeyserRecipe> lastCreatedRecipe) voidsetLastHitTime(long lastHitTime) The time of the last hit.voidsetLastInteractionBlockPosition(org.cloudburstmc.math.vector.Vector3i lastInteractionBlockPosition) Stores the last position of the block the player interacted with.voidsetLastInteractionPlayerPosition(org.cloudburstmc.math.vector.Vector3f lastInteractionPlayerPosition) Stores the position of the player the last time they interacted.voidsetLastInteractionTime(long lastInteractionTime) Store the last time the player interacted.voidAs of Java 1.19.3, the client only uses these for commands.voidsetLookBackScheduledFuture(ScheduledFuture<?> lookBackScheduledFuture) Used to return the player to their original rotation after using an item in BedrockInventoryTransactionTranslatorvoidsetMountVehicleScheduledFuture(ScheduledFuture<?> mountVehicleScheduledFuture) Used to return players back to their vehicles if the server doesn't want them unmounting.voidsetMouseoverEntity(Entity mouseoverEntity) The entity that the client is currently looking at.voidsetOldSmithingTable(boolean oldSmithingTable) Whether to emulate pre-1.20 smithing table behavior.voidsetOpPermissionLevel(int opPermissionLevel) The op permission level set by the servervoidsetPendingOrCurrentBedrockInventoryId(int pendingOrCurrentBedrockInventoryId) Stores the bedrock inventory id of the pending inventory, or -1 if no inventory is pending.voidsetPlacedBucket(boolean placedBucket) Stores whether the player intended to place a bucket.voidsetPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose) Stores the Java pose that the server and/or Geyser believes the player currently has.voidsetReducedDebugInfo(boolean value) Update the cached value for the reduced debug info gamerule.voidsetServerRenderDistance(int renderDistance) voidsetSpawned(boolean spawned) voidsetSpinAttack(boolean spinAttack) voidsetSprinting(boolean sprinting) voidsetSteeringLeft(boolean steeringLeft) Saves if the client is steering left on a boat.voidsetSteeringRight(boolean steeringRight) Saves if the client is steering right on a boat.voidsetStepTicks(int stepTicks) The amount of ticks requested by the server that the game should proceed with, even if the game tick loop is frozen.voidsetStonecutterRecipes(it.unimi.dsi.fastutil.ints.Int2ObjectMap<GeyserStonecutterData> stonecutterRecipes) Saves a list of all stonecutter recipes, for use in a stonecutter inventory.voidsetSwimming(boolean swimming) voidsetUnconfirmedTeleport(TeleportCache unconfirmedTeleport) voidsetUsingExperimentalMinecartLogic(boolean isUsingExperimentalMinecartLogic) Whether to use the minecart_improvements experimentvoidsetWaitingForStatistics(boolean waitingForStatistics) Whether we're expecting statistics to be sent back to us.voidsetWalkSpeed(float walkSpeed) voidsetWorldName(net.kyori.adventure.key.Key worldName) Keeps track of the world name for respawning.voidsetWorldTicks(long worldTicks) The world time in ticks according to the servervoidshakeCamera(float intensity, float duration, @NonNull org.geysermc.geyser.api.bedrock.camera.CameraShake type) voidshowEmote(@NonNull org.geysermc.geyser.api.entity.type.player.GeyserPlayerEntity emoter, @NonNull String emoteId) voidvoidvoidprotected voidtick()Called every Minecraft tick.booleantransfer(@NonNull String address, @org.checkerframework.common.value.qual.IntRange(from=0L, to=65535L) int port) @NonNull org.geysermc.api.util.UiProfilevoidupdateRain(float strength) Sends a packet to update rain strength.voidupdateStatistics(@NonNull it.unimi.dsi.fastutil.objects.Object2IntMap<org.geysermc.mcprotocollib.protocol.data.game.statistic.Statistic> statistics) Used for updating statistic values since we only get changes from the servervoidupdateThunder(float strength) Sends a packet to update thunderstorm strength.voidupdateTickingState(float tickRate, boolean frozen) voiduseItem(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Convenience method to reduce amount of duplicate code.@NonNull Stringversion()@NonNull Stringxuid()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.geysermc.geyser.api.command.CommandSource
sendMessageMethods inherited from interface org.geysermc.geyser.command.GeyserCommandSource
handle, sendLocaleString, sendLocaleString, sendMessage
-
Field Details
-
sentSpawnPacket
protected boolean sentSpawnPacket
-
-
Constructor Details
-
GeyserSession
public GeyserSession(GeyserImpl geyser, org.cloudburstmc.protocol.bedrock.BedrockServerSession bedrockServerSession, io.netty.channel.EventLoop tickEventLoop)
-
-
Method Details
-
connect
public void connect()Send all necessary packets to load Bedrock into the server -
authenticate
-
authenticateWithAuthChain
-
authenticateWithMicrosoftCode
public void authenticateWithMicrosoftCode() -
authenticateWithMicrosoftCode
public void authenticateWithMicrosoftCode(boolean offlineAccess) Present a form window to the user asking to log in with another web browser -
onMicrosoftLoginComplete
If successful, also begins connecting to the Java server. -
disconnect
-
disconnect
public void disconnect(net.kyori.adventure.text.Component reason) -
ensureInEventLoop
Moves task to the session event loop if already not in it. Otherwise, the task is automatically ran. -
executeInEventLoop
Executes a task and prints a stack trace if an error occurs. -
scheduleInEventLoop
Schedules a task and prints a stack trace if an error occurs.The task will not run if the session is closed.
-
updateTickingState
public void updateTickingState(float tickRate, boolean frozen) -
tick
protected void tick()Called every Minecraft tick. -
startSneaking
public void startSneaking() -
stopSneaking
public void stopSneaking() -
setSpinAttack
public void setSpinAttack(boolean spinAttack) -
setGliding
public void setGliding(boolean gliding) -
setSwimming
public void setSwimming(boolean swimming) -
setCrawling
public void setCrawling(boolean crawling) -
setFlying
public void setFlying(boolean flying) -
setGameMode
public void setGameMode(org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode newGamemode) -
setClientData
-
useItem
public void useItem(org.geysermc.mcprotocollib.protocol.data.game.entity.player.Hand hand) Convenience method to reduce amount of duplicate code. Sends ServerboundUseItemPacket. -
releaseItem
public void releaseItem() -
activateArmAnimationTicking
public void activateArmAnimationTicking()Starts ticking the amount of time that the Bedrock client has been swinging their arm, and disables blocking if blocking. -
isHandsBusy
public boolean isHandsBusy()You can't break blocks, attack entities, or use items while driving in a boat -
requestOffhandSwap
public void requestOffhandSwap() -
name
- Specified by:
namein interfaceorg.geysermc.geyser.api.command.CommandSource
-
sendMessage
- Specified by:
sendMessagein interfaceorg.geysermc.geyser.api.command.CommandSource
-
isConsole
public boolean isConsole()- Specified by:
isConsolein interfaceorg.geysermc.geyser.api.command.CommandSource
-
playerUuid
- Specified by:
playerUuidin interfaceorg.geysermc.geyser.api.command.CommandSource
-
connection
- Specified by:
connectionin interfaceorg.geysermc.geyser.api.command.CommandSource- Specified by:
connectionin interfaceGeyserCommandSource
-
locale
Description copied from interface:GeyserCommandSource- Specified by:
localein interfaceorg.geysermc.geyser.api.command.CommandSource- Specified by:
localein interfaceGeyserCommandSource
-
hasPermission
- Specified by:
hasPermissionin interfaceorg.geysermc.geyser.api.command.CommandSource
-
sendChat
Sends a chat message to the Java server. -
sendCommand
Sends a command to the Java server. -
setClientRenderDistance
public void setClientRenderDistance(int clientRenderDistance) -
setServerRenderDistance
public void setServerRenderDistance(int renderDistance) -
getSocketAddress
-
sendForm
public boolean sendForm(@NonNull org.geysermc.cumulus.form.Form form) - Specified by:
sendFormin interfaceorg.geysermc.api.connection.Connection
-
getPlayerInventory
-
getOpenInventory
-
sendForm
public boolean sendForm(@NonNull org.geysermc.cumulus.form.util.FormBuilder<?, ?, ?> formBuilder) - Specified by:
sendFormin interfaceorg.geysermc.api.connection.Connection
-
sendForm
Deprecated.since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases. Please use the new forms instead. -
sendForm
Deprecated.since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases. Please use the new forms instead. -
getNextItemNetId
public int getNextItemNetId()- Returns:
- the next Bedrock item network ID to use for a new item
-
confirmTeleport
public void confirmTeleport(org.cloudburstmc.math.vector.Vector3d position) -
sendUpstreamPacket
public void sendUpstreamPacket(org.cloudburstmc.protocol.bedrock.packet.BedrockPacket packet) Queue a packet to be sent to player.- Parameters:
packet- the bedrock packet from the NukkitX protocol lib
-
sendUpstreamPacketImmediately
public void sendUpstreamPacketImmediately(org.cloudburstmc.protocol.bedrock.packet.BedrockPacket packet) Send a packet immediately to the player.- Parameters:
packet- the bedrock packet from the NukkitX protocol lib
-
sendDownstreamGamePacket
public void sendDownstreamGamePacket(org.geysermc.mcprotocollib.network.packet.Packet packet) Send a packet to the remote server if in the game state.- Parameters:
packet- the java edition packet from MCProtocolLib
-
sendDownstreamLoginPacket
public void sendDownstreamLoginPacket(org.geysermc.mcprotocollib.network.packet.Packet packet) Send a packet to the remote server if in the login state.- Parameters:
packet- the java edition packet from MCProtocolLib
-
sendDownstreamPacket
public void sendDownstreamPacket(org.geysermc.mcprotocollib.network.packet.Packet packet, org.geysermc.mcprotocollib.protocol.data.ProtocolState intendedState) Send a packet to the remote server if in the specified state.- Parameters:
packet- the java edition packet from MCProtocolLibintendedState- the state the client should be in
-
sendDownstreamPacket
public void sendDownstreamPacket(org.geysermc.mcprotocollib.network.packet.Packet packet) Send a packet to the remote server.- Parameters:
packet- the java edition packet from MCProtocolLib
-
setReducedDebugInfo
public void setReducedDebugInfo(boolean value) Update the cached value for the reduced debug info gamerule. If enabled, also hides the player's coordinates.- Parameters:
value- The new value for reducedDebugInfo
-
setDaylightCycle
public void setDaylightCycle(boolean doCycle) Changes the daylight cycle gamerule on the client This is used in the login screen along-side normal usage- Parameters:
doCycle- If the cycle should continue
-
sendGameRule
Send a gamerule value to the client- Parameters:
gameRule- The gamerule to sendvalue- The value of the gamerule
-
sendAdventureSettings
public void sendAdventureSettings()Send an AdventureSettingsPacket to the client with the latest flags -
sendJavaClientSettings
public void sendJavaClientSettings()Send a packet to the server to indicate client render distance, locale, skin parts, and hand preference. -
updateStatistics
public void updateStatistics(@NonNull it.unimi.dsi.fastutil.objects.Object2IntMap<org.geysermc.mcprotocollib.protocol.data.game.statistic.Statistic> statistics) Used for updating statistic values since we only get changes from the server- Parameters:
statistics- Updated statistics values
-
refreshEmotes
-
canUseCommandBlocks
public boolean canUseCommandBlocks() -
playSoundEvent
public void playSoundEvent(org.cloudburstmc.protocol.bedrock.data.SoundEvent sound, org.cloudburstmc.math.vector.Vector3f position) -
getEyeHeight
public float getEyeHeight() -
updateRain
public void updateRain(float strength) Sends a packet to update rain strength. Stops rain if strength is 0.- Parameters:
strength- value between 0 and 1
-
updateThunder
public void updateThunder(float strength) Sends a packet to update thunderstorm strength. Stops thunderstorm if strength is 0.- Parameters:
strength- value between 0 and 1
-
isRaining
public boolean isRaining() -
isThunder
public boolean isThunder() -
bedrockUsername
- Specified by:
bedrockUsernamein interfaceorg.geysermc.api.connection.Connection
-
javaUsername
- Specified by:
javaUsernamein interfaceorg.geysermc.api.connection.Connection
-
javaUuid
- Specified by:
javaUuidin interfaceorg.geysermc.api.connection.Connection
-
xuid
- Specified by:
xuidin interfaceorg.geysermc.api.connection.Connection
-
version
- Specified by:
versionin interfaceorg.geysermc.api.connection.Connection
-
platform
public @NonNull org.geysermc.api.util.BedrockPlatform platform()- Specified by:
platformin interfaceorg.geysermc.api.connection.Connection
-
languageCode
- Specified by:
languageCodein interfaceorg.geysermc.api.connection.Connection
-
uiProfile
public @NonNull org.geysermc.api.util.UiProfile uiProfile()- Specified by:
uiProfilein interfaceorg.geysermc.api.connection.Connection
-
inputMode
public @NonNull org.geysermc.api.util.InputMode inputMode()- Specified by:
inputModein interfaceorg.geysermc.api.connection.Connection
-
isLinked
public boolean isLinked()- Specified by:
isLinkedin interfaceorg.geysermc.api.connection.Connection
-
transfer
public boolean transfer(@NonNull String address, @org.checkerframework.common.value.qual.IntRange(from=0L, to=65535L) int port) - Specified by:
transferin interfaceorg.geysermc.api.connection.Connection
-
entityByJavaId
public @NonNull CompletableFuture<@Nullable org.geysermc.geyser.api.entity.type.GeyserEntity> entityByJavaId(@org.checkerframework.checker.index.qual.NonNegative int javaId) - Specified by:
entityByJavaIdin interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
showEmote
public void showEmote(@NonNull org.geysermc.geyser.api.entity.type.player.GeyserPlayerEntity emoter, @NonNull String emoteId) - Specified by:
showEmotein interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
lockInputs
public void lockInputs(boolean camera, boolean movement) -
camera
public @NonNull org.geysermc.geyser.api.bedrock.camera.CameraData camera()- Specified by:
camerain interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
entities
public @NonNull org.geysermc.geyser.api.entity.EntityData entities()- Specified by:
entitiesin interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
shakeCamera
public void shakeCamera(float intensity, float duration, @NonNull org.geysermc.geyser.api.bedrock.camera.CameraShake type) - Specified by:
shakeCamerain interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
stopCameraShake
public void stopCameraShake()- Specified by:
stopCameraShakein interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
sendFog
- Specified by:
sendFogin interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
removeFog
- Specified by:
removeFogin interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
fogEffects
- Specified by:
fogEffectsin interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
ping
public int ping()- Specified by:
pingin interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
protocolVersion
public int protocolVersion()- Specified by:
protocolVersionin interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
closeForm
public void closeForm()- Specified by:
closeFormin interfaceorg.geysermc.geyser.api.connection.GeyserConnection
-
addCommandEnum
-
removeCommandEnum
-
getGeyser
-
getUpstream
-
getDownstream
-
getTickEventLoop
public io.netty.channel.EventLoop getTickEventLoop()The loop where all packets and ticking is processed to prevent concurrency issues. If this is manually called, ensure that any exceptions are properly handled. -
getAuthData
-
getClientData
-
getCertChainData
Used for Floodgate skin uploading -
getErosionHandler
-
remoteServer
public org.geysermc.geyser.api.network.RemoteServer remoteServer() -
getPlayerEntity
-
getAdvancementsCache
-
getBookEditCache
-
getBundleCache
-
getChunkCache
-
getEntityCache
-
getEffectCache
-
getFormCache
-
getInputCache
-
getLodestoneCache
-
getPistonCache
-
getPreferencesCache
-
getRegistryCache
-
getSkullCache
-
getStructureBlockCache
-
getTagCache
-
getWorldCache
-
getUnconfirmedTeleport
-
getWorldBorder
-
isInWorldBorderWarningArea
public boolean isInWorldBorderWarningArea()Whether simulated fog has been sent to the client or not. -
getPlayerInventoryHolder
Stores the player inventory and player inventory translator -
getInventoryHolder
Stores the current open Bedrock inventory, including the correct translator. Prefer usingInventoryUtils.getInventory(GeyserSession, int), as this method can e.g. return aInventoryHolder<LecternContainer>due to the workaround inLecternContainer.isBookInPlayerInventory()workaround. -
isClosingInventory
public boolean isClosingInventory()Whether the client is currently closing an inventory. Used to open new inventories while another one is currently open. -
getPendingOrCurrentBedrockInventoryId
public int getPendingOrCurrentBedrockInventoryId()Stores the bedrock inventory id of the pending inventory, or -1 if no inventory is pending. This id is only set when the block that should be opened exists. -
getContainerOutputFuture
-
getCollisionManager
Stores session collision -
getBlockMappings
Stores the block mappings for this specific version. -
getItemMappings
Stores the item translations for this specific version. -
getItemFrameCache
A map of Vector3i positions to Java entities. Used for translating Bedrock block actions to Java entity actions. -
getPlayerWithCustomHeads
A map of all players (and their heads) that are wearing a player head with a custom texture. Our workaround for these players is to give them a custom skin and geometry to emulate wearing a custom skull. -
isDroppingLecternBook
public boolean isDroppingLecternBook() -
getLastChunkPosition
public org.cloudburstmc.math.vector.Vector2i getLastChunkPosition() -
getClientRenderDistance
public int getClientRenderDistance() -
getServerRenderDistance
public int getServerRenderDistance() -
isSentSpawnPacket
public boolean isSentSpawnPacket() -
isLoggedIn
public boolean isLoggedIn() -
isLoggingIn
public boolean isLoggingIn() -
isSpawned
public boolean isSpawned() -
isClosed
public boolean isClosed()Accessed on the initial Java and Bedrock packet processing threads -
getGameMode
public org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode getGameMode() -
getWorldName
public net.kyori.adventure.key.Key getWorldName()Keeps track of the world name for respawning. -
getLevels
As of Java 1.19.3, the client only uses these for commands. -
isSneaking
public boolean isSneaking() -
getPose
public org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose getPose()Stores the Java pose that the server and/or Geyser believes the player currently has. -
isSprinting
public boolean isSprinting() -
getBedrockOverworldDimension
The overworld dimension which Bedrock Edition uses. -
getDimensionType
The dimension of the player. As all entities are in the same world, this can be safely applied to all other entities. -
getBedrockDimension
Which dimension Bedrock understands themselves to be in. This should only be set after the ChangeDimensionPacket is sent, or right before the StartGamePacket is sent. -
getBreakingBlock
public int getBreakingBlock() -
getLastBlockPlacePosition
public org.cloudburstmc.math.vector.Vector3i getLastBlockPlacePosition() -
getLastBlockPlaced
-
isInteracting
public boolean isInteracting() -
getLastInteractionBlockPosition
public org.cloudburstmc.math.vector.Vector3i getLastInteractionBlockPosition()Stores the last position of the block the player interacted with. This can either be a block that the client placed or an existing block the player interacted with (for example, a chest).
Initialized as (0, 0, 0) so it is always not-null. -
getLastInteractionPlayerPosition
public org.cloudburstmc.math.vector.Vector3f getLastInteractionPlayerPosition()Stores the position of the player the last time they interacted. Used to verify that the player did not move since their last interaction.
Initialized as (0, 0, 0) so it is always not-null. -
getMouseoverEntity
The entity that the client is currently looking at. -
getJavaToBedrockRecipeIds
Stores all Java recipes by ID, and matches them to all possible Bedrock recipe identifiers. -
getCraftingRecipes
-
getLastCreatedRecipe
public it.unimi.dsi.fastutil.Pair<org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.CraftingRecipeData,GeyserRecipe> getLastCreatedRecipe() -
getLastRecipeNetId
-
getStonecutterRecipes
Saves a list of all stonecutter recipes, for use in a stonecutter inventory. The key is the Bedrock recipe net ID; the values are their respective output and button ID. -
getSmithingRecipes
-
isEmulatePost1_13Logic
public boolean isEmulatePost1_13Logic()Whether to work around 1.13's different behavior in villager trading menus. -
isEmulatePost1_16Logic
public boolean isEmulatePost1_16Logic()Starting in 1.17, Java servers expect thecarriedItemparameter of the serverbound click container packet to be the current contents of the mouse after the transaction has been done. 1.16 expects the clicked slot contents before any transaction is done. With the current ViaVersion structure, if we do not send what 1.16 expects and send multiple click container packets, then successive transactions will be rejected. -
isEmulatePost1_18Logic
public boolean isEmulatePost1_18Logic() -
isOldSmithingTable
public boolean isOldSmithingTable()Whether to emulate pre-1.20 smithing table behavior. Adapts ViaVersion's furnace UI to one Bedrock can use. SeeOldSmithingTableTranslator. -
isUsingExperimentalMinecartLogic
public boolean isUsingExperimentalMinecartLogic()Whether to use the minecart_improvements experiment -
getAttackSpeed
public double getAttackSpeed()The current attack speed of the player. Used for sending proper cooldown timings. Setting a default fixes cooldowns not showing up on a fresh world. -
getLastHitTime
public long getLastHitTime()The time of the last hit. Used to gauge how long the cooldown is taking. This is a session variable in order to prevent more scheduled threads than necessary. -
isSteeringLeft
public boolean isSteeringLeft()Saves if the client is steering left on a boat. -
isSteeringRight
public boolean isSteeringRight()Saves if the client is steering right on a boat. -
getLastInteractionTime
public long getLastInteractionTime()Store the last time the player interacted. Used to fix a right-click spam bug. See this for context. -
getBlockBreakStartTime
public long getBlockBreakStartTime()Stores when the player started to break a block. Used to allow correct break time for custom blocks. -
isPlacedBucket
public boolean isPlacedBucket()Stores whether the player intended to place a bucket. -
getArmAnimationTicks
public int getArmAnimationTicks()Counts how many ticks have occurred since an arm animation started. -1 means there is no active arm swing -
getLastAirHitTick
public int getLastAirHitTick()The tick in which the player last hit air. Used to ensure we dont send two sing packets for one hit. -
isDaylightCycle
public boolean isDaylightCycle()Controls whether the daylight cycle gamerule has been sent to the client, so the sun/moon remain motionless. -
isReducedDebugInfo
public boolean isReducedDebugInfo() -
getOpPermissionLevel
public int getOpPermissionLevel()The op permission level set by the server -
isCanFly
public boolean isCanFly()If the current player can fly -
isFlying
public boolean isFlying()If the current player is flying -
isInstabuild
public boolean isInstabuild() -
getFlySpeed
public float getFlySpeed() -
getWalkSpeed
public float getWalkSpeed() -
getRainStrength
public float getRainStrength()Caches current rain strength. Value between 0 and 1. -
getThunderStrength
public float getThunderStrength()Caches current thunder strength. Value between 0 and 1. -
getStatistics
public it.unimi.dsi.fastutil.objects.Object2IntMap<org.geysermc.mcprotocollib.protocol.data.game.statistic.Statistic> getStatistics()Stores a map of all statistics sent from the server. The server only sends new statistics back to us, so in order to show all statistics we need to cache existing ones. -
isWaitingForStatistics
public boolean isWaitingForStatistics()Whether we're expecting statistics to be sent back to us. -
getEmotes
-
isAdvancedTooltips
public boolean isAdvancedTooltips()Whether advanced tooltips will be added to the player's items. -
getTickThread
The thread that will run every game tick. -
getTicks
public int getTicks()The number of ticks that have elapsed since the start of this session -
getWorldTicks
public long getWorldTicks()The world time in ticks according to the serverNote: The TickingStatePacket is currently ignored.
-
getLookBackScheduledFuture
Used to return the player to their original rotation after using an item in BedrockInventoryTransactionTranslator -
getMountVehicleScheduledFuture
Used to return players back to their vehicles if the server doesn't want them unmounting. -
getKeepAliveCache
A cache of IDs from ClientboundKeepAlivePackets that have been sent to the Bedrock client, but haven't been returned to the server. Only used ifGeyserConfiguration.isForwardPlayerPing()is enabled. -
getCurrentBook
public @Nullable org.cloudburstmc.protocol.bedrock.data.inventory.ItemData getCurrentBook()Stores the book that is currently being read. Used inJavaOpenBookTranslator -
getCookies
Stores cookies sent by the Java server. -
getCameraData
-
getEntityData
-
getNanosecondsPerTick
public int getNanosecondsPerTick() -
getMillisecondsPerTick
public float getMillisecondsPerTick() -
isTickingFrozen
public boolean isTickingFrozen() -
getStepTicks
public int getStepTicks()The amount of ticks requested by the server that the game should proceed with, even if the game tick loop is frozen. -
setAuthData
-
setCertChainData
Used for Floodgate skin uploading -
setErosionHandler
-
remoteServer
- Returns:
this.
-
setUnconfirmedTeleport
-
setInventoryHolder
Stores the current open Bedrock inventory, including the correct translator. Prefer usingInventoryUtils.getInventory(GeyserSession, int), as this method can e.g. return aInventoryHolder<LecternContainer>due to the workaround inLecternContainer.isBookInPlayerInventory()workaround. -
setClosingInventory
public void setClosingInventory(boolean closingInventory) Whether the client is currently closing an inventory. Used to open new inventories while another one is currently open. -
setPendingOrCurrentBedrockInventoryId
public void setPendingOrCurrentBedrockInventoryId(int pendingOrCurrentBedrockInventoryId) Stores the bedrock inventory id of the pending inventory, or -1 if no inventory is pending. This id is only set when the block that should be opened exists. -
setContainerOutputFuture
-
setBlockMappings
Stores the block mappings for this specific version. -
setItemMappings
Stores the item translations for this specific version. -
setDroppingLecternBook
public void setDroppingLecternBook(boolean droppingLecternBook) -
setLastChunkPosition
public void setLastChunkPosition(org.cloudburstmc.math.vector.Vector2i lastChunkPosition) -
setSpawned
public void setSpawned(boolean spawned) -
setWorldName
public void setWorldName(net.kyori.adventure.key.Key worldName) Keeps track of the world name for respawning. -
setLevels
As of Java 1.19.3, the client only uses these for commands. -
setPose
public void setPose(org.geysermc.mcprotocollib.protocol.data.game.entity.metadata.Pose pose) Stores the Java pose that the server and/or Geyser believes the player currently has. -
setSprinting
public void setSprinting(boolean sprinting) -
setDimensionType
The dimension of the player. As all entities are in the same world, this can be safely applied to all other entities. -
setBedrockDimension
Which dimension Bedrock understands themselves to be in. This should only be set after the ChangeDimensionPacket is sent, or right before the StartGamePacket is sent. -
setBreakingBlock
public void setBreakingBlock(int breakingBlock) -
setLastBlockPlacePosition
public void setLastBlockPlacePosition(org.cloudburstmc.math.vector.Vector3i lastBlockPlacePosition) -
setLastBlockPlaced
-
setInteracting
public void setInteracting(boolean interacting) -
setLastInteractionBlockPosition
public void setLastInteractionBlockPosition(org.cloudburstmc.math.vector.Vector3i lastInteractionBlockPosition) Stores the last position of the block the player interacted with. This can either be a block that the client placed or an existing block the player interacted with (for example, a chest).
Initialized as (0, 0, 0) so it is always not-null. -
setLastInteractionPlayerPosition
public void setLastInteractionPlayerPosition(org.cloudburstmc.math.vector.Vector3f lastInteractionPlayerPosition) Stores the position of the player the last time they interacted. Used to verify that the player did not move since their last interaction.
Initialized as (0, 0, 0) so it is always not-null. -
setMouseoverEntity
The entity that the client is currently looking at. -
setLastCreatedRecipe
public void setLastCreatedRecipe(it.unimi.dsi.fastutil.Pair<org.cloudburstmc.protocol.bedrock.data.inventory.crafting.recipe.CraftingRecipeData, GeyserRecipe> lastCreatedRecipe) -
setStonecutterRecipes
public void setStonecutterRecipes(it.unimi.dsi.fastutil.ints.Int2ObjectMap<GeyserStonecutterData> stonecutterRecipes) Saves a list of all stonecutter recipes, for use in a stonecutter inventory. The key is the Bedrock recipe net ID; the values are their respective output and button ID. -
setEmulatePost1_13Logic
public void setEmulatePost1_13Logic(boolean emulatePost1_13Logic) Whether to work around 1.13's different behavior in villager trading menus. -
setEmulatePost1_16Logic
public void setEmulatePost1_16Logic(boolean emulatePost1_16Logic) Starting in 1.17, Java servers expect thecarriedItemparameter of the serverbound click container packet to be the current contents of the mouse after the transaction has been done. 1.16 expects the clicked slot contents before any transaction is done. With the current ViaVersion structure, if we do not send what 1.16 expects and send multiple click container packets, then successive transactions will be rejected. -
setEmulatePost1_18Logic
public void setEmulatePost1_18Logic(boolean emulatePost1_18Logic) -
setOldSmithingTable
public void setOldSmithingTable(boolean oldSmithingTable) Whether to emulate pre-1.20 smithing table behavior. Adapts ViaVersion's furnace UI to one Bedrock can use. SeeOldSmithingTableTranslator. -
setUsingExperimentalMinecartLogic
public void setUsingExperimentalMinecartLogic(boolean isUsingExperimentalMinecartLogic) Whether to use the minecart_improvements experiment -
setAttackSpeed
public void setAttackSpeed(double attackSpeed) The current attack speed of the player. Used for sending proper cooldown timings. Setting a default fixes cooldowns not showing up on a fresh world. -
setLastHitTime
public void setLastHitTime(long lastHitTime) The time of the last hit. Used to gauge how long the cooldown is taking. This is a session variable in order to prevent more scheduled threads than necessary. -
setSteeringLeft
public void setSteeringLeft(boolean steeringLeft) Saves if the client is steering left on a boat. -
setSteeringRight
public void setSteeringRight(boolean steeringRight) Saves if the client is steering right on a boat. -
setLastInteractionTime
public void setLastInteractionTime(long lastInteractionTime) Store the last time the player interacted. Used to fix a right-click spam bug. See this for context. -
setBlockBreakStartTime
public void setBlockBreakStartTime(long blockBreakStartTime) Stores when the player started to break a block. Used to allow correct break time for custom blocks. -
setPlacedBucket
public void setPlacedBucket(boolean placedBucket) Stores whether the player intended to place a bucket. -
setLastAirHitTick
public void setLastAirHitTick(int lastAirHitTick) The tick in which the player last hit air. Used to ensure we dont send two sing packets for one hit. -
setOpPermissionLevel
public void setOpPermissionLevel(int opPermissionLevel) The op permission level set by the server -
setCanFly
public void setCanFly(boolean canFly) If the current player can fly -
setInstabuild
public void setInstabuild(boolean instabuild) -
setFlySpeed
public void setFlySpeed(float flySpeed) -
setWalkSpeed
public void setWalkSpeed(float walkSpeed) -
setWaitingForStatistics
public void setWaitingForStatistics(boolean waitingForStatistics) Whether we're expecting statistics to be sent back to us. -
setAdvancedTooltips
public void setAdvancedTooltips(boolean advancedTooltips) Whether advanced tooltips will be added to the player's items. -
setWorldTicks
public void setWorldTicks(long worldTicks) The world time in ticks according to the serverNote: The TickingStatePacket is currently ignored.
-
setLookBackScheduledFuture
Used to return the player to their original rotation after using an item in BedrockInventoryTransactionTranslator -
setMountVehicleScheduledFuture
Used to return players back to their vehicles if the server doesn't want them unmounting. -
setCurrentBook
public void setCurrentBook(@Nullable org.cloudburstmc.protocol.bedrock.data.inventory.ItemData currentBook) Stores the book that is currently being read. Used inJavaOpenBookTranslator -
setCookies
Stores cookies sent by the Java server. -
setStepTicks
public void setStepTicks(int stepTicks) The amount of ticks requested by the server that the game should proceed with, even if the game tick loop is frozen.
-