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 Details

    • sentSpawnPacket

      protected boolean sentSpawnPacket
  • Constructor Details

    • GeyserSession

      public GeyserSession(GeyserImpl geyser, org.cloudburstmc.protocol.bedrock.BedrockServerSession bedrockServerSession, io.netty.channel.EventLoop eventLoop)
  • Method Details

    • connect

      public void connect()
      Send all necessary packets to load Bedrock into the server
    • authenticate

      public void authenticate(String username)
    • authenticateWithRefreshToken

      public void authenticateWithRefreshToken(String refreshToken)
    • 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

      public boolean onMicrosoftLoginComplete(PendingMicrosoftAuthentication.AuthenticationTask task)
      If successful, also begins connecting to the Java server.
    • disconnect

      public void disconnect(String reason)
    • ensureInEventLoop

      public void ensureInEventLoop(Runnable runnable)
      Moves task to the session event loop if already not in it. Otherwise, the task is automatically ran.
    • executeInEventLoop

      public void executeInEventLoop(Runnable runnable)
      Executes a task and prints a stack trace if an error occurs.
    • scheduleInEventLoop

      public ScheduledFuture<?> scheduleInEventLoop(Runnable runnable, long duration, TimeUnit timeUnit)
      Schedules a task and prints a stack trace if an error occurs.

      The task will not run if the session is closed.

    • tick

      protected void tick()
      Called every 50 milliseconds - one Minecraft tick.
    • setAuthenticationData

      public void setAuthenticationData(AuthData authData)
    • startSneaking

      public void startSneaking()
    • stopSneaking

      public void stopSneaking()
    • setSwimming

      public void setSwimming(boolean swimming)
    • setFlying

      public void setFlying(boolean flying)
    • setGameMode

      public void setGameMode(org.geysermc.mcprotocollib.protocol.data.game.entity.player.GameMode newGamemode)
    • activateArmAnimationTicking

      public void activateArmAnimationTicking()
      Starts ticking the amount of time that the Bedrock client has been swinging their arm, and disables blocking if blocking.
    • armSwingPending

      public void armSwingPending()
      For issue 2113 and combating arm ticking activating being delayed in BedrockAnimateTranslator.
    • requestOffhandSwap

      public void requestOffhandSwap()
    • name

      public String name()
      Specified by:
      name in interface org.geysermc.geyser.api.command.CommandSource
    • sendMessage

      public void sendMessage(@NonNull String message)
      Specified by:
      sendMessage in interface org.geysermc.geyser.api.command.CommandSource
    • isConsole

      public boolean isConsole()
      Specified by:
      isConsole in interface org.geysermc.geyser.api.command.CommandSource
    • locale

      public String locale()
      Description copied from interface: GeyserCommandSource
      Specified by:
      locale in interface org.geysermc.geyser.api.command.CommandSource
      Specified by:
      locale in interface GeyserCommandSource
    • sendChat

      public void sendChat(String message)
      Sends a chat message to the Java server.
    • sendCommand

      public void sendCommand(String command)
      Sends a command to the Java server.
    • setServerRenderDistance

      public void setServerRenderDistance(int renderDistance)
    • getSocketAddress

      public InetSocketAddress getSocketAddress()
    • sendForm

      public boolean sendForm(@NonNull org.geysermc.cumulus.form.Form form)
      Specified by:
      sendForm in interface org.geysermc.api.connection.Connection
    • sendForm

      public boolean sendForm(@NonNull org.geysermc.cumulus.form.util.FormBuilder<?,?,?> formBuilder)
      Specified by:
      sendForm in interface org.geysermc.api.connection.Connection
    • sendForm

      @Deprecated public void sendForm(org.geysermc.cumulus.Form<?> form)
      Deprecated.
      since Cumulus version 1.1, and will be removed when Cumulus 2.0 releases. Please use the new forms instead.
    • sendForm

      @Deprecated public void sendForm(org.geysermc.cumulus.util.FormBuilder<?,?> formBuilder)
      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 MCProtocolLib
      intendedState - 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

      public void sendGameRule(String gameRule, Object value)
      Send a gamerule value to the client
      Parameters:
      gameRule - The gamerule to send
      value - The value of the gamerule
    • hasPermission

      public boolean hasPermission(String permission)
      Checks if the given session's player has a permission
      Specified by:
      hasPermission in interface org.geysermc.geyser.api.command.CommandSource
      Parameters:
      permission - The permission node to check
      Returns:
      true if the player has the requested permission, false if not
    • 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

      public void refreshEmotes(List<UUID> emotes)
    • 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()
    • bedrockUsername

      public @NonNull String bedrockUsername()
      Specified by:
      bedrockUsername in interface org.geysermc.api.connection.Connection
    • javaUsername

      public @MonotonicNonNull String javaUsername()
      Specified by:
      javaUsername in interface org.geysermc.api.connection.Connection
    • javaUuid

      public UUID javaUuid()
      Specified by:
      javaUuid in interface org.geysermc.api.connection.Connection
    • xuid

      public @NonNull String xuid()
      Specified by:
      xuid in interface org.geysermc.api.connection.Connection
    • version

      public @NonNull String version()
      Specified by:
      version in interface org.geysermc.api.connection.Connection
    • platform

      public @NonNull org.geysermc.api.util.BedrockPlatform platform()
      Specified by:
      platform in interface org.geysermc.api.connection.Connection
    • languageCode

      public @NonNull String languageCode()
      Specified by:
      languageCode in interface org.geysermc.api.connection.Connection
    • uiProfile

      public @NonNull org.geysermc.api.util.UiProfile uiProfile()
      Specified by:
      uiProfile in interface org.geysermc.api.connection.Connection
    • inputMode

      public @NonNull org.geysermc.api.util.InputMode inputMode()
      Specified by:
      inputMode in interface org.geysermc.api.connection.Connection
    • isLinked

      public boolean isLinked()
      Specified by:
      isLinked in interface org.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:
      transfer in interface org.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:
      entityByJavaId in interface org.geysermc.geyser.api.connection.GeyserConnection
    • showEmote

      public void showEmote(@NonNull org.geysermc.geyser.api.entity.type.player.GeyserPlayerEntity emoter, @NonNull String emoteId)
      Specified by:
      showEmote in interface org.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:
      camera in interface org.geysermc.geyser.api.connection.GeyserConnection
    • entities

      public @NonNull org.geysermc.geyser.api.entity.EntityData entities()
      Specified by:
      entities in interface org.geysermc.geyser.api.connection.GeyserConnection
    • shakeCamera

      public void shakeCamera(float intensity, float duration, @NonNull org.geysermc.geyser.api.bedrock.camera.CameraShake type)
      Specified by:
      shakeCamera in interface org.geysermc.geyser.api.connection.GeyserConnection
    • stopCameraShake

      public void stopCameraShake()
      Specified by:
      stopCameraShake in interface org.geysermc.geyser.api.connection.GeyserConnection
    • sendFog

      public void sendFog(String... fogNameSpaces)
      Specified by:
      sendFog in interface org.geysermc.geyser.api.connection.GeyserConnection
    • removeFog

      public void removeFog(String... fogNameSpaces)
      Specified by:
      removeFog in interface org.geysermc.geyser.api.connection.GeyserConnection
    • fogEffects

      public @NonNull Set<String> fogEffects()
      Specified by:
      fogEffects in interface org.geysermc.geyser.api.connection.GeyserConnection
    • addCommandEnum

      public void addCommandEnum(String name, String enums)
    • removeCommandEnum

      public void removeCommandEnum(String name, String enums)
    • getGeyser

      public GeyserImpl getGeyser()
    • getUpstream

      public UpstreamSession getUpstream()
    • getDownstream

      public DownstreamSession getDownstream()
    • getEventLoop

      public io.netty.channel.EventLoop getEventLoop()
      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

      public AuthData getAuthData()
    • getClientData

      public BedrockClientData getClientData()
    • getCertChainData

      public List<String> getCertChainData()
      Used for Floodgate skin uploading
    • getErosionHandler

      public @NonNull AbstractGeyserboundPacketHandler getErosionHandler()
    • remoteServer

      public org.geysermc.geyser.api.network.RemoteServer remoteServer()
    • getPlayerEntity

      public SessionPlayerEntity getPlayerEntity()
    • getAdvancementsCache

      public AdvancementsCache getAdvancementsCache()
    • getBookEditCache

      public BookEditCache getBookEditCache()
    • getChunkCache

      public ChunkCache getChunkCache()
    • getEntityCache

      public EntityCache getEntityCache()
    • getEffectCache

      public EntityEffectCache getEffectCache()
    • getFormCache

      public FormCache getFormCache()
    • getLodestoneCache

      public LodestoneCache getLodestoneCache()
    • getPistonCache

      public PistonCache getPistonCache()
    • getPreferencesCache

      public PreferencesCache getPreferencesCache()
    • getRegistryCache

      public RegistryCache getRegistryCache()
    • getSkullCache

      public SkullCache getSkullCache()
    • getStructureBlockCache

      public StructureBlockCache getStructureBlockCache()
    • getTagCache

      public TagCache getTagCache()
    • getWorldCache

      public WorldCache getWorldCache()
    • getUnconfirmedTeleport

      public TeleportCache getUnconfirmedTeleport()
    • getWorldBorder

      public WorldBorder getWorldBorder()
    • isInWorldBorderWarningArea

      public boolean isInWorldBorderWarningArea()
      Whether simulated fog has been sent to the client or not.
    • getPlayerInventory

      public PlayerInventory getPlayerInventory()
    • getOpenInventory

      public Inventory getOpenInventory()
    • isClosingInventory

      public boolean isClosingInventory()
    • getInventoryTranslator

      public InventoryTranslator getInventoryTranslator()
    • getCraftingGridFuture

      public ScheduledFuture<?> getCraftingGridFuture()
    • getCollisionManager

      public CollisionManager getCollisionManager()
      Stores session collision
    • getBlockMappings

      public BlockMappings getBlockMappings()
      Stores the block mappings for this specific version.
    • getItemMappings

      public ItemMappings getItemMappings()
      Stores the item translations for this specific version.
    • getItemFrameCache

      public Map<org.cloudburstmc.math.vector.Vector3i,ItemFrameEntity> getItemFrameCache()
      A map of Vector3i positions to Java entities. Used for translating Bedrock block actions to Java entity actions.
    • getPlayerWithCustomHeads

      public Set<UUID> getPlayerWithCustomHeads()
      A list of all players that have a player head on 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 String getWorldName()
      Keeps track of the world name for respawning.
    • getLevels

      public String[] 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()
    • getDimension

      public int getDimension()
      The dimension of the player. As all entities are in the same world, this can be safely applied to all other entities.
    • getDimensionType

      public @MonotonicNonNull JavaDimension getDimensionType()
    • getBreakingBlock

      public int getBreakingBlock()
    • getLastBlockPlacePosition

      public org.cloudburstmc.math.vector.Vector3i getLastBlockPlacePosition()
    • getLastBlockPlaced

      public BlockItem 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

      public Entity getMouseoverEntity()
      The entity that the client is currently looking at.
    • getJavaToBedrockRecipeIds

      public Map<String,List<String>> getJavaToBedrockRecipeIds()
      Stores all Java recipes by recipe identifier, and matches them to all possible Bedrock recipe identifiers. They are not 1:1, since Bedrock can have multiple recipes for the same Java recipe.
    • getCraftingRecipes

      public it.unimi.dsi.fastutil.ints.Int2ObjectMap<GeyserRecipe> getCraftingRecipes()
    • getLastRecipeNetId

      public AtomicInteger getLastRecipeNetId()
    • getStonecutterRecipes

      public it.unimi.dsi.fastutil.ints.Int2ObjectMap<GeyserStonecutterData> getStonecutterRecipes()
      Saves a list of all stonecutter recipes, for use in a stonecutter inventory. The key is the Java ID of the item; the values are all the possible outputs' Java IDs sorted by their string identifier
    • 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 the carriedItem parameter 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. See OldSmithingTableTranslator.
    • 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.
    • getLastMovementTimestamp

      public long getLastMovementTimestamp()
      Used to send a movement packet every three seconds if the player hasn't moved. Prevents timeouts when AFK in certain instances.
    • getLastVehicleMoveTimestamp

      public long getLastVehicleMoveTimestamp()
      Used to send a ServerboundMoveVehiclePacket for every PlayerInputPacket after idling on a boat/horse for more than 100ms
    • getArmAnimationTicks

      public int getArmAnimationTicks()
      Counts how many ticks have occurred since an arm animation started. -1 means there is no active arm swing; -2 means an arm swing will start in a tick.
    • 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()
    • isRaining

      public boolean isRaining()
      Caches current rain status.
    • isThunder

      public boolean isThunder()
      Caches current thunder status.
    • 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

      public Set<UUID> getEmotes()
    • isAdvancedTooltips

      public boolean isAdvancedTooltips()
      Whether advanced tooltips will be added to the player's items.
    • getTickThread

      public ScheduledFuture<?> getTickThread()
      The thread that will run every 50 milliseconds - one Minecraft tick.
    • getLookBackScheduledFuture

      public ScheduledFuture<?> getLookBackScheduledFuture()
      Used to return the player to their original rotation after using an item in BedrockInventoryTransactionTranslator
    • getMountVehicleScheduledFuture

      public ScheduledFuture<?> getMountVehicleScheduledFuture()
      Used to return players back to their vehicles if the server doesn't want them unmounting.
    • getKeepAliveCache

      public Queue<Long> 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 if GeyserConfiguration.isForwardPlayerPing() is enabled.
    • getCurrentBook

      public @Nullable org.cloudburstmc.protocol.bedrock.data.inventory.ItemData getCurrentBook()
      Stores the book that is currently being read. Used in JavaOpenBookTranslator
    • getCameraData

      public GeyserCameraData getCameraData()
    • getEntityData

      public GeyserEntityData getEntityData()
    • getProtocol

      public org.geysermc.mcprotocollib.protocol.MinecraftProtocol getProtocol()
    • setAuthData

      public void setAuthData(AuthData authData)
    • setClientData

      public void setClientData(BedrockClientData clientData)
    • setCertChainData

      public void setCertChainData(List<String> certChainData)
      Used for Floodgate skin uploading
    • setErosionHandler

      public void setErosionHandler(@NonNull AbstractGeyserboundPacketHandler erosionHandler)
    • remoteServer

      public GeyserSession remoteServer(org.geysermc.geyser.api.network.RemoteServer remoteServer)
      Returns:
      this.
    • setUnconfirmedTeleport

      public void setUnconfirmedTeleport(TeleportCache unconfirmedTeleport)
    • setOpenInventory

      public void setOpenInventory(Inventory openInventory)
    • setClosingInventory

      public void setClosingInventory(boolean closingInventory)
    • setInventoryTranslator

      public void setInventoryTranslator(InventoryTranslator inventoryTranslator)
    • setCraftingGridFuture

      public void setCraftingGridFuture(ScheduledFuture<?> craftingGridFuture)
    • setBlockMappings

      public void setBlockMappings(BlockMappings blockMappings)
      Stores the block mappings for this specific version.
    • setItemMappings

      public void setItemMappings(ItemMappings itemMappings)
      Stores the item translations for this specific version.
    • setDroppingLecternBook

      public void setDroppingLecternBook(boolean droppingLecternBook)
    • setLastChunkPosition

      public void setLastChunkPosition(org.cloudburstmc.math.vector.Vector2i lastChunkPosition)
    • setClientRenderDistance

      public void setClientRenderDistance(int clientRenderDistance)
    • setSpawned

      public void setSpawned(boolean spawned)
    • setWorldName

      public void setWorldName(String worldName)
      Keeps track of the world name for respawning.
    • setLevels

      public void setLevels(String[] levels)
      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)
    • setDimension

      public void setDimension(int dimension)
      The dimension of the player. As all entities are in the same world, this can be safely applied to all other entities.
    • setDimensionType

      public void setDimensionType(@MonotonicNonNull JavaDimension dimensionType)
    • setBreakingBlock

      public void setBreakingBlock(int breakingBlock)
    • setLastBlockPlacePosition

      public void setLastBlockPlacePosition(org.cloudburstmc.math.vector.Vector3i lastBlockPlacePosition)
    • setLastBlockPlaced

      public void setLastBlockPlaced(BlockItem lastBlockPlaced)
    • 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

      public void setMouseoverEntity(Entity mouseoverEntity)
      The entity that the client is currently looking at.
    • setJavaToBedrockRecipeIds

      public void setJavaToBedrockRecipeIds(Map<String,List<String>> javaToBedrockRecipeIds)
      Stores all Java recipes by recipe identifier, and matches them to all possible Bedrock recipe identifiers. They are not 1:1, since Bedrock can have multiple recipes for the same Java recipe.
    • setCraftingRecipes

      public void setCraftingRecipes(it.unimi.dsi.fastutil.ints.Int2ObjectMap<GeyserRecipe> craftingRecipes)
    • 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 Java ID of the item; the values are all the possible outputs' Java IDs sorted by their string identifier
    • 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 the carriedItem parameter 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. See OldSmithingTableTranslator.
    • 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.
    • setLastMovementTimestamp

      public void setLastMovementTimestamp(long lastMovementTimestamp)
      Used to send a movement packet every three seconds if the player hasn't moved. Prevents timeouts when AFK in certain instances.
    • setLastVehicleMoveTimestamp

      public void setLastVehicleMoveTimestamp(long lastVehicleMoveTimestamp)
      Used to send a ServerboundMoveVehiclePacket for every PlayerInputPacket after idling on a boat/horse for more than 100ms
    • 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)
    • setRaining

      public void setRaining(boolean raining)
      Caches current rain status.
    • setThunder

      public void setThunder(boolean thunder)
      Caches current thunder status.
    • 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.
    • setLookBackScheduledFuture

      public void setLookBackScheduledFuture(ScheduledFuture<?> lookBackScheduledFuture)
      Used to return the player to their original rotation after using an item in BedrockInventoryTransactionTranslator
    • setMountVehicleScheduledFuture

      public void setMountVehicleScheduledFuture(ScheduledFuture<?> mountVehicleScheduledFuture)
      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 in JavaOpenBookTranslator
    • setCookies

      public void setCookies(Map<String,byte[]> cookies)
      Stores cookies sent by the Java server.
    • getCookies

      public Map<String,byte[]> getCookies()
      Stores cookies sent by the Java server.