Interface ViaFabricPlusBase


public interface ViaFabricPlusBase
General API point for mods. Get instance via ViaFabricPlus.getImpl().
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Add a setting group to the mod.
    default int
     
    boolean
    bannerPatternExists(net.minecraft.resources.ResourceKey<net.minecraft.world.level.block.entity.BannerPattern> pattern, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
     
    boolean
    effectExists(net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
     
    boolean
    enchantmentExists(net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
     
    The implementation version of the current running jar file, containing commit-hash as well as the getVersion().
    int
    getMaxChatLength(com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
    Calculates the maximum chat length for given ProtocolVersion instance.
    Get the root path of the mod.
    @Nullable com.viaversion.viaversion.api.connection.UserConnection
     
    @Nullable com.viaversion.viaversion.api.protocol.version.ProtocolVersion
    getServerVersion(net.minecraft.client.multiplayer.ServerData serverInfo)
    Gets the per-server protocol version for the given server.
    @Nullable SettingGroup
    getSettingGroup(String translationKey)
    Get a setting group by its translationKey.
    All setting groups of the mod.
    int
    getStackCount(net.minecraft.world.item.ItemStack stack)
    Similar to ItemStack.getCount(), but also handles negative item counts in pre 1.11 versions
    com.viaversion.viaversion.api.protocol.version.ProtocolVersion
    This method is used when you need the target version after connecting to the server.
    com.viaversion.viaversion.api.protocol.version.ProtocolVersion
    getTargetVersion(io.netty.channel.Channel channel)
    Gets the target version from the channel attribute, can be used in the early stages of the connection
    com.viaversion.viaversion.api.protocol.version.ProtocolVersion
    getTargetVersion(net.minecraft.network.Connection connection)
    Gets the target version from the connection, can be used in the early stages of the connection
    @Nullable com.viaversion.viaversion.api.connection.UserConnection
    getUserConnection(net.minecraft.network.Connection connection)
    Get the UserConnection for the given connection Connection.
    The version of the mod, this is the version that is displayed in the mod list (e.g., 4.0.0)
    boolean
    itemExists(net.minecraft.world.item.Item item, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
     
    boolean
    itemExistsInConnection(net.minecraft.world.item.Item item)
    Similar to itemExists(net.minecraft.world.item.Item, ProtocolVersion), but takes in the current connection details (e.g., classic protocol extensions being loaded)
    boolean
    itemExistsInConnection(net.minecraft.world.item.ItemStack stack)
    void
    openProtocolSelectionScreen(net.minecraft.client.gui.screens.Screen parent)
    Open the protocol selection screen.
    void
    openSettingsScreen(net.minecraft.client.gui.screens.Screen parent)
    Open the settings screen.
    void
    Register a callback for the loading cycle which covers most of the loading process of the mod.
    void
    Register a callback for when the user changes the target version in the screen, or if the user joins a server with a different version.
    void
    setTargetVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion newVersion)
    Sets the target version
    void
    setTargetVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion newVersion, boolean revertOnDisconnect)
    Sets the target version
    @Nullable net.minecraft.world.item.ItemStack
    translateItem(com.viaversion.viaversion.api.minecraft.item.Item item, com.viaversion.viaversion.api.protocol.version.ProtocolVersion sourceVersion)
    Converts a ViaVersion item Item to a Minecraft item stack ItemStack
    @Nullable com.viaversion.viaversion.api.minecraft.item.Item
    translateItem(net.minecraft.world.item.ItemStack stack, com.viaversion.viaversion.api.protocol.version.ProtocolVersion targetVersion)
    Converts a Minecraft item stack ItemStack to a ViaVersion item Item
  • Method Details

    • apiVersion

      default int apiVersion()
      Returns:
      an internally based API version incremented with meaningful or breaking changes.
    • getVersion

      String getVersion()
      The version of the mod, this is the version that is displayed in the mod list (e.g., 4.0.0)
      Returns:
      the version of the mod
    • getImplVersion

      String getImplVersion()
      The implementation version of the current running jar file, containing commit-hash as well as the getVersion().
      Returns:
      the implementation version of the mod
    • getPath

      Path getPath()
      Get the root path of the mod.
      Returns:
      The root path
    • getTargetVersion

      com.viaversion.viaversion.api.protocol.version.ProtocolVersion getTargetVersion()
      This method is used when you need the target version after connecting to the server.
      Returns:
      the target version
    • setTargetVersion

      void setTargetVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion newVersion)
      Sets the target version
      Parameters:
      newVersion - the target version
    • getTargetVersion

      com.viaversion.viaversion.api.protocol.version.ProtocolVersion getTargetVersion(io.netty.channel.Channel channel)
      Gets the target version from the channel attribute, can be used in the early stages of the connection
      Parameters:
      channel - the channel
      Returns:
      the target version
    • getTargetVersion

      com.viaversion.viaversion.api.protocol.version.ProtocolVersion getTargetVersion(net.minecraft.network.Connection connection)
      Gets the target version from the connection, can be used in the early stages of the connection
      Parameters:
      connection - the connection
      Returns:
      the target version
    • setTargetVersion

      void setTargetVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion newVersion, boolean revertOnDisconnect)
      Sets the target version
      Parameters:
      newVersion - the target version
      revertOnDisconnect - if true, the previous version will be set when the player disconnects from the server
    • getPlayNetworkUserConnection

      @Nullable @Nullable com.viaversion.viaversion.api.connection.UserConnection getPlayNetworkUserConnection()
      Returns:
      the current UserConnection of the connection to the server, if the player isn't connected to a server, it will return null
    • getUserConnection

      @Nullable @Nullable com.viaversion.viaversion.api.connection.UserConnection getUserConnection(net.minecraft.network.Connection connection)
      Get the UserConnection for the given connection Connection.
      Parameters:
      connection - the connection
      Returns:
      the UserConnection
    • getServerVersion

      @Nullable @Nullable com.viaversion.viaversion.api.protocol.version.ProtocolVersion getServerVersion(net.minecraft.client.multiplayer.ServerData serverInfo)
      Gets the per-server protocol version for the given server.
      Parameters:
      serverInfo - the server info
      Returns:
      the server version
    • registerOnChangeProtocolVersionCallback

      void registerOnChangeProtocolVersionCallback(ChangeProtocolVersionCallback callback)
      Register a callback for when the user changes the target version in the screen, or if the user joins a server with a different version.
      Parameters:
      callback - the callback
    • registerLoadingCycleCallback

      void registerLoadingCycleCallback(LoadingCycleCallback callback)
      Register a callback for the loading cycle which covers most of the loading process of the mod. Intended to be used inside ViaFabricPlusLoadEntrypoint implementations.
      Parameters:
      callback - the callback
    • getMaxChatLength

      int getMaxChatLength(com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
      Calculates the maximum chat length for given ProtocolVersion instance.
      Returns:
      The maximum chat length
    • getSettingGroups

      List<SettingGroup> getSettingGroups()
      All setting groups of the mod. Note that this list is not modifiable.
      Returns:
      The setting groups
    • addSettingGroup

      void addSettingGroup(SettingGroup group)
      Add a setting group to the mod.
      Parameters:
      group - The setting group
    • getSettingGroup

      @Nullable @Nullable SettingGroup getSettingGroup(String translationKey)
      Get a setting group by its translationKey.
      Parameters:
      translationKey - The translationKey of the setting group
      Returns:
      The setting group or null if it does not exist
    • openProtocolSelectionScreen

      void openProtocolSelectionScreen(net.minecraft.client.gui.screens.Screen parent)
      Open the protocol selection screen.
      Parameters:
      parent - The parent screen
    • openSettingsScreen

      void openSettingsScreen(net.minecraft.client.gui.screens.Screen parent)
      Open the settings screen.
      Parameters:
      parent - The parent screen
    • translateItem

      @Nullable @Nullable com.viaversion.viaversion.api.minecraft.item.Item translateItem(net.minecraft.world.item.ItemStack stack, com.viaversion.viaversion.api.protocol.version.ProtocolVersion targetVersion)
      Converts a Minecraft item stack ItemStack to a ViaVersion item Item
      Parameters:
      stack - The Minecraft item stack to convert ItemStack
      targetVersion - The target version to convert to (e.g., v1.13) ProtocolVersion
      Returns:
      The ViaVersion item for the target version Item
    • translateItem

      @Nullable @Nullable net.minecraft.world.item.ItemStack translateItem(com.viaversion.viaversion.api.minecraft.item.Item item, com.viaversion.viaversion.api.protocol.version.ProtocolVersion sourceVersion)
      Converts a ViaVersion item Item to a Minecraft item stack ItemStack
      Parameters:
      item - The ViaVersion item to convert Item
      sourceVersion - The source version of the item (e.g., b1.8) ProtocolVersion
      Returns:
      The Minecraft item stack for the source version ItemStack
    • itemExists

      boolean itemExists(net.minecraft.world.item.Item item, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
      Parameters:
      item - The item to check
      version - The version to check for
      Returns:
      true if the item exists in the given version, false otherwise; this will also check for CPE items (CustomBlocks V1 extension)
    • enchantmentExists

      boolean enchantmentExists(net.minecraft.resources.ResourceKey<net.minecraft.world.item.enchantment.Enchantment> enchantment, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
      Parameters:
      enchantment - The enchantment to check
      version - The version to check for
      Returns:
      true if the enchantment exists in the given version, false otherwise
    • effectExists

      boolean effectExists(net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
      Parameters:
      effect - The status effect to check
      version - The version to check for
      Returns:
      true if the status effect exists in the given version, false otherwise
    • bannerPatternExists

      boolean bannerPatternExists(net.minecraft.resources.ResourceKey<net.minecraft.world.level.block.entity.BannerPattern> pattern, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version)
      Parameters:
      pattern - The banner pattern to check
      version - The version to check for
      Returns:
      true if the banner pattern exists in the given version, false otherwise
    • itemExistsInConnection

      boolean itemExistsInConnection(net.minecraft.world.item.Item item)
      Similar to itemExists(net.minecraft.world.item.Item, ProtocolVersion), but takes in the current connection details (e.g., classic protocol extensions being loaded)
      Parameters:
      item - The item to check
      Returns:
      true if the item exists in the current connection, false otherwise
    • itemExistsInConnection

      boolean itemExistsInConnection(net.minecraft.world.item.ItemStack stack)
      Same as itemExists(net.minecraft.world.item.Item, ProtocolVersion), but for item stacks. This also compares against certain data components like enchantments or banner patterns.
      Parameters:
      stack - The item stack to check
      Returns:
      true if the item stack exists in the given version, false otherwise
    • getStackCount

      int getStackCount(net.minecraft.world.item.ItemStack stack)
      Similar to ItemStack.getCount(), but also handles negative item counts in pre 1.11 versions
      Parameters:
      stack - The item stack to get the count of
      Returns:
      the count of the item stack can be negative in pre 1.11 versions