{"id":20881610,"url":"https://github.com/viaversionmcp/vialoadingbase","last_synced_at":"2025-05-12T17:30:40.822Z","repository":{"id":84095538,"uuid":"556028209","full_name":"ViaVersionMCP/ViaLoadingBase","owner":"ViaVersionMCP","description":"[OUTDATED] Universal ViaVersion, ViaBackwards and ViaRewind standalone implementation","archived":false,"fork":false,"pushed_at":"2024-06-26T17:48:31.000Z","size":404,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-06-26T22:18:36.457Z","etag":null,"topics":["java","minecraft","minecraft-protocol","protocol","protocolhack","protocoltranslator","via","viaversion","wikivg"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ViaVersionMCP.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-22T22:36:56.000Z","updated_at":"2024-06-26T17:48:34.000Z","dependencies_parsed_at":"2023-11-18T21:33:37.710Z","dependency_job_id":"ff6803be-0544-4563-9db0-393edc2670d3","html_url":"https://github.com/ViaVersionMCP/ViaLoadingBase","commit_stats":null,"previous_names":["viaversionmcp/vialoadingbase"],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViaVersionMCP%2FViaLoadingBase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViaVersionMCP%2FViaLoadingBase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViaVersionMCP%2FViaLoadingBase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViaVersionMCP%2FViaLoadingBase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ViaVersionMCP","download_url":"https://codeload.github.com/ViaVersionMCP/ViaLoadingBase/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225143584,"owners_count":17427633,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","minecraft","minecraft-protocol","protocol","protocolhack","protocoltranslator","via","viaversion","wikivg"],"created_at":"2024-11-18T07:25:32.592Z","updated_at":"2024-11-18T07:25:33.184Z","avatar_url":"https://github.com/ViaVersionMCP.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ViaLoadingBase\nUniversal ViaVersion, ViaBackwards and ViaRewind standalone implementation \u003cbr\u003e\n\u003cbr\u003e\n### This library is outdated and only maintained to be used in [ViaMCP](https://github.com/FlorianMichael/ViaMCP), please use [ViaLoader](https://github.com/ViaVersion/ViaLoader)\n\n## Contact\nIf you encounter any issues, please report them on the\n[issue tracker](https://github.com/FlorianMichael/ViaLoadingBase/issues).  \nIf you just want to talk or need help with ViaLoadingBase feel free to join my\n[Discord](https://discord.gg/BwWhCHUKDf).\n\n## Add this to your own project\nbuild.gradle\n```groovy\nrepositories {\n    maven {\n        url = \"https://repo.viaversion.com/\"\n    }\n    maven {\n        url = \"https://jitpack.io/\"\n    }\n}\n\ndependencies {\n    // https://ci.viaversion.com/\n    implementation \"com.viaversion:viaversion-common:5.0.2-SNAPSHOT\"\n    implementation \"com.viaversion:viabackwards-common:5.0.2-SNAPSHOT\"\n    implementation \"com.viaversion:viarewind-common:4.0.1-SNAPSHOT\"\n    \n    implementation \"org.yaml:snakeyaml:2.2\"\n    \n    implementation \"com.github.FlorianMichael:ViaLoadingBase:4.7.0\" // https://jitpack.io/#FlorianMichael/ViaLoadingBase\n    \n    // You also need Netty, Guava and Log4j in your class path, but they should be there if your project is based on Minecraft.\n    implementation \"com.google.guava:guava:31.1-jre\"\n    implementation \"io.netty:netty-all:5.0.0.Alpha2\"\n    implementation \"org.apache.logging.log4j:log4j-core:2.19.0\"\n}\n```\n\n### Which library do I need?\nIf your platform is older than the latest Minecraft version, you need ViaVersion + ViaBackwards, if your platform is 1.8.x,\nyou need ViaVersion + ViaBackwards + ViaRewind, otherwise you only need ViaVersion: \u003cbr\u003e\n\nA `1.8.x` Minecraft client for example would need `ViaVersion + ViaBackwards + ViaRewind`. \u003cbr\u003e\nA `1.12.x` Minecraft client for example would need `ViaVersion + ViaBackwards`. \u003cbr\u003e\nA `1.19.x` Minecraft client, for example, would need `ViaVersion`. \u003cbr\u003e\n\n## Example implementation\n```java\npublic void init() { // Basic code to load all platforms which are in the class path\n    ViaLoadingBase.ViaLoadingBaseBuilder.\n        create().\n        runDirectory(new File(\"ViaVersion\")).\n        nativeVersion(47).\n        build();\n}\n```\n\nThe most important part is the modification of your netty pipeline. This is needed for **ViaVersion** to translate the packets in both ways.\n```java\nfinal UserConnection user = new UserConnectionImpl(channel, true);\n\nnew ProtocolPipelineImpl(user);\n\nchannel.pipeline().addLast(new VLBPipeline(user) {\n\n    @Override\n    public String getDecoderHandlerName() {\n        return \"decoder\";\n    }\n\n    @Override\n    public String getEncoderHandlerName() {\n        return \"encoder\";\n    }\n\n    @Override\n    public String getDecompressionHandlerName() {\n        return \"decompress\";\n    }\n\n    @Override\n    public String getCompressionHandlerName() {\n        return \"compress\";\n    }\n});\n```\nIn case your platform has compression, you can call the **CompressionReorderEvent** at the end of the compression code to correct the compression.\n```java\nchannel.pipeline().fireUserEventTriggered(new CompressionReorderEvent());\n```\nViaLoadingBase will use the provided handler names in the VLB Pipeline in order to do that.\n\n### For a mcp based implementation you can have a look at the code in [ViaForge](https://github.com/FlorianMichael/ViaForge)\n\n## API examples\nViaLoadingBase also offers a system to compare the target version with other versions:\n```java\nif (ViaLoadingBase.getInstance().getTargetVersion().olderThan(ProtocolVersion.v1_8)) {\n    // Code is executed when the target version is \u003c than 1.8\n}\nif (ViaLoadingBase.getInstance().getTargetVersion().olderThanOrEqualTo(ProtocolVersion.v1_16_4)) {\n    // Code is executed when the target version is \u003c = than 1.16.4\n}\nif (ViaLoadingBase.getInstance().getTargetVersion().newerThan(ProtocolVersion.v1_12_2)) {\n    // Code is executed when the target version is \u003e than 1.12.2\n}\nif (ViaLoadingBase.getInstance().getTargetVersion().newerThanOrEqualTo(ProtocolVersion.v1_14_4)) {\n    // Code is executed when the target version is \u003e = than 1.14.4\n}\nif (ViaLoadingBase.getInstance().getTargetVersion().equalTo(ProtocolVersion.v1_10)) {\n    // Code is executed when the target version is equal to 1.10\n}\n```\nThe versions are compared according to the order in which they are loaded, each protocol version that is loaded gets an \u003cbr\u003e\nindex that is then used for comparison, so if a platform is loaded last, its protocols are treated as oldest. \u003cbr\u003e\nBelow is explained how to determine the pure sequence\u003cbr\u003e\n\u003cbr\u003e\nTo define a range of versions you can use the *ProtocolRange* class:\n```java\nfinal ProtocolRange allVersionsAbove1_8 = ProtocolRange.andNewer(ProtocolVersion.v1_8);\nfinal ProtocolRange allVersionsUnder1_12_2 = ProtocolRange.andOlder(ProtocolVersion.v1_12_2);\nfinal ProtocolRange only1_18_2 = ProtocolRange.singleton(ProtocolRange.v1_18_2);\n\nif (allVersionsAbove1_8.contains(ProtocolVersion.v1_10)) {\n    // Check if a version is in the range\n}\n```\nThe class also has a toString() method that automatically formats the range\n\n## How to load platforms\n```java\npublic class ExampleImplementation {\n\n    private final Platform examplePlatform = new Platform(\n            \"Example\",\n            () -\u003e ViaLoadingBase.inClassPath(\"net.exampledev.exampleplatform.ExamplePlatform\"), // Checks if the platform class is in the class path\n            ExamplePlatformImpl::new,\n            protocolVersions -\u003e protocolVersions.addAll(ExamplePlatformVersions.PROTOCOLS));\n\n    public void main() {\n        ViaLoadingBase.ViaLoadingBaseBuilder.\n                create().\n\n                platform(examplePlatform). // will set the platform as last \n                platform(examplePlatform, 0). // will set the platform as first \n\n                runDirectory(new File(\"ViaVersion\")).\n                nativeVersion(47).\n                build();\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviaversionmcp%2Fvialoadingbase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviaversionmcp%2Fvialoadingbase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviaversionmcp%2Fvialoadingbase/lists"}