Package com.viaversion.viafabricplus.api
Schnittstelle ViaFabricPlusBase
public interface ViaFabricPlusBase
General API point for mods. Get instance via
ViaFabricPlus.getImpl().-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoidaddSettingGroup(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. 4.0.0)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. classic protocol extensions being loaded)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
-
Methodendetails
-
apiVersion
default int apiVersion()- Gibt zurück:
- 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)- Gibt zurück:
- the version of the mod
-
getImplVersion
String getImplVersion()The implementation version of the current running jar file, containing commit-hash as well as thegetVersion().- Gibt zurück:
- the implementation version of the mod
-
getPath
Path getPath()Get the root path of the mod.- Gibt zurück:
- 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.- Gibt zurück:
- the target version
-
setTargetVersion
void setTargetVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion newVersion) Sets the target version- Parameter:
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- Parameter:
channel- the channel- Gibt zurück:
- 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- Parameter:
connection- the connection- Gibt zurück:
- the target version
-
setTargetVersion
void setTargetVersion(com.viaversion.viaversion.api.protocol.version.ProtocolVersion newVersion, boolean revertOnDisconnect) Sets the target version- Parameter:
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()- Gibt zurück:
- 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.- Parameter:
connection- the connection- Gibt zurück:
- 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.- Parameter:
serverInfo- the server info- Gibt zurück:
- 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.- Parameter:
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.- Parameter:
callback- the callback
-
getMaxChatLength
int getMaxChatLength(com.viaversion.viaversion.api.protocol.version.ProtocolVersion version) Calculates the maximum chat length for givenProtocolVersioninstance.- Gibt zurück:
- The maximum chat length
-
getSettingGroups
List<SettingGroup> getSettingGroups()All setting groups of the mod. Note that this list is not modifiable.- Gibt zurück:
- The setting groups
-
addSettingGroup
Add a setting group to the mod.- Parameter:
group- The setting group
-
getSettingGroup
Get a setting group by its translationKey.- Parameter:
translationKey- The translationKey of the setting group- Gibt zurück:
- 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.- Parameter:
parent- The parent screen
-
openSettingsScreen
void openSettingsScreen(net.minecraft.client.gui.screens.Screen parent) Open the settings screen.- Parameter:
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- Parameter:
stack- The Minecraft item stack to convertItemStacktargetVersion- The target version to convert to (e.g. v1.13)ProtocolVersion- Gibt zurück:
- 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- Parameter:
item- The ViaVersion item to convertItemsourceVersion- The source version of the item (e.g. b1.8)ProtocolVersion- Gibt zurück:
- 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) - Parameter:
item- The item to checkversion- The version to check for- Gibt zurück:
- 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) - Parameter:
enchantment- The enchantment to checkversion- The version to check for- Gibt zurück:
- 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) - Parameter:
effect- The status effect to checkversion- The version to check for- Gibt zurück:
- 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) - Parameter:
pattern- The banner pattern to checkversion- The version to check for- Gibt zurück:
- 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)- Parameter:
item- The item to check- Gibt zurück:
- 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.- Parameter:
stack- The item stack to check- Gibt zurück:
- 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- Parameter:
stack- The item stack to get the count of- Gibt zurück:
- the count of the item stack, can be negative in pre 1.11 versions
-