{"id":18574140,"url":"https://github.com/viaversion/vialoader","last_synced_at":"2025-04-10T07:32:51.034Z","repository":{"id":144935135,"uuid":"584943581","full_name":"ViaVersion/ViaLoader","owner":"ViaVersion","description":"Implementation of a ViaVersion based protocol translator platform","archived":false,"fork":false,"pushed_at":"2024-09-16T22:13:08.000Z","size":431,"stargazers_count":15,"open_issues_count":0,"forks_count":1,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-09-17T11:16:40.394Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ViaVersion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"ko_fi":"rk_01"}},"created_at":"2023-01-03T23:12:40.000Z","updated_at":"2024-09-16T22:13:11.000Z","dependencies_parsed_at":"2023-11-24T17:26:31.035Z","dependency_job_id":"1c92930c-e5e1-4a76-8e9b-16dada8cae19","html_url":"https://github.com/ViaVersion/ViaLoader","commit_stats":null,"previous_names":["raphimc/viaprotocolhack"],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViaVersion%2FViaLoader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViaVersion%2FViaLoader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViaVersion%2FViaLoader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ViaVersion%2FViaLoader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ViaVersion","download_url":"https://codeload.github.com/ViaVersion/ViaLoader/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223430212,"owners_count":17143625,"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":[],"created_at":"2024-11-06T23:14:02.687Z","updated_at":"2025-04-10T07:32:51.024Z","avatar_url":"https://github.com/ViaVersion.png","language":"Java","readme":"# ViaLoader\nEasy to use ViaVersion, (and optional ViaBackwards, ViaRewind, ViaLegacy, ViaAprilFools and ViaBedrock) platform implementation.\n\nViaLoader is not usable by itself as a standalone software, as it is an implementation of a ViaVersion platform.\n\n### Projects implementing ViaLoader\n- [ViaProxy](https://github.com/ViaVersion/ViaProxy): Standalone proxy which allows players to join EVERY Minecraft server version (Classic, Alpha, Beta, Release, Bedrock).\n- [ViaForge](https://github.com/ViaVersion/ViaForge): Client-side Implementation of ViaVersion, ViaBackwards and ViaRewind for Legacy Minecraft Forge.\n- [ViaFabricPlus](https://github.com/ViaVersion/ViaFabricPlus): Fabric mod to connect to EVERY Minecraft server version (Release, Beta, Alpha, Classic, Snapshots, Bedrock) with QoL fixes to the gameplay.\n\n## Releases\n### Gradle/Maven\nTo use ViaLoader with Gradle/Maven you can use the ViaVersion maven server:\n```groovy\nrepositories {\n    maven { url \"https://repo.viaversion.com\" }\n}\n\ndependencies {\n    implementation(\"com.viaversion:vialoader:x.x.x\") // Get latest version from releases\n}\n```\n\n```xml\n\u003crepositories\u003e\n    \u003crepository\u003e\n        \u003cid\u003eviaversion\u003c/id\u003e\n        \u003curl\u003ehttps://repo.viaversion.com\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n\n\u003cdependencies\u003e\n    \u003cdependency\u003e\n        \u003cgroupId\u003ecom.viaversion\u003c/groupId\u003e\n        \u003cartifactId\u003evialoader\u003c/artifactId\u003e\n        \u003cversion\u003ex.x.x\u003c/version\u003e \u003c!-- Get latest version from releases --\u003e\n    \u003c/dependency\u003e\n\u003c/dependencies\u003e\n```\n\n### Jar File\nIf you just want the latest jar file you can download it from [GitHub Actions](https://github.com/RaphiMC/ViaLoader/actions/workflows/build.yml) or the [ViaVersion Jenkins](https://ci.viaversion.com/view/All/job/ViaLoader/).\n\n## Usage\nTo use ViaLoader in your project you need to decide what components of Via* you want to use.\nViaLoader is split into 6 different components:\n- ViaVersion (Is the base component of ViaLoader [required])\n- ViaBackwards (Allows older clients to join to newer server versions [needs ViaVersion])\n- ViaRewind (Allows 1.8.x and 1.7.x clients to join to 1.9+ servers [needs ViaBackwards])\n- ViaLegacy (Allows clients to join to \u003c= 1.7.10 servers [needs ViaVersion])\n- ViaAprilFools (Allows clients to join to some notable Minecraft snapshots [needs ViaBackwards])\n- ViaBedrock (Allows clients to join to Bedrock edition servers [needs latest ViaVersion and ViaLoader snapshot versions])\n\nIn case you want to include ViaBedrock, you have to add the Lenni0451 maven repository to your build script:\n```groovy\nrepositories {\n    maven {\n        name = \"Lenni0451\"\n        url = \"https://maven.lenni0451.net/everything\"\n    }\n}\n```\nHere is an example dependency configuration for all components:\n```groovy\nimplementation \"com.viaversion:viaversion-common:5.3.1\"\nimplementation \"com.viaversion:viabackwards-common:5.3.1\"\nimplementation \"com.viaversion:viarewind-common:4.0.7\"\nimplementation \"net.raphimc:ViaLegacy:3.0.9\"\nimplementation \"com.viaversion:viaaprilfools-common:4.0.1\"\nimplementation \"net.raphimc:ViaBedrock:0.0.16-SNAPSHOT\"\n```\n\n## Implementation\nTo implement ViaLoader into your project you need to initialize the Via* platforms first.  \nViaLoader provides a wrapper class with default values for that. To use a default value you can just pass ``null`` to that argument.\nIf you want to change the default value you should create your own class which extends the base class and overrides the methods you want to change.\n\nThe only default value you have to change is the ``VLLoader`` argument. The loader is used to register all the providers for the Via* platforms. \nProviders are used to provide information about the platform to ViaVersion when it's (almost) impossible to get them ourselves. \n\nTo override the default you first create a new class which extends ``VLLoader`` and overrides the ``load`` method.  \nWithin the ``load`` method you have to register a ``VersionProvider`` implementation which will be used to determine the target server version of a given connection.\nHere is an example implementation:\n```java\npublic class CustomVLLoaderImpl extends VLLoader {\n\n    @Override\n    public void load() {\n        super.load();\n\n        Via.getManager().getProviders().use(VersionProvider.class, new BaseVersionProvider() {\n            @Override\n            public ProtocolVersion getClosestServerProtocol(UserConnection connection) {\n                // Change the logic here to select the target server version\n                return ProtocolVersion.v1_8;\n            }\n        });\n    }\n}\n```\nThen you have to create a new instance of your loader class and pass it to the ``ViaLoader.init`` call.\n\nTo do this you can call the ``ViaLoader.init()`` method somewhere suitable in your project (You can do that async) with your desired argument values:\n```java\nViaLoader.init(null/*ViaPlatform*/, new CustomVLLoaderImpl(), null/*ViaInjector*/, null/*ViaCommandHandler*/, ViaBackwardsPlatformImpl::new, ViaRewindPlatforImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new);\n```\nMake sure to have all platform impls you need added to the init call. Every platform added there needs to be in your dependencies.\n\nAfter you have initialized the Via* platforms you can start implementing ViaLoader into your project.\n\n### Netty modifications\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\nOur recommended way is to use the `VLPipeline` (for codec based pipelines) or the `VLLegacyPipeline` (for decoder/encoder pipelines) as it \nautomatically handles the modifications required for all Via* platforms.\n\nHere is an example implementation:\n```java\npublic class CustomVLPipeline extends VLPipeline {\n\n    public CustomVLPipeline(UserConnection connection) {\n        super(connection);\n    }\n\n    // Replace these with the names of your pipeline components\n    @Override\n    protected String compressionCodecName() {\n        return \"compression_codec\";\n    }\n\n    @Override\n    protected String packetCodecName() {\n        return \"packet_codec\";\n    }\n\n    @Override\n    protected String lengthCodecName() {\n        return \"length_codec\";\n    }\n\n}\n```\nThe same can be done for the `VLLegacyPipeline` with similar functions for the decoder/encoder pairs.\n\nThen you can add the Via* pipeline to your netty pipeline:\n```java\nfinal UserConnection connection = new UserConnectionImpl(channel, true/*clientside or serverside*/);\nnew ProtocolPipelineImpl(connection);\n\nchannel.pipeline().addLast(new CustomVLPipeline(connection));\n```\n\nBoth `VLPipeline` and `VLLegacyPipeline` contain various functions allowing you to modify/wrap the existing pipeline elements,\nif you need a more complex/dynamic pipeline setup you can also manually add the Via* handlers to the pipeline.\nHere is an example implementation:\n```java\nfinal UserConnection connection = new UserConnectionImpl(channel, true/*clientside or serverside*/);\nnew ProtocolPipelineImpl(connection);\n\n//channel.pipeline().addBefore(\"packet_decoder\", VLLegacyPipeline.VIA_DECODER_NAME, new ViaDecoder(connection));\n//channel.pipeline().addBefore(\"packet_encoder\", VLLegacyPipeline.VIA_ENCODER_NAME, new ViaEncoder(connection));\nchannel.pipeline().addBefore(\"packet_codec\", VLPipeline.VIA_CODEC_NAME, new ViaCodec(connection));\n```\nIf you are using ViaLegacy, you should read its [README](https://github.com/ViaVersion/ViaLegacy?tab=readme-ov-file#vialegacy) to see what changes you need to make to the netty pipeline for it to work.\n\nDepending on where you are implementing ViaLoader you might need to ensure that the pipeline is held in the correct order.\nMinecraft clients modify the pipeline order when adding the compression handlers. You have to ensure that the Via* handlers are always on their correct location.\n\nIf you are using the `VLPipeline` or `VLLegacyPipeline` you can fire the `CompressionReorderEvent` once the compression handler is added to the pipeline.\n\nNow you should have a working protocol translator implementation in your project.\n\n## Configuring the protocol translation\nTo change the protocol translation settings/features you can look into the ViaLoader folder.\nYou can find 5 config files there depending on the platforms loaded:\n- viaversion.yml (ViaVersion)\n- viabackwards.yml (ViaBackwards)\n- viarewind.yml (ViaRewind)\n- vialegacy.yml (ViaLegacy)\n- viabedrock.yml (ViaBedrock)\n\n## Contact\nIf you encounter any issues, please report them on the\n[issue tracker](https://github.com/ViaVersion/ViaLoader/issues).  \nIf you just want to talk or need help implementing ViaLoader feel free to join the ViaVersion\n[Discord](https://discord.gg/viaversion).\n","funding_links":["https://ko-fi.com/rk_01"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviaversion%2Fvialoader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fviaversion%2Fvialoader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fviaversion%2Fvialoader/lists"}