Interface ViaFabricPlusBase
public interface ViaFabricPlusBase
General API point for mods. Get instance via
ViaFabricPlus.getImpl().-
Method Summary
Modifier and TypeMethodDescriptionvoidaddSettingGroup(SettingGroup group) Add a setting group to the mod.default intbooleanbannerPatternExists(net.minecraft.resources.ResourceKey<net.minecraft.world.level.block.entity.BannerPattern> pattern, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version) booleaneffectExists(net.minecraft.core.Holder<net.minecraft.world.effect.MobEffect> effect, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version) booleanenchantmentExists(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 thegetVersion().intgetMaxChatLength(com.viaversion.viaversion.api.protocol.version.ProtocolVersion version) Calculates the maximum chat length for givenProtocolVersioninstance.getPath()Get the root path of the mod.@Nullable com.viaversion.viaversion.api.connection.UserConnection@Nullable com.viaversion.viaversion.api.protocol.version.ProtocolVersiongetServerVersion(net.minecraft.client.multiplayer.ServerData serverInfo) Gets the per-server protocol version for the given server.@Nullable SettingGroupgetSettingGroup(String translationKey) Get a setting group by its translationKey.All setting groups of the mod.intgetStackCount(net.minecraft.world.item.ItemStack stack) Similar toItemStack.getCount(), but also handles negative item counts in pre 1.11 versionscom.viaversion.viaversion.api.protocol.version.ProtocolVersionThis method is used when you need the target version after connecting to the server.com.viaversion.viaversion.api.protocol.version.ProtocolVersiongetTargetVersion(io.netty.channel.Channel channel) Gets the target version from the channel attribute, can be used in early stages of the connectioncom.viaversion.viaversion.api.protocol.version.ProtocolVersiongetTargetVersion(net.minecraft.network.Connection connection) Gets the target version from the connection, can be used in early stages of the connection@Nullable com.viaversion.viaversion.api.connection.UserConnectiongetUserConnection(net.minecraft.network.Connection connection) Get the UserConnection for the given connectionConnection.The version of the mod, this is the version that is displayed in the mod list (e.g.booleanitemExists(net.minecraft.world.item.Item item, com.viaversion.viaversion.api.protocol.version.ProtocolVersion version) booleanitemExistsInConnection(net.minecraft.world.item.Item item) Similar toitemExists(net.minecraft.world.item.Item, ProtocolVersion), but takes in the current connection details (e.g.booleanitemExistsInConnection(net.minecraft.world.item.ItemStack stack) Same asitemExists(net.minecraft.world.item.Item, ProtocolVersion), but for item stacks.voidopenProtocolSelectionScreen(net.minecraft.client.gui.screens.Screen parent) Open the protocol selection screen.voidopenSettingsScreen(net.minecraft.client.gui.screens.Screen parent) Open the settings screen.voidRegister a callback for the loading cycle which covers most of the loading process of the mod.voidRegister a callback for when the user changes the target version in the screen, or if the user joins a server with a different version.voidsetTargetVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion newVersion) Sets the target versionvoidsetTargetVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion newVersion, boolean revertOnDisconnect) Sets the target version@Nullable net.minecraft.world.item.ItemStacktranslateItem(com.viaversion.viaversion.api.minecraft.item.Item item, com.viaversion.viaversion.api.protocol.version.ProtocolVersion sourceVersion) Converts a ViaVersion itemItemto a Minecraft item stackItemStack@Nullable com.viaversion.viaversion.api.minecraft.item.ItemtranslateItem(net.minecraft.world.item.ItemStack stack, com.viaversion.viaversion.api.protocol.version.ProtocolVersion targetVersion) Converts a Minecraft item stackItemStackto a ViaVersion itemItem
-
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 thegetVersion().- Returns:
- the implementation version of the mod
-
getPath
-
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 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 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 versionrevertOnDisconnect- 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 connectionConnection.- 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
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
Register a callback for the loading cycle which covers most of the loading process of the mod. Intended to be used insideViaFabricPlusLoadEntrypointimplementations.- Parameters:
callback- the callback
-
getMaxChatLength
int getMaxChatLength(com.viaversion.viaversion.api.protocol.version.ProtocolVersion version) Calculates the maximum chat length for givenProtocolVersioninstance.- 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
Add a setting group to the mod.- Parameters:
group- The setting group
-
getSettingGroup
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 stackItemStackto a ViaVersion itemItem- Parameters:
stack- The Minecraft item stack to convertItemStacktargetVersion- 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 itemItemto a Minecraft item stackItemStack- Parameters:
item- The ViaVersion item to convertItemsourceVersion- 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 checkversion- 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 checkversion- 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 checkversion- 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 checkversion- 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 toitemExists(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 asitemExists(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 toItemStack.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
-