Compare commits

...
107 Commits
Author SHA1 Message Date
Nassim Jahnke 757db4f25b Update VV usage 2026-04-02 15:13:01 +02:00
mfishmaandNassim Jahnke 51f061bfc1 Pass original item ids to custom model data (#1217)
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
2026-04-02 12:02:02 +02:00
Nassim Jahnke 14b3296959 Call super instead of mapTypes in entity rewriter 2026-04-01 17:26:14 +02:00
Florian Reuth 22e823e919 Directly override handle click event in 1.21.6->1.21.5 (#1233) 2026-04-01 10:07:38 +02:00
Nassim Jahnke bd3877bb46 Fix 1.21.6->1.21.5 show dialog read types 2026-03-31 10:53:35 +02:00
Nassim Jahnke 368881055d Fix non-empty custom tag backup in 1.20.5->1.20.4
Fixes #1231
2026-03-31 10:47:36 +02:00
Nassim Jahnke be0f50ad69 Default rewriter registrations across protocols 2026-03-30 20:38:54 +02:00
Nassim Jahnke b63f50750d 5.8.1 Release 2026-03-30 20:28:19 +02:00
Nassim Jahnke 50e7c15db1 Fix wolf_variant tracking in 1.21.5->1.21.4 2026-03-30 20:18:36 +02:00
Nassim Jahnke ef004cfa9c Fix blocks_attack backup with null bypass tag
Closes #1228
2026-03-29 15:18:15 +02:00
Nassim Jahnke 4f4fd5db8f Handle show dialog item changes
Fixes #1200
2026-03-28 17:11:14 +01:00
Nassim Jahnke 57157fd521 Bump version to 5.8.1-SNAPSHOT 2026-03-28 17:06:18 +01:00
Nassim Jahnke db8d9ab411 5.8.0 Release 2026-03-27 17:36:24 +01:00
Colbster937 f92a47df21 Map glazed terracotta blocks to their colored counterparts in 1.12->1.11 (#1220) 2026-03-27 17:36:07 +01:00
mfishma 00a08e95ef Add more sound mappings 2026-03-23 11:11:51 +01:00
Nassim Jahnke 1c652f82fc Remove dye data component too 2026-03-19 20:26:15 +01:00
Nassim Jahnke 7bb2c3e188 Add empty tags for older versions 2026-03-13 12:30:40 +01:00
Florian Reuth 92bbec9b73 Use new fallback value for object components if present in 1.21.9->1.21.7
Signed-off-by: Florian Reuth <git@florianreuth.de>
2026-03-12 21:10:50 +01:00
Nassim Jahnke 2604f8e37f Drop double interact 2026-03-11 21:40:01 +01:00
Nassim Jahnke 938164f22d 26.1-pre1 2026-03-10 21:30:08 +01:00
Nassim Jahnke 2b6948cec3 Fix entity data indexes 2026-03-07 09:49:04 +01:00
Nassim Jahnke 9cfa44368a Back up new item data 2026-03-06 21:15:25 +01:00
Nassim Jahnke f86925d747 26.1-snapshot-11 2026-03-06 20:57:59 +01:00
Nassim Jahnke 5a89919058 26.1-snapshot-10 2026-03-03 16:45:57 +01:00
Nassim Jahnke bf41b02718 26.1-snapshot-8 (maybe) 2026-03-03 16:45:57 +01:00
Nassim Jahnke 593106ff79 26.1-snapshot-7 2026-03-03 16:45:57 +01:00
Nassim Jahnke 0add20f841 26.1-snapshot-6 2026-03-03 16:45:57 +01:00
Nassim Jahnke dc521d9918 26.1-snapshot-5 2026-03-03 16:45:57 +01:00
Nassim Jahnke 98c20752c3 26.1-snapshot-4 2026-03-03 16:45:57 +01:00
Nassim Jahnke bbd17ea7c8 Fix day time setting 2026-03-03 16:45:57 +01:00
Nassim Jahnke b2902561bb 26.1-snapshot-3 2026-03-03 16:45:56 +01:00
Nassim Jahnke 010fc0bb13 26.1-snapshot-2 2026-03-03 16:45:56 +01:00
Nassim Jahnke d1a13c6f78 Update template protocol 2026-03-03 16:45:56 +01:00
Nassim Jahnke 7be2b232d1 26.1-snapshot-1 2026-03-03 16:45:55 +01:00
Nassim Jahnke 07baf2d068 5.7.2 Release 2026-03-01 16:37:00 +01:00
Nassim Jahnke 53a45d6ab6 [ci skip] Add gradle to dependabot config 2026-02-20 22:17:57 +01:00
Nassim Jahnke 831da784e6 Handle 1.21.11->1.21.9 biome sounds and particles 2026-02-20 13:56:30 +01:00
Florian Reuth 69620f894b [ci skip] Update my donation URL (#1198) 2026-02-05 17:09:24 +01:00
dependabot[bot] e5be7a8260 [ci skip] Bump actions/checkout from 6.0.1 to 6.0.2 (#1196)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-02 14:08:24 +01:00
dependabot[bot] a20f6db968 [ci skip] Bump actions/setup-java from 5.1.0 to 5.2.0 (#1197)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-02-02 14:08:10 +01:00
Nassim Jahnke a5949b9d4b [ci skip] Update supported Velocity versions 2026-01-31 12:05:07 +01:00
FlorianMichael e433fb3066 Add config option for code of conduct emulation in 1.21.9->1.21.7 (#1194) 2026-01-28 17:16:23 +01:00
Nassim Jahnke f3be21ed9d Fix trusted tag limiting
Fixes ViaVersion/ViaVersion#4792
2026-01-25 13:16:36 +01:00
FlorianMichael 2a2150beed [ci skip] Remove Gradle wrapper update action (#1192) 2026-01-24 19:25:46 +01:00
Nassim Jahnke f3af5f189c 5.7.1 Release 2026-01-18 16:06:36 +01:00
Pantera (Mad_Daniel) ca69def762 Fix missing entity data for pig and strider saddles in 1.21.5 -> 1.21.4 (#1182) 2026-01-17 17:57:33 +01:00
Pantera (Mad_Daniel) b268342acd Fix frog and cat variant mapping in 1.21.5->1.21.4 (#1183) 2026-01-17 17:54:41 +01:00
FlorianMichael bb61f4dece Add default impl class (#1184) 2026-01-17 14:42:47 +01:00
Nassim Jahnke 2360ea2c6b Fix 1.19->1.18 painting offsets
Fixes #964
2026-01-16 14:27:58 +01:00
Nassim Jahnke 44819eaf03 Move block entity handling to block rewriter
Also fixes double handling in 1.21.5->1.21.4
2026-01-10 13:11:15 +01:00
tmpod a839cb0684 Handle text components in signs in 1.21.7→1.21.5 (#1173) 2026-01-10 11:25:59 +01:00
FlorianMichaelandItsClairton b243e5ee32 Add missing warped & crimson sign range (#1179)
Co-authored-by: ItsClairton <hi@clairton.dev>
2026-01-10 10:23:53 +01:00
dewgs ab20f50510 Fix short overflow in old velocity handling (#1171) 2026-01-07 17:27:12 +01:00
FlorianMichaelandNassim Jahnke 1f4f45195c Update deps (#1170)
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
2026-01-07 16:57:38 +01:00
Nassim Jahnke 9e200b092b Prevent block breaking with spears
Closes #1169
2026-01-05 12:24:20 +01:00
Nassim Jahnke 16b057ecee [ci skip] Update copyright header 2026-01-04 15:43:11 +01:00
MelonHell a1f7c804c3 Don't require config impl class in ViaBackwardsPlatform#init (#1168) 2026-01-04 12:06:31 +01:00
Owen af9edc87fb Fix some older client issues for mannequins (#1166)
Resend the player head rotation, as older clients need to have the player head rotation sent as they don't handle the head rotation correctly in the spawn packet
2026-01-02 10:46:19 +01:00
booky fea7604ab1 Don't send nautilus mob effect to players < 1.21.11 (#1165) 2026-01-02 10:32:39 +01:00
Nassim Jahnke aeb0f4a7ee Bump version to 5.7.1-SNAPSHOT 2026-01-02 10:32:09 +01:00
Nassim Jahnke 76b98eb396 5.7.0 Release 2025-12-29 12:48:01 +01:00
Nassim Jahnke b33221b95c Don't throw on bad entity data in 1.14->1.13 2025-12-28 10:33:03 +01:00
Nassim Jahnke 8ce26b1353 Bump to 5.7.0-SNAPSHOT and update VV usage 2025-12-26 21:57:06 +01:00
9a79f9e217 Delay mannequin spawning for proper skin application (#1158)
Co-authored-by: FlorianMichael <git@florianmichael.de>
Co-authored-by: Nassim Jahnke <nassim@njahnke.dev>
2025-12-26 21:50:10 +01:00
Nassim Jahnke 44476f2468 Replace toIntExact with clamp
Fixes #1159
2025-12-25 09:10:09 +01:00
David Lüdtke 54655e34e7 Fix world border lerp size set in ticks instead of millis (#1156) 2025-12-23 09:55:03 +01:00
Nassim Jahnke 863258df4e Correct overworld fog color 2025-12-21 16:55:01 +01:00
Nassim Jahnke 8a5fce2d2e Put set_objective and set_score packets through component rewriter
Fixes #1155
2025-12-21 15:53:03 +01:00
Nassim Jahnke 5374c3b626 Fix avatar arm handling in 1.21.11->1.21.9 2025-12-20 22:53:24 +01:00
FlorianMichael 96e0d85bc0 Map pale oak shelf to pale oak planks in 1.21.9->1.21.7 (#1154) 2025-12-20 16:38:29 +01:00
Kichura 84576d1d95 [ci skip] Set CI timeout to 30 mins (#1153) 2025-12-20 15:46:05 +01:00
Nassim Jahnke c6f0717ad5 Convert compact sound list to single entry in registry data 2025-12-20 12:00:16 +01:00
Nassim Jahnke 395bebac62 Remove tamable entity data from nautilus
Fixes #1152
2025-12-14 09:25:07 +01:00
FlorianMichael 6d19ad3b81 [ci skip] Include the newest ViaProxy version from 3.0.0 to 4.0.0 (#1151) 2025-12-13 19:59:23 +01:00
Nassim Jahnke 38080fc5cc Remove 1.21.11 registries 2025-12-13 12:04:12 +01:00
FlorianMichael 285dcdd81f Add ViaBackwardsPlatform#init with config instance (#1149) 2025-12-13 11:30:04 +01:00
Nassim Jahnke 1f5fd88fef 5.6.0 Release 2025-12-12 16:00:57 +01:00
Nassim Jahnke 531f7d078e Remove nautilus variant in 1.21.11 component rewriter 2025-12-12 16:00:57 +01:00
Nassim Jahnke 2806671813 Add translatables 2025-12-12 16:00:56 +01:00
Nassim Jahnke 7634a7ec7a Add fog effects to dimensions and biomes 2025-12-12 16:00:56 +01:00
Nassim Jahnke 8cd5bd3368 1.21.11-pre4 2025-12-12 16:00:56 +01:00
Nassim Jahnke 0735e4afb5 Handle biome color type changes 2025-12-12 16:00:56 +01:00
Nassim Jahnke 3568eee8f2 Back up new item data 2025-12-12 16:00:55 +01:00
Nassim Jahnke e694b3532a 1.21.11-pre1 2025-12-12 16:00:55 +01:00
Nassim Jahnke 2bcf79c501 25w46a 2025-12-12 16:00:55 +01:00
Nassim Jahnke 7ded34c55e 25w45a 2025-12-12 16:00:55 +01:00
Nassim Jahnke 3bdeed8a9f 25w43a 2025-12-12 16:00:54 +01:00
Nassim Jahnke 30df707369 WIP 25w42a 2025-12-12 16:00:54 +01:00
github-actions[bot]andgradle-update-robot cf8058016c Update Gradle Wrapper from 9.2.0 to 9.2.1 (#1141)
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2025-12-12 15:58:35 +01:00
Kichura 3468b0a785 Update workflow configs (#1144) 2025-12-06 20:34:00 +01:00
tmpod d273b06e05 Fix text components in signs not being rewritten in 1.21.9→1.21.7 (#1147) 2025-12-06 20:14:36 +01:00
dependabot[bot] 4f561ba4a7 Bump actions/checkout from 5 to 6 (#1142)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-11-24 21:58:08 +01:00
Nanashi.andFlorianMichael 0a5035d209 More dialog emulation fixes (#1131)
Co-authored-by: FlorianMichael <florian.michael07@gmail.com>
2025-11-24 21:57:46 +01:00
Nassim Jahnke 609b657c68 Handle set_player_team text component changes 2025-11-23 19:47:05 +01:00
Nassim Jahnke 5885074fcd [ci skip] Update issue template 2025-11-18 19:50:03 +01:00
Nassim Jahnke d499918e4b Don't cancel full equipment containing saddle in 1.21.5->1.21.4
Plugins manually sending equipment packets may include saddles for entities that shouldn't have saddle equipment, though the client will ignore them
Closes #1140
2025-11-18 19:33:34 +01:00
FlorianMichael 17d7b4873f Set accepted = true in 1.12->1.11.1 shift click fix (#1139) 2025-11-16 19:04:17 +01:00
FlorianMichael 38243bad78 [ci skip] Update ViaFabricPlus jars path (#1133) 2025-11-12 16:58:40 +01:00
Nassim Jahnke 50577abbb5 Fix jukebox_playable backup
Fixes #1130
2025-11-08 10:45:51 +01:00
github-actions[bot]andgradle-update-robot 277de42948 Update Gradle Wrapper from 9.1.0 to 9.2.0 (#1129)
Signed-off-by: gradle-update-robot <gradle-update-robot@regolo.cc>
Co-authored-by: gradle-update-robot <gradle-update-robot@regolo.cc>
2025-11-03 16:52:13 +01:00
FlorianMichael 4c26915fdf Fix text display y offset in 1.19.4->1.19.3 (#1128) 2025-11-01 15:07:36 +01:00
FlorianMichael 7c98b75543 Cancel sign editor open packet for invalid positions in 1.21.2->1.21 (#1099) 2025-11-01 14:59:13 +01:00
Nassim Jahnke 7d39bcc365 Fix regression in cancelling new 1.21.5 registries 2025-10-28 21:11:26 +01:00
Nassim Jahnke 85688beba8 Go through normal registry handling for removed registries in 1.21.5->1.21.4 2025-10-20 14:28:26 +02:00
FlorianMichael fd16c4469c Add option to disable dialog handling in 1.21.6->1.21.5 (#1116) 2025-10-18 18:34:23 +02:00
Nassim Jahnke a37605e920 Update VV usage 2025-10-14 17:59:53 +02:00
FlorianMichael 1d4e41f867 Fix custom action button in notice dialogs not added in 1.21.6->1.21.5 (#1117) 2025-10-13 20:30:47 +02:00
335 changed files with 4708 additions and 2886 deletions

No files matched your search

+1 -1
View File
@@ -1,3 +1,3 @@
github: kennytv
patreon: kennytv
custom: ['https://florianmichael.de/donate']
custom: ['https://florianreuth.de/donate']
+2 -11
View File
@@ -48,21 +48,12 @@ body:
label: Steps to Reproduce
description: |
List the steps on how we can reproduce the issue. Make sure we can easily understand what you mean with each step.
**Please always include the client version(s) with which the issue happens. Ideally also try to find out from what specific version downward/in what version range the issue happens.**
placeholder: |
Example:
1. Login with a 1.16.5 client
2. Place a sign
3. The sign text is displayed wrong
validations:
required: true
- type: textarea
attributes:
label: Expected Behavior
description: |
Describe what exactly you expected to happen.
placeholder: |
Example: "Placed sign text should not disappear."
3. The sign text disappears
validations:
required: true
+9 -1
View File
@@ -1,6 +1,14 @@
version: 2
updates:
- package-ecosystem: "github-actions"
cooldown:
default-days: 7
directory: "/"
schedule:
interval: "weekly"
interval: "monthly"
- package-ecosystem: "gradle"
cooldown:
default-days: 7
directory: "/"
schedule:
interval: "monthly"
+9 -8
View File
@@ -1,22 +1,23 @@
name: Java CI with Gradle
on: [push, pull_request]
name: Build
on: [pull_request, push, workflow_dispatch]
permissions:
contents: read
jobs:
build:
# Only run on PRs if the source branch is on a different repo. We do not need to run everything twice.
if: ${{ github.event_name != 'pull_request' || github.repository != github.event.pull_request.head.repo.full_name }}
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v5
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v5
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # 5.0.1
- name: Set up JDK 17
uses: actions/setup-java@v5
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # 5.2.0
with:
distribution: 'temurin'
java-version: 17
+8 -4
View File
@@ -6,24 +6,28 @@ on:
- dev
workflow_dispatch:
permissions:
contents: read
jobs:
publish:
if: github.repository_owner == 'ViaVersion'
runs-on: ubuntu-24.04
timeout-minutes: 30
steps:
- name: Checkout Repository
uses: actions/checkout@v5
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # 6.0.2
with:
persist-credentials: false
- name: Set up Gradle
uses: gradle/actions/setup-gradle@v5
uses: gradle/actions/setup-gradle@f29f5a9d7b09a7c6b29859002d29d24e1674c884 # 5.0.1
- name: Set up JDK 17
uses: actions/setup-java@v5
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # 5.2.0
with:
distribution: 'temurin'
java-version: 17
check-latest: true
- name: Build
- name: Build with Gradle
run: ./gradlew build --refresh-dependencies
- name: Publish to Hangar
env:
@@ -1,16 +0,0 @@
name: Update Gradle Wrapper
on:
workflow_dispatch:
schedule:
- cron: "0 0 * * 0"
jobs:
update-gradle-wrapper:
runs-on: ubuntu-24.04
steps:
- name: Checkout Repository
uses: actions/checkout@v5
with:
persist-credentials: false
- name: Update Gradle Wrapper
uses: gradle-update/update-gradle-wrapper-action@v2
+1 -1
View File
@@ -12,7 +12,7 @@ Supported Versions
-
As a plugin, ViaBackwards runs on servers on releases 1.10-latest. You can also use ViaBackwards in ViaFabric or ViaFabricPlus.
- in **ViaFabric**, put ViaBackwards into the `mods` folder
- in **ViaFabricPlus**, put ViaBackwards into the `ViaFabricPlus/jars` folder
- in **ViaFabricPlus**, put ViaBackwards into the `config/viafabriclus/jars` folder
See [HERE](https://viaversion.com) for an overview of the different Via* projects.
+1 -1
View File
@@ -8,7 +8,7 @@ repositories {
dependencies {
// version must be manually kept in sync with the one in root project settings.gradle.kts
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.1.0")
implementation("com.gradleup.shadow:shadow-gradle-plugin:9.4.1")
// A nice no-conflict comment for patching in downgrading
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,11 +19,12 @@
package com.viaversion.viabackwards;
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
import com.viaversion.viabackwards.listener.BlockBreakListener;
import com.viaversion.viabackwards.listener.FireDamageListener;
import com.viaversion.viabackwards.listener.FireExtinguishListener;
import com.viaversion.viabackwards.listener.LecternInteractListener;
import com.viaversion.viabackwards.listener.PlayerItemDropListener;
import com.viaversion.viabackwards.listener.DurabilitySync1_11;
import com.viaversion.viabackwards.listener.PlayerHurtSound1_12;
import com.viaversion.viabackwards.listener.FireExtinguish1_16;
import com.viaversion.viabackwards.listener.LecternInteract1_14;
import com.viaversion.viabackwards.listener.ItemDropSync1_17;
import com.viaversion.viabackwards.listener.SpearAttack1_21_11;
import com.viaversion.viabackwards.protocol.v1_20_2to1_20.provider.AdvancementCriteriaProvider;
import com.viaversion.viabackwards.provider.BukkitAdvancementCriteriaProvider;
import com.viaversion.viaversion.api.Via;
@@ -53,20 +54,23 @@ public class BukkitPlugin extends JavaPlugin implements ViaBackwardsPlatform {
ViaBackwardsPlatform.super.enable();
final ProtocolVersion protocolVersion = Via.getAPI().getServerVersion().highestSupportedProtocolVersion();
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_21_11)) {
new SpearAttack1_21_11(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_17)) {
new PlayerItemDropListener(this).register();
new ItemDropSync1_17(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_16)) {
new FireExtinguishListener(this).register();
new FireExtinguish1_16(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_14)) {
new LecternInteractListener(this).register();
new LecternInteract1_14(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_12)) {
new FireDamageListener(this).register();
new PlayerHurtSound1_12(this).register();
}
if (protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_11)) {
new BlockBreakListener(this).register();
new DurabilitySync1_11(this).register();
}
final ViaProviders providers = Via.getManager().getProviders();
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,9 +27,9 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class BlockBreakListener extends ViaBukkitListener {
public class DurabilitySync1_11 extends ViaBukkitListener {
public BlockBreakListener(final BukkitPlugin plugin) {
public DurabilitySync1_11(final BukkitPlugin plugin) {
super(plugin, Protocol1_11To1_10.class);
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,9 +28,9 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
public class FireExtinguishListener extends ViaBukkitListener {
public class FireExtinguish1_16 extends ViaBukkitListener {
public FireExtinguishListener(BukkitPlugin plugin) {
public FireExtinguish1_16(BukkitPlugin plugin) {
super(plugin, Protocol1_16To1_15_2.class);
}
@@ -1,7 +1,7 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -27,9 +27,9 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.inventory.ItemStack;
public class PlayerItemDropListener extends ViaBukkitListener {
public class ItemDropSync1_17 extends ViaBukkitListener {
public PlayerItemDropListener(final BukkitPlugin plugin) {
public ItemDropSync1_17(final BukkitPlugin plugin) {
super(plugin, Protocol1_13_1To1_13.class); // Starts with 1.13 clients on 1.17 servers
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -30,9 +30,9 @@ import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
public class LecternInteractListener extends ViaBukkitListener {
public class LecternInteract1_14 extends ViaBukkitListener {
public LecternInteractListener(BukkitPlugin plugin) {
public LecternInteract1_14(BukkitPlugin plugin) {
super(plugin, Protocol1_14To1_13_2.class);
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -28,9 +28,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageEvent;
public class FireDamageListener extends ViaBukkitListener {
public class PlayerHurtSound1_12 extends ViaBukkitListener {
public FireDamageListener(BukkitPlugin plugin) {
public PlayerHurtSound1_12(BukkitPlugin plugin) {
super(plugin, Protocol1_12To1_11_1.class);
}
@@ -0,0 +1,48 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.listener;
import com.viaversion.viabackwards.BukkitPlugin;
import com.viaversion.viabackwards.protocol.v1_21_11to1_21_9.Protocol1_21_11To1_21_9;
import com.viaversion.viaversion.bukkit.listeners.ViaBukkitListener;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class SpearAttack1_21_11 extends ViaBukkitListener {
public SpearAttack1_21_11(final BukkitPlugin plugin) {
super(plugin, Protocol1_21_11To1_21_9.class);
}
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event) {
final Player player = event.getPlayer();
if (!isOnPipe(player)) {
return;
}
final ItemStack item = player.getInventory().getItemInMainHand();
if (item.getType().name().endsWith("_SPEAR")) {
// Prevent spears from breaking blocks
event.setCancelled(true);
}
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -44,7 +44,10 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
private boolean mapCustomModelData;
private boolean mapDisplayEntities;
private boolean suppressEmulationWarnings;
private boolean dialogsViaChests;
private DialogStyleConfig dialogStyleConfig;
private boolean codeOfConductAsDialog;
private boolean passOriginalItemNameToResourcePacks;
public ViaBackwardsConfig(File configFile, Logger logger) {
super(configFile, logger);
@@ -70,7 +73,10 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
mapCustomModelData = getBoolean("map-custom-model-data", true);
mapDisplayEntities = getBoolean("map-display-entities", true);
suppressEmulationWarnings = getBoolean("suppress-emulation-warnings", false);
dialogsViaChests = getBoolean("dialogs-via-chests", true);
dialogStyleConfig = loadDialogStyleConfig(getSection("dialog-style"));
codeOfConductAsDialog = getBoolean("code-of-conduct-as-dialog", true);
passOriginalItemNameToResourcePacks = getBoolean("pass-original-item-name-to-resource-packs", true);
}
private DialogStyleConfig loadDialogStyleConfig(final ConfigSection section) {
@@ -160,11 +166,26 @@ public class ViaBackwardsConfig extends Config implements com.viaversion.viaback
return suppressEmulationWarnings;
}
@Override
public boolean dialogsViaChests() {
return dialogsViaChests;
}
@Override
public DialogStyleConfig dialogStyleConfig() {
return dialogStyleConfig;
}
@Override
public boolean codeOfConductAsDialog() {
return codeOfConductAsDialog;
}
@Override
public boolean passOriginalItemNameToResourcePacks() {
return passOriginalItemNameToResourcePacks;
}
@Override
public URL getDefaultConfigURL() {
return getClass().getClassLoader().getResource("assets/viabackwards/config.yml");
@@ -0,0 +1,53 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards;
import com.viaversion.viabackwards.api.ViaBackwardsPlatform;
import com.viaversion.viaversion.api.Via;
import java.io.File;
import java.util.logging.Logger;
public class ViaBackwardsPlatformImpl implements ViaBackwardsPlatform {
private final Logger logger;
public ViaBackwardsPlatformImpl() {
logger = Via.getPlatform().createLogger("ViaBackwards");
init(new File(getDataFolder(), "viabackwards.yml"));
enable();
}
@Override
public Logger getLogger() {
return logger;
}
@Override
public void disable() {
}
@Override
public File getDataFolder() {
return Via.getPlatform().getDataFolder();
}
@Override
public boolean isOutdated() {
return false;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,9 +18,9 @@
package com.viaversion.viabackwards.api;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.text.TranslatableRewriter;
import com.viaversion.viabackwards.api.rewriters.BackwardsRegistryRewriter;
import com.viaversion.viabackwards.protocol.registration.BackwardsRegistrations;
import com.viaversion.viabackwards.utils.BackwardsProtocolLogger;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
@@ -31,6 +31,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
public abstract class BackwardsProtocol<CU extends ClientboundPacketType, CM extends ClientboundPacketType, SM extends ServerboundPacketType, SU extends ServerboundPacketType>
extends AbstractProtocol<CU, CM, SM, SU> {
@Deprecated
protected BackwardsProtocol() {
}
@@ -39,21 +40,10 @@ public abstract class BackwardsProtocol<CU extends ClientboundPacketType, CM ext
super(oldClientboundPacketEnum, clientboundPacketEnum, oldServerboundPacketEnum, serverboundPacketEnum);
}
/**
* Waits for the given protocol to be loaded to then asynchronously execute the runnable for this protocol.
*/
protected void executeAsyncAfterLoaded(Class<? extends Protocol> protocolClass, Runnable runnable) {
Via.getManager().getProtocolManager().addMappingLoaderFuture(getClass(), protocolClass, runnable);
}
@Override
protected void registerPackets() {
super.registerPackets();
final BackwardsMappingData mappingData = getMappingData();
if (mappingData != null && mappingData.getViaVersionProtocolClass() != null) {
executeAsyncAfterLoaded(mappingData.getViaVersionProtocolClass(), this::loadMappingData);
}
protected void applySharedRegistrations() {
super.applySharedRegistrations();
BackwardsRegistrations.registrations().applyMatching(this);
}
@Override
@@ -62,18 +52,17 @@ public abstract class BackwardsProtocol<CU extends ClientboundPacketType, CM ext
}
@Override
public boolean hasMappingDataToLoad() {
// Manually load them later, since they depend on VV's mappings
return false;
public @Nullable Class<? extends Protocol<?, ?, ?, ?>> dependsOn() {
return getMappingData() != null ? getMappingData().getViaVersionProtocolClass() : null;
}
@Override
public @Nullable BackwardsMappingData getMappingData() { // Change return type to BackwardsMappings
public @Nullable BackwardsMappingData getMappingData() {
return null;
}
@Override
public @Nullable TranslatableRewriter getComponentRewriter() {
public @Nullable BackwardsRegistryRewriter getRegistryDataRewriter() {
return null;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -113,10 +113,33 @@ public interface ViaBackwardsConfig extends Config {
*/
boolean suppressEmulationWarnings();
/**
* If enabled, dialogs will be shown via chest inventories for 1.21.5 clients on 1.21.6+ servers.
*
* @return true if enabled
*/
boolean dialogsViaChests();
/**
* Returns the dialog style configuration.
*
* @return the dialog style configuration
*/
DialogStyleConfig dialogStyleConfig();
/**
* If true, the code of conduct will be displayed as a dialog for 1.21.7 clients on 1.21.9+ servers.
*
* @return true if enabled
*/
boolean codeOfConductAsDialog();
/**
* Injects the original vanilla 1.21.4+ item name into custom_model_data strings for resource packs.
* Disable if your server creates custom items using modern items as their base.
* Tip: For server custom items, base them on items in the game before 1.21.4 (e.g. saddle) to ensure compatibility.
*
* @return true if enabled
*/
boolean passOriginalItemNameToResourcePacks();
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,6 +21,7 @@ package com.viaversion.viabackwards.api;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.ViaBackwardsConfig;
import com.viaversion.viabackwards.api.data.TranslatableMappings;
import com.viaversion.viabackwards.protocol.registration.BackwardsRegistrations;
import com.viaversion.viabackwards.protocol.v1_10to1_9_3.Protocol1_10To1_9_3;
import com.viaversion.viabackwards.protocol.v1_11_1to1_11.Protocol1_11_1To1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.Protocol1_11To1_10;
@@ -55,6 +56,7 @@ import com.viaversion.viabackwards.protocol.v1_20_2to1_20.Protocol1_20_2To1_20;
import com.viaversion.viabackwards.protocol.v1_20_3to1_20_2.Protocol1_20_3To1_20_2;
import com.viaversion.viabackwards.protocol.v1_20_5to1_20_3.Protocol1_20_5To1_20_3;
import com.viaversion.viabackwards.protocol.v1_20to1_19_4.Protocol1_20To1_19_4;
import com.viaversion.viabackwards.protocol.v1_21_11to1_21_9.Protocol1_21_11To1_21_9;
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.Protocol1_21_2To1_21;
import com.viaversion.viabackwards.protocol.v1_21_2to1_21.task.PlayerPacketsTickTask;
import com.viaversion.viabackwards.protocol.v1_21_4to1_21_2.Protocol1_21_4To1_21_2;
@@ -66,6 +68,7 @@ import com.viaversion.viabackwards.protocol.v1_21_9to1_21_7.Protocol1_21_9To1_21
import com.viaversion.viabackwards.protocol.v1_21to1_20_5.Protocol1_21To1_20_5;
import com.viaversion.viabackwards.protocol.v1_9_1to1_9.Protocol1_9_1To1_9;
import com.viaversion.viabackwards.protocol.v1_9_3to1_9_1.Protocol1_9_3To1_9_1;
import com.viaversion.viabackwards.protocol.v26_1to1_21_11.Protocol26_1To1_21_11;
import com.viaversion.viabackwards.utils.VersionInfo;
import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.protocol.ProtocolManager;
@@ -77,13 +80,16 @@ import java.util.logging.Logger;
public interface ViaBackwardsPlatform {
String MINIMUM_VV_VERSION = "5.5.1";
String MINIMUM_VV_VERSION = "5.8.1";
default void init(final File configFile) {
init(new ViaBackwardsConfig(configFile, getLogger()));
}
/**
* Initialize ViaBackwards.
*/
default void init(final File configFile) {
ViaBackwardsConfig config = new ViaBackwardsConfig(configFile, getLogger());
default void init(final com.viaversion.viabackwards.api.ViaBackwardsConfig config) {
config.reload();
Via.getManager().getConfigurationProvider().register(config);
@@ -100,6 +106,8 @@ public interface ViaBackwardsPlatform {
TranslatableMappings.loadTranslatables();
getLogger().info("Registering protocols...");
BackwardsRegistrations.apply();
final ProtocolManager protocolManager = Via.getManager().getProtocolManager();
protocolManager.registerProtocol(new Protocol1_9_1To1_9(), ProtocolVersion.v1_9, ProtocolVersion.v1_9_1);
protocolManager.registerProtocol(new Protocol1_9_3To1_9_1(), Arrays.asList(ProtocolVersion.v1_9_1, ProtocolVersion.v1_9_2), ProtocolVersion.v1_9_3);
@@ -156,6 +164,9 @@ public interface ViaBackwardsPlatform {
protocolManager.registerProtocol(new Protocol1_21_6To1_21_5(), ProtocolVersion.v1_21_5, ProtocolVersion.v1_21_6);
protocolManager.registerProtocol(new Protocol1_21_7To1_21_6(), ProtocolVersion.v1_21_6, ProtocolVersion.v1_21_7);
protocolManager.registerProtocol(new Protocol1_21_9To1_21_7(), ProtocolVersion.v1_21_7, ProtocolVersion.v1_21_9);
protocolManager.registerProtocol(new Protocol1_21_11To1_21_9(), ProtocolVersion.v1_21_9, ProtocolVersion.v1_21_11);
protocolManager.registerProtocol(new Protocol26_1To1_21_11(), ProtocolVersion.v1_21_11, ProtocolVersion.v26_1);
}
default void enable() {
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -24,6 +24,7 @@ import com.viaversion.nbt.tag.IntTag;
import com.viaversion.nbt.tag.ListTag;
import com.viaversion.nbt.tag.StringTag;
import com.viaversion.nbt.tag.Tag;
import com.viaversion.viabackwards.ViaBackwards;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.data.MappedItem;
@@ -40,6 +41,7 @@ import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.rewriter.StructuredItemRewriter;
import com.viaversion.viaversion.util.ArrayUtil;
import com.viaversion.viaversion.util.Key;
import java.util.ArrayList;
import java.util.List;
@@ -51,9 +53,13 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
T extends BackwardsProtocol<C, ?, ?, S>> extends StructuredItemRewriter<C, S, T> {
private static final int[] EMPTY_INT_ARRAY = new int[0];
private static final String GLOBAL_MODEL_DATA_MARKER = "VB|injected_cmd";
private final String nbtTagName;
public BackwardsStructuredItemRewriter(T protocol) {
super(protocol);
this.nbtTagName = "VB|" + protocol.getClass().getSimpleName();
}
@Override
@@ -70,17 +76,11 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
customTag.putInt(nbtTagName("id"), item.identifier()); // Save original id
// Add custom model data
if (mappedItem.customModelData() != null) {
final boolean addOriginalIdentifier = ViaBackwards.getConfig().passOriginalItemNameToResourcePacks();
if (mappedItem.customModelData() != null || addOriginalIdentifier) {
if (connection.getProtocolInfo().protocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_21_4)) {
if (!dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4)) {
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, new CustomModelData1_21_4(
new float[]{mappedItem.customModelData().floatValue()},
new boolean[0],
new String[0],
EMPTY_INT_ARRAY
));
}
} else if (!dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA1_20_5)) {
addCustomModelData(item, addOriginalIdentifier, mappedItem, customTag);
} else if (mappedItem.customModelData() != null && !dataContainer.has(StructuredDataKey.CUSTOM_MODEL_DATA1_20_5)) {
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_20_5, mappedItem.customModelData());
}
}
@@ -92,6 +92,33 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
}
}
private void addCustomModelData(final Item item, final boolean addOriginalIdentifier, final MappedItem mappedItem, final CompoundTag customTag) {
final StructuredDataContainer dataContainer = item.dataContainer();
CustomModelData1_21_4 customModelData = dataContainer.get(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4);
if (customModelData == null) {
final String[] strings = addOriginalIdentifier
? new String[]{protocol.getMappingData().getFullItemMappings().identifier(item.identifier())}
: new String[0];
customModelData = new CustomModelData1_21_4(
mappedItem.customModelData() != null ? new float[]{mappedItem.customModelData().floatValue()} : new float[0],
new boolean[0],
strings,
EMPTY_INT_ARRAY
);
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, customModelData);
// Add one global marker and one for this specific version, so it is removed at the correct protocol
customTag.putBoolean(GLOBAL_MODEL_DATA_MARKER, true);
customTag.putBoolean(nbtTagName("added_custom_model_data"), true);
} else if (addOriginalIdentifier && !customTag.contains(GLOBAL_MODEL_DATA_MARKER)) {
final String identifier = protocol.getMappingData().getFullItemMappings().identifier(item.identifier());
dataContainer.set(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, new CustomModelData1_21_4(
customModelData.floats(), customModelData.booleans(), ArrayUtil.add(customModelData.strings(), identifier), customModelData.colors()
));
customTag.putBoolean(GLOBAL_MODEL_DATA_MARKER, true);
customTag.putString(nbtTagName("injected_custom_model_data"), identifier);
}
}
@Override
protected void restoreBackupData(final Item item, final StructuredDataContainer container, final CompoundTag customData) {
super.restoreBackupData(item, container, customData);
@@ -99,6 +126,25 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
item.setIdentifier(originalTag.asInt());
removeCustomTag(container, customData);
}
if (removeBackupTag(customData, "injected_custom_model_data") instanceof StringTag injectedCustomModelData) {
customData.remove(GLOBAL_MODEL_DATA_MARKER);
container.replace(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4, customModelData -> {
final String target = injectedCustomModelData.getValue();
final String[] strings = customModelData.strings();
for (int i = 0; i < strings.length; i++) {
if (strings[i].equals(target)) {
// Remove the injected string
final String[] filteredStrings = ArrayUtil.remove(strings, i);
return new CustomModelData1_21_4(customModelData.floats(), customModelData.booleans(), filteredStrings, customModelData.colors());
}
}
return customModelData;
});
} else if (removeBackupTag(customData, "added_custom_model_data") != null) {
customData.remove(GLOBAL_MODEL_DATA_MARKER);
container.remove(StructuredDataKey.CUSTOM_MODEL_DATA1_21_4);
}
}
protected void saveListTag(CompoundTag tag, ListTag<?> original, String name) {
@@ -300,7 +346,11 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
}
protected Holder<SoundEvent> restoreSoundEventHolder(final CompoundTag tag) {
return restoreHolder(tag, "sound_event", soundEventTag -> {
return restoreSoundEventHolder(tag, "sound_event");
}
protected Holder<SoundEvent> restoreSoundEventHolder(final CompoundTag tag, final String key) {
return restoreHolder(tag, key, soundEventTag -> {
final String identifier = soundEventTag.getString("identifier");
final FloatTag fixedRange = soundEventTag.getFloatTag("fixed_range");
return new SoundEvent(identifier, fixedRange != null ? fixedRange.asFloat() : null);
@@ -309,6 +359,6 @@ public class BackwardsStructuredItemRewriter<C extends ClientboundPacketType, S
@Override
public String nbtTagName() {
return "VB|" + protocol.getClass().getSimpleName();
return this.nbtTagName;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -38,7 +38,7 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
}
@Override
public void registerTrackerWithData(C packetType, EntityType fallingBlockType) {
public void registerTrackerWithData(C packetType) {
protocol.registerClientbound(packetType, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Entity ID
wrapper.passthrough(Types.UUID); // Entity UUID
@@ -49,12 +49,12 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
wrapper.passthrough(Types.BYTE); // Pitch
wrapper.passthrough(Types.BYTE); // Yaw
wrapper.passthrough(Types.INT); // Data
getSpawnTrackerWithDataHandler(fallingBlockType).handle(wrapper);
getSpawnTrackerWithDataHandler().handle(wrapper);
});
}
@Override
public void registerTrackerWithData1_19(C packetType, EntityType fallingBlockType) {
public void registerTrackerWithData1_19(C packetType) {
protocol.registerClientbound(packetType, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Entity id
wrapper.passthrough(Types.UUID); // Entity UUID
@@ -66,22 +66,22 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
wrapper.passthrough(Types.BYTE); // Yaw
wrapper.passthrough(Types.BYTE); // Head yaw
wrapper.passthrough(Types.VAR_INT); // Data
getSpawnTrackerWithDataHandler1_19(fallingBlockType).handle(wrapper);
getSpawnTrackerWithDataHandler1_19().handle(wrapper);
});
}
public PacketHandler getSpawnTrackerWithDataHandler(EntityType fallingBlockType) {
public PacketHandler getSpawnTrackerWithDataHandler() {
return wrapper -> {
// Check against the UNMAPPED entity type
EntityType entityType = trackAndMapEntity(wrapper);
if (entityType == fallingBlockType) {
if (entityType == typeFromId("falling_block")) {
int blockState = wrapper.get(Types.INT, 0);
wrapper.set(Types.INT, 0, protocol.getMappingData().getNewBlockStateId(blockState));
}
};
}
public PacketHandler getSpawnTrackerWithDataHandler1_19(EntityType fallingBlockType) {
public PacketHandler getSpawnTrackerWithDataHandler1_19() {
return wrapper -> {
if (protocol.getMappingData() == null) {
return;
@@ -89,14 +89,15 @@ public abstract class EntityRewriter<C extends ClientboundPacketType, T extends
// Check against the UNMAPPED entity type
EntityType entityType = trackAndMapEntity(wrapper);
if (entityType == fallingBlockType) {
if (entityType == typeFromId("falling_block")) {
int blockState = wrapper.get(Types.VAR_INT, 2);
wrapper.set(Types.VAR_INT, 2, protocol.getMappingData().getNewBlockStateId(blockState));
}
};
}
public void registerSpawnTracker(C packetType) {
@Override
public void registerTracker(C packetType) {
protocol.registerClientbound(packetType, wrapper -> {
wrapper.passthrough(Types.VAR_INT); // Entity ID
wrapper.passthrough(Types.UUID); // Entity UUID
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,24 +17,22 @@
*/
package com.viaversion.viabackwards.api.rewriters;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viaversion.api.minecraft.Holder;
import com.viaversion.viaversion.api.minecraft.SoundEvent;
import com.viaversion.viaversion.api.data.Mappings;
import com.viaversion.viaversion.api.protocol.AbstractProtocol;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
import com.viaversion.viaversion.api.type.Types;
public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversion.viaversion.rewriter.SoundRewriter<C> {
private final BackwardsProtocol<C, ?, ?, ?> protocol;
public SoundRewriter(final BackwardsProtocol<C, ?, ?, ?> protocol) {
public SoundRewriter(final AbstractProtocol<C, ?, ?, ?> protocol) {
super(protocol);
this.protocol = protocol;
}
public void registerNamedSound(final C packetType) {
if (protocol.getMappingData() == null || Mappings.isFullIdentity(protocol.getMappingData().getFullSoundMappings())) {
return;
}
protocol.registerClientbound(packetType, wrapper -> {
wrapper.passthrough(Types.STRING); // Sound identifier
getNamedSoundHandler().handle(wrapper);
@@ -42,27 +40,10 @@ public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversi
}
public void registerStopSound(final C packetType) {
protocol.registerClientbound(packetType, wrapper -> getStopSoundHandler().handle(wrapper));
}
public PacketHandler getNamedSoundHandler() {
return wrapper -> {
final String soundId = wrapper.get(Types.STRING, 0);
final String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
if (mappedId == null) {
return;
}
if (!mappedId.isEmpty()) {
wrapper.set(Types.STRING, 0, mappedId);
} else {
wrapper.cancel();
}
};
}
public PacketHandler getStopSoundHandler() {
return wrapper -> {
if (protocol.getMappingData() == null || Mappings.isFullIdentity(protocol.getMappingData().getFullSoundMappings())) {
return;
}
protocol.registerClientbound(packetType, wrapper -> {
final byte flags = wrapper.passthrough(Types.BYTE);
if ((flags & 0x01) != 0) {
wrapper.passthrough(Types.VAR_INT); // Source
@@ -70,7 +51,7 @@ public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversi
if ((flags & 0x02) == 0) return; // No sound specified
final String soundId = wrapper.read(Types.STRING);
final String mappedId = protocol.getMappingData().getMappedNamedSound(soundId);
final String mappedId = protocol.getMappingData().getFullSoundMappings().mappedIdentifier(soundId);
if (mappedId == null) {
// No mapping found
wrapper.write(Types.STRING, soundId);
@@ -83,45 +64,22 @@ public class SoundRewriter<C extends ClientboundPacketType> extends com.viaversi
// Cancel if set to empty
wrapper.cancel();
}
};
});
}
@Override
public void registerSound1_19_3(final C packetType) {
protocol.registerClientbound(packetType, getSoundHandler1_19_3());
}
public PacketHandler getSoundHandler1_19_3() {
public PacketHandler getNamedSoundHandler() {
return wrapper -> {
Holder<SoundEvent> soundEventHolder = wrapper.read(Types.SOUND_EVENT);
if (soundEventHolder.isDirect()) {
wrapper.write(Types.SOUND_EVENT, rewriteSoundEvent(wrapper, soundEventHolder));
final String soundId = wrapper.get(Types.STRING, 0);
final String mappedId = protocol.getMappingData().getFullSoundMappings().mappedIdentifier(soundId);
if (mappedId == null) {
return;
}
final int mappedId = idRewriter.rewrite(soundEventHolder.id());
if (mappedId == -1) {
if (!mappedId.isEmpty()) {
wrapper.set(Types.STRING, 0, mappedId);
} else {
wrapper.cancel();
return;
}
if (mappedId != soundEventHolder.id()) {
soundEventHolder = Holder.of(mappedId);
}
wrapper.write(Types.SOUND_EVENT, soundEventHolder);
};
}
public Holder<SoundEvent> rewriteSoundEvent(final PacketWrapper wrapper, final Holder<SoundEvent> soundEventHolder) {
final SoundEvent soundEvent = soundEventHolder.value();
final String mappedIdentifier = protocol.getMappingData().getMappedNamedSound(soundEvent.identifier());
if (mappedIdentifier != null) {
if (!mappedIdentifier.isEmpty()) {
return Holder.of(soundEvent.withIdentifier(mappedIdentifier));
}
wrapper.cancel();
}
return soundEventHolder;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -0,0 +1,38 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.registration;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import com.viaversion.viaversion.protocol.shared_registration.SharedRegistrations;
public final class BackwardsRegistrations {
private static final SharedRegistrations REGISTRATIONS = SharedRegistrations.create();
public static void apply() {
REGISTRATIONS.registrations()
.range(ProtocolVersion.v1_10, ProtocolVersion.v1_19_3, RegistryRegistrations::registerNamedSound1_10)
.since(ProtocolVersion.v1_14, RegistryRegistrations::registerStopSound1_14)
.register();
}
public static SharedRegistrations registrations() {
return REGISTRATIONS;
}
}
@@ -0,0 +1,36 @@
/*
* This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.registration;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType;
import com.viaversion.viaversion.protocol.shared_registration.PacketBound;
import com.viaversion.viaversion.protocol.shared_registration.RegistrationContext;
import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14;
import com.viaversion.viaversion.protocols.v1_9_1to1_9_3.packet.ClientboundPackets1_9_3;
final class RegistryRegistrations {
static <CU extends ClientboundPacketType> void registerNamedSound1_10(final RegistrationContext<CU, ?> ctx) {
ctx.clientbound(ClientboundPackets1_9_3.CUSTOM_SOUND, new SoundRewriter<>(ctx.protocol())::registerNamedSound, PacketBound.REMOVED_AT_MAX);
}
static <CU extends ClientboundPacketType> void registerStopSound1_14(final RegistrationContext<CU, ?> ctx) {
ctx.clientbound(ClientboundPackets1_14.STOP_SOUND, new SoundRewriter<>(ctx.protocol())::registerStopSound);
}
}
@@ -1,95 +0,0 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.template;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType1_21_5;
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPacket1_21_4;
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPackets1_21_4;
import com.viaversion.viaversion.protocols.v1_21_4to1_21_5.rewriter.RecipeDisplayRewriter1_21_5;
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
// To replace if needed:
// ChunkType1_21_5
// RecipeDisplayRewriter
// Types1_21_4
final class BlockItemPacketRewriter1_99 extends BackwardsStructuredItemRewriter<ClientboundPacket1_21_2, ServerboundPacket1_21_4, Protocol1_99To1_98> {
public BlockItemPacketRewriter1_99(final Protocol1_99To1_98 protocol) {
super(protocol);
}
@Override
public void registerPackets() {
final BlockRewriter<ClientboundPacket1_21_2> blockRewriter = BlockRewriter.for1_20_2(protocol);
blockRewriter.registerBlockEvent(ClientboundPackets1_21_2.BLOCK_EVENT);
blockRewriter.registerBlockUpdate(ClientboundPackets1_21_2.BLOCK_UPDATE);
blockRewriter.registerSectionBlocksUpdate1_20(ClientboundPackets1_21_2.SECTION_BLOCKS_UPDATE);
blockRewriter.registerLevelEvent1_21(ClientboundPackets1_21_2.LEVEL_EVENT, 2001);
blockRewriter.registerLevelChunk1_19(ClientboundPackets1_21_2.LEVEL_CHUNK_WITH_LIGHT, ChunkType1_21_5::new);
blockRewriter.registerBlockEntityData(ClientboundPackets1_21_2.BLOCK_ENTITY_DATA);
// registerOpenScreen(ClientboundPackets1_21_2.OPEN_SCREEN);
registerSetCursorItem(ClientboundPackets1_21_2.SET_CURSOR_ITEM);
registerSetPlayerInventory(ClientboundPackets1_21_2.SET_PLAYER_INVENTORY);
registerCooldown1_21_2(ClientboundPackets1_21_2.COOLDOWN);
registerSetContent1_21_2(ClientboundPackets1_21_2.CONTAINER_SET_CONTENT);
registerSetSlot1_21_2(ClientboundPackets1_21_2.CONTAINER_SET_SLOT);
registerAdvancements1_20_3(ClientboundPackets1_21_2.UPDATE_ADVANCEMENTS);
registerSetEquipment(ClientboundPackets1_21_2.SET_EQUIPMENT);
registerMerchantOffers1_20_5(ClientboundPackets1_21_2.MERCHANT_OFFERS);
registerContainerClick1_21_5(ServerboundPackets1_21_4.CONTAINER_CLICK);
registerSetCreativeModeSlot1_21_5(ServerboundPackets1_21_4.SET_CREATIVE_MODE_SLOT);
final RecipeDisplayRewriter<ClientboundPacket1_21_2> recipeRewriter = new RecipeDisplayRewriter1_21_5<>(protocol);
recipeRewriter.registerUpdateRecipes(ClientboundPackets1_21_2.UPDATE_RECIPES);
recipeRewriter.registerRecipeBookAdd(ClientboundPackets1_21_2.RECIPE_BOOK_ADD);
recipeRewriter.registerPlaceGhostRecipe(ClientboundPackets1_21_2.PLACE_GHOST_RECIPE);
}
@Override
protected void handleItemDataComponentsToClient(final UserConnection connection, final Item item, final StructuredDataContainer container) {
super.handleItemDataComponentsToClient(connection, item, container);
// downgradeData(item, container); // static import VV method
}
@Override
protected void handleItemDataComponentsToServer(final UserConnection connection, final Item item, final StructuredDataContainer container) {
super.handleItemDataComponentsToServer(connection, item, container);
// upgradeData(item, container); // static import VV method
}
@Override
protected void restoreBackupData(final Item item, final StructuredDataContainer container, final CompoundTag customData) {
super.restoreBackupData(item, container, customData);
// restore any data if needed here
}
@Override
protected void backupInconvertibleData(final UserConnection connection, final Item item, final StructuredDataContainer dataContainer, final CompoundTag backupTag) {
super.backupInconvertibleData(connection, item, dataContainer, backupTag);
// back up any data if needed here, called before the method below
}
}
@@ -0,0 +1,64 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.template;
import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viabackwards.api.rewriters.BackwardsStructuredItemRewriter;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.data.StructuredDataContainer;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ServerboundPacket1_21_9;
// To replace if needed:
// ChunkType1_21_5
// RecipeDisplayRewriter
final class BlockItemPacketRewriter99_1 extends BackwardsStructuredItemRewriter<ClientboundPacket26_1, ServerboundPacket1_21_9, Protocol99_1To98_1> {
public BlockItemPacketRewriter99_1(final Protocol99_1To98_1 protocol) {
super(protocol);
}
@Override
public void registerPackets() {
}
@Override
protected void handleItemDataComponentsToClient(final UserConnection connection, final Item item, final StructuredDataContainer container) {
super.handleItemDataComponentsToClient(connection, item, container);
// downgradeData(item, container); // static import VV method
}
@Override
protected void handleItemDataComponentsToServer(final UserConnection connection, final Item item, final StructuredDataContainer container) {
super.handleItemDataComponentsToServer(connection, item, container);
// upgradeData(item, container); // static import VV method
}
@Override
protected void restoreBackupData(final Item item, final StructuredDataContainer container, final CompoundTag customData) {
super.restoreBackupData(item, container, customData);
// restore any data if needed here
}
@Override
protected void backupInconvertibleData(final UserConnection connection, final Item item, final StructuredDataContainer dataContainer, final CompoundTag backupTag) {
super.backupInconvertibleData(connection, item, dataContainer, backupTag);
// back up any data if needed here, called before the method below
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -21,11 +21,11 @@ import com.viaversion.nbt.tag.CompoundTag;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.rewriters.text.NBTComponentRewriter;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
final class ComponentRewriter1_99 extends NBTComponentRewriter<ClientboundPacket1_21_2> {
final class ComponentRewriter99_1 extends NBTComponentRewriter<ClientboundPacket26_1> {
public ComponentRewriter1_99(final BackwardsProtocol<ClientboundPacket1_21_2, ?, ?, ?> protocol) {
public ComponentRewriter99_1(final BackwardsProtocol<ClientboundPacket26_1, ?, ?, ?> protocol) {
super(protocol);
}
@@ -1,93 +0,0 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.template;
import com.viaversion.viabackwards.api.rewriters.BackwardsRegistryRewriter;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_4;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21_2;
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
import com.viaversion.viaversion.rewriter.RegistryDataRewriter;
// Replace if needed
// VersionedTypes
final class EntityPacketRewriter1_99 extends EntityRewriter<ClientboundPacket1_21_2, Protocol1_99To1_98> {
public EntityPacketRewriter1_99(final Protocol1_99To1_98 protocol) {
super(protocol, VersionedTypes.V1_21_4.entityDataTypes.optionalComponentType, VersionedTypes.V1_21_4.entityDataTypes.booleanType);
}
@Override
public void registerPackets() {
registerTrackerWithData1_21_9(ClientboundPackets1_21_2.ADD_ENTITY, EntityTypes1_21_4.FALLING_BLOCK);
registerSetEntityData(ClientboundPackets1_21_2.SET_ENTITY_DATA);
registerRemoveEntities(ClientboundPackets1_21_2.REMOVE_ENTITIES);
registerPlayerAbilities(ClientboundPackets1_21_2.PLAYER_ABILITIES);
registerGameEvent(ClientboundPackets1_21_2.GAME_EVENT);
registerLogin1_20_5(ClientboundPackets1_21_2.LOGIN);
registerRespawn1_20_5(ClientboundPackets1_21_2.RESPAWN);
final RegistryDataRewriter registryDataRewriter = new BackwardsRegistryRewriter(protocol);
protocol.registerClientbound(ClientboundConfigurationPackets1_21.REGISTRY_DATA, registryDataRewriter::handle);
}
@Override
protected void registerRewrites() {
final EntityDataTypes1_21_2 mappedEntityDataTypes = VersionedTypes.V1_21_4.entityDataTypes;
/*filter().handler((event, data) -> {
int id = data.dataType().typeId();
if (id >= ac) {
return;
} else if (id >= ab) {
id--;
}
data.setDataType(mappedEntityDataTypess.byId(id));
});*/
registerEntityDataTypeHandler1_20_3(
mappedEntityDataTypes.itemType,
mappedEntityDataTypes.blockStateType,
mappedEntityDataTypes.optionalBlockStateType,
mappedEntityDataTypes.particleType,
mappedEntityDataTypes.particlesType,
mappedEntityDataTypes.componentType,
mappedEntityDataTypes.optionalComponentType
);
// Remove entity data of new entity type
// filter().type(EntityTypes1_21_4.SNIFFER).removeIndex(newIndex);
}
@Override
public void onMappingDataLoaded() {
// If types changed, uncomment to map them
// mapTypes();
// mapEntityTypeWithData(EntityTypes1_21_4.SNIFFER, EntityTypes1_21_4.RAVAGER).tagName();
}
@Override
public EntityType typeFromId(final int type) {
return EntityTypes1_21_4.getTypeFromId(type);
}
}
@@ -0,0 +1,78 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.template;
import com.viaversion.viabackwards.api.rewriters.EntityRewriter;
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_11;
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_21_11;
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
// Replace if needed
// VersionedTypes
final class EntityPacketRewriter99_1 extends EntityRewriter<ClientboundPacket26_1, Protocol99_1To98_1> {
private static final EntityDataTypes1_21_11 MAPPED_DATA_TYPES = VersionedTypes.V1_21_11.entityDataTypes;
public EntityPacketRewriter99_1(final Protocol99_1To98_1 protocol) {
super(protocol, MAPPED_DATA_TYPES.optionalComponentType, MAPPED_DATA_TYPES.booleanType);
}
@Override
public void registerPackets() {
}
@Override
protected void registerRewrites() {
/*filter().handler((event, data) -> {
int id = data.dataType().typeId();
if (id >= ac) {
return;
} else if (id >= ab) {
id--;
}
data.setDataType(MAPPED_DATA_TYPES.byId(id));
});*/
registerEntityDataTypeHandler1_20_3(
MAPPED_DATA_TYPES.itemType,
MAPPED_DATA_TYPES.blockStateType,
MAPPED_DATA_TYPES.optionalBlockStateType,
MAPPED_DATA_TYPES.particleType,
MAPPED_DATA_TYPES.particlesType,
MAPPED_DATA_TYPES.componentType,
MAPPED_DATA_TYPES.optionalComponentType
);
// Remove entity data of new entity type
// filter().type(EntityTypes1_21_11.SNIFFER).removeIndex(newIndex);
}
@Override
public void onMappingDataLoaded() {
super.onMappingDataLoaded();
// mapEntityTypeWithData(EntityTypes1_21_11.SNIFFER, EntityTypes1_21_11.RAVAGER).tagName();
}
@Override
public EntityType typeFromId(final int type) {
return EntityTypes1_21_11.getTypeFromId(type);
}
}
@@ -1,160 +0,0 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.template;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.text.NBTComponentRewriter;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_4;
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.data.item.ItemHasherBase;
import com.viaversion.viaversion.protocols.v1_20_3to1_20_5.packet.ServerboundConfigurationPackets1_20_5;
import com.viaversion.viaversion.protocols.v1_20_5to1_21.Protocol1_20_5To1_21;
import com.viaversion.viaversion.protocols.v1_20_5to1_21.packet.ClientboundConfigurationPackets1_21;
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPacket1_21_4;
import com.viaversion.viaversion.protocols.v1_21_2to1_21_4.packet.ServerboundPackets1_21_4;
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPacket1_21_2;
import com.viaversion.viaversion.protocols.v1_21to1_21_2.packet.ClientboundPackets1_21_2;
import com.viaversion.viaversion.rewriter.ParticleRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.util.SerializerVersion;
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
// Placeholders to replace (in the entire package):
// Protocol1_98To1_99, EntityPacketRewriter1_99, BlockItemPacketRewriter1_99
// Protocol1_20_5To1_21 (the ViaVersion protocol class the mappings depend on)
// ClientboundPacket1_21_2
// ServerboundPacket1_21_4
// ClientboundConfigurationPackets1_21
// ServerboundConfigurationPackets1_20_5
// EntityTypes1_21_4 (UNMAPPED type)
// VersionedTypes.V1_21_5
// 1.99, 1.98
final class Protocol1_99To1_98 extends BackwardsProtocol<ClientboundPacket1_21_2, ClientboundPacket1_21_2, ServerboundPacket1_21_4, ServerboundPacket1_21_4> {
// ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("1.99", "1.98", Protocol1_20_5To1_21.class); // Change the VV (!) protocol class
private final EntityPacketRewriter1_99 entityRewriter = new EntityPacketRewriter1_99(this);
private final BlockItemPacketRewriter1_99 itemRewriter = new BlockItemPacketRewriter1_99(this);
private final ParticleRewriter<ClientboundPacket1_21_2> particleRewriter = new ParticleRewriter<>(this);
private final NBTComponentRewriter<ClientboundPacket1_21_2> translatableRewriter = new ComponentRewriter1_99(this);
private final TagRewriter<ClientboundPacket1_21_2> tagRewriter = new TagRewriter<>(this);
public Protocol1_99To1_98() {
super(ClientboundPacket1_21_2.class, ClientboundPacket1_21_2.class, ServerboundPacket1_21_4.class, ServerboundPacket1_21_4.class);
}
@Override
protected void registerPackets() {
super.registerPackets();
tagRewriter.registerGeneric(ClientboundPackets1_21_2.UPDATE_TAGS);
tagRewriter.registerGeneric(ClientboundConfigurationPackets1_21.UPDATE_TAGS);
final SoundRewriter<ClientboundPacket1_21_2> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerSound1_19_3(ClientboundPackets1_21_2.SOUND);
soundRewriter.registerSound1_19_3(ClientboundPackets1_21_2.SOUND_ENTITY);
soundRewriter.registerStopSound(ClientboundPackets1_21_2.STOP_SOUND);
new StatisticsRewriter<>(this).register(ClientboundPackets1_21_2.AWARD_STATS);
//new AttributeRewriter<>(this).register1_21(ClientboundPackets1_21_2.UPDATE_ATTRIBUTES);
// Registers translatable mappings (missing a whole bunch still)
//translatableRewriter.registerOpenScreen1_14(ClientboundPackets1_21_2.OPEN_SCREEN); // Handled by registerOpenScreen in item rewriters
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_ACTION_BAR_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_TITLE_TEXT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SET_SUBTITLE_TEXT);
translatableRewriter.registerBossEvent(ClientboundPackets1_21_2.BOSS_EVENT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_21_2.TAB_LIST);
translatableRewriter.registerPlayerCombatKill1_20(ClientboundPackets1_21_2.PLAYER_COMBAT_KILL);
translatableRewriter.registerPlayerInfoUpdate1_21_4(ClientboundPackets1_21_2.PLAYER_INFO_UPDATE);
translatableRewriter.registerComponentPacket(ClientboundPackets1_21_2.SYSTEM_CHAT);
translatableRewriter.registerDisguisedChat(ClientboundPackets1_21_2.DISGUISED_CHAT);
translatableRewriter.registerPlayerChat1_21_5(ClientboundPackets1_21_2.PLAYER_CHAT);
translatableRewriter.registerPing();
// If needed for any particle, item, or block changes. Extend ParticleRewriter for particle serializer changes
particleRewriter.registerLevelParticles1_21_4(ClientboundPackets1_21_2.LEVEL_PARTICLES);
particleRewriter.registerExplode1_21_9(ClientboundPackets1_21_2.EXPLODE);
}
@Override
public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_4.PLAYER));
addItemHasher(connection, new ItemHasherBase(this, connection));
}
@Override
public BackwardsMappingData getMappingData() {
return MAPPINGS;
}
@Override
public EntityPacketRewriter1_99 getEntityRewriter() {
return entityRewriter;
}
@Override
public BlockItemPacketRewriter1_99 getItemRewriter() {
return itemRewriter;
}
@Override
public ParticleRewriter<ClientboundPacket1_21_2> getParticleRewriter() {
return particleRewriter;
}
@Override
public NBTComponentRewriter<ClientboundPacket1_21_2> getComponentRewriter() {
return translatableRewriter;
}
@Override
public TagRewriter<ClientboundPacket1_21_2> getTagRewriter() {
return tagRewriter;
}
@Override
public VersionedTypesHolder types() {
return VersionedTypes.V1_21_5;
}
@Override
public VersionedTypesHolder mappedTypes() {
return VersionedTypes.V1_21_5;
}
@Override
protected PacketTypesProvider<ClientboundPacket1_21_2, ClientboundPacket1_21_2, ServerboundPacket1_21_4, ServerboundPacket1_21_4> createPacketTypesProvider() {
return new SimplePacketTypesProvider<>(
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class),
packetTypeMap(mappedClientboundPacketType, ClientboundPackets1_21_2.class, ClientboundConfigurationPackets1_21.class),
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_21_4.class, ServerboundConfigurationPackets1_20_5.class),
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_21_4.class, ServerboundConfigurationPackets1_20_5.class)
);
}
}
@@ -0,0 +1,150 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viabackwards.protocol.template;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.BackwardsRegistryRewriter;
import com.viaversion.viabackwards.api.rewriters.text.NBTComponentRewriter;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_21_11;
import com.viaversion.viaversion.api.protocol.packet.provider.PacketTypesProvider;
import com.viaversion.viaversion.api.protocol.packet.provider.SimplePacketTypesProvider;
import com.viaversion.viaversion.api.type.types.chunk.ChunkType26_1;
import com.viaversion.viaversion.api.type.types.version.VersionedTypes;
import com.viaversion.viaversion.api.type.types.version.VersionedTypesHolder;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.data.item.ItemHasherBase;
import com.viaversion.viaversion.protocols.v1_21_11to26_1.Protocol1_21_11To26_1;
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPacket26_1;
import com.viaversion.viaversion.protocols.v1_21_11to26_1.packet.ClientboundPackets26_1;
import com.viaversion.viaversion.protocols.v1_21_4to1_21_5.rewriter.RecipeDisplayRewriter1_21_5;
import com.viaversion.viaversion.protocols.v1_21_5to1_21_6.packet.ServerboundPackets1_21_6;
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ClientboundConfigurationPackets1_21_9;
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ServerboundConfigurationPackets1_21_9;
import com.viaversion.viaversion.protocols.v1_21_7to1_21_9.packet.ServerboundPacket1_21_9;
import com.viaversion.viaversion.rewriter.BlockRewriter;
import com.viaversion.viaversion.rewriter.ParticleRewriter;
import com.viaversion.viaversion.rewriter.RecipeDisplayRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.rewriter.block.BlockRewriter1_21_5;
import static com.viaversion.viaversion.util.ProtocolUtil.packetTypeMap;
// Placeholders to replace (in the entire package):
// Protocol1_21_11To26_1 (the ViaVersion protocol class the mappings depend on)
// ClientboundPacket26_1
// ServerboundPacket1_21_9
// ClientboundConfigurationPackets1_21
// ServerboundConfigurationPackets1_20_5
// EntityTypes1_21_11 (UNMAPPED type)
// VersionedTypes.V26_1
// 99.1, 98.1
final class Protocol99_1To98_1 extends BackwardsProtocol<ClientboundPacket26_1, ClientboundPacket26_1, ServerboundPacket1_21_9, ServerboundPacket1_21_9> {
// ViaBackwards uses its own mappings and also needs a translatablerewriter for translation mappings
public static final BackwardsMappingData MAPPINGS = new BackwardsMappingData("99.1", "98.1", Protocol1_21_11To26_1.class); // Change the VV (!) protocol class
private final EntityPacketRewriter99_1 entityRewriter = new EntityPacketRewriter99_1(this);
private final BlockItemPacketRewriter99_1 itemRewriter = new BlockItemPacketRewriter99_1(this);
private final ParticleRewriter<ClientboundPacket26_1> particleRewriter = new ParticleRewriter<>(this);
private final NBTComponentRewriter<ClientboundPacket26_1> translatableRewriter = new ComponentRewriter99_1(this);
private final TagRewriter<ClientboundPacket26_1> tagRewriter = new TagRewriter<>(this);
private final BackwardsRegistryRewriter registryDataRewriter = new BackwardsRegistryRewriter(this);
private final BlockRewriter<ClientboundPacket26_1> blockRewriter = new BlockRewriter1_21_5<>(this, ChunkType26_1::new);
private final RecipeDisplayRewriter<ClientboundPacket26_1> recipeRewriter = new RecipeDisplayRewriter1_21_5<>(this);
public Protocol99_1To98_1() {
super(ClientboundPacket26_1.class, ClientboundPacket26_1.class, ServerboundPacket1_21_9.class, ServerboundPacket1_21_9.class);
}
@Override
protected void registerPackets() {
super.registerPackets();
}
@Override
public void init(final UserConnection connection) {
addEntityTracker(connection, new EntityTrackerBase(connection, EntityTypes1_21_11.PLAYER));
addItemHasher(connection, new ItemHasherBase(this, connection));
}
@Override
public BackwardsMappingData getMappingData() {
return MAPPINGS;
}
@Override
public EntityPacketRewriter99_1 getEntityRewriter() {
return entityRewriter;
}
@Override
public BlockItemPacketRewriter99_1 getItemRewriter() {
return itemRewriter;
}
@Override
public BlockRewriter<ClientboundPacket26_1> getBlockRewriter() {
return blockRewriter;
}
@Override
public RecipeDisplayRewriter<ClientboundPacket26_1> getRecipeRewriter() {
return recipeRewriter;
}
@Override
public BackwardsRegistryRewriter getRegistryDataRewriter() {
return registryDataRewriter;
}
@Override
public ParticleRewriter<ClientboundPacket26_1> getParticleRewriter() {
return particleRewriter;
}
@Override
public NBTComponentRewriter<ClientboundPacket26_1> getComponentRewriter() {
return translatableRewriter;
}
@Override
public TagRewriter<ClientboundPacket26_1> getTagRewriter() {
return tagRewriter;
}
@Override
public VersionedTypesHolder types() {
return VersionedTypes.V26_1;
}
@Override
public VersionedTypesHolder mappedTypes() {
return VersionedTypes.V26_1;
}
@Override
protected PacketTypesProvider<ClientboundPacket26_1, ClientboundPacket26_1, ServerboundPacket1_21_9, ServerboundPacket1_21_9> createPacketTypesProvider() {
return new SimplePacketTypesProvider<>(
packetTypeMap(unmappedClientboundPacketType, ClientboundPackets26_1.class, ClientboundConfigurationPackets1_21_9.class),
packetTypeMap(mappedClientboundPacketType, ClientboundPackets26_1.class, ClientboundConfigurationPackets1_21_9.class),
packetTypeMap(mappedServerboundPacketType, ServerboundPackets1_21_6.class, ServerboundConfigurationPackets1_21_9.class),
packetTypeMap(unmappedServerboundPacketType, ServerboundPackets1_21_6.class, ServerboundConfigurationPackets1_21_9.class)
);
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -57,7 +57,7 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
itemRewriter.register();
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
registerClientbound(ClientboundPackets1_9_3.CUSTOM_SOUND, new PacketHandlers() {
replaceClientbound(ClientboundPackets1_9_3.CUSTOM_SOUND, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // 0 - Sound name
@@ -70,7 +70,7 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
handler(soundRewriter.getNamedSoundHandler());
}
});
registerClientbound(ClientboundPackets1_9_3.SOUND, new PacketHandlers() {
replaceClientbound(ClientboundPackets1_9_3.SOUND, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Sound name
@@ -116,9 +116,4 @@ public class Protocol1_10To1_9_3 extends BackwardsProtocol<ClientboundPackets1_9
public BlockItemPacketRewriter1_10 getItemRewriter() {
return itemRewriter;
}
@Override
public boolean hasMappingDataToLoad() {
return true;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@ package com.viaversion.viabackwards.protocol.v1_11to1_10;
import com.viaversion.viabackwards.api.BackwardsProtocol;
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
import com.viaversion.viabackwards.api.rewriters.SoundRewriter;
import com.viaversion.viabackwards.api.rewriters.text.JsonNBTComponentRewriter;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.BlockItemPacketRewriter1_11;
import com.viaversion.viabackwards.protocol.v1_11to1_10.rewriter.EntityPacketRewriter1_11;
@@ -51,10 +50,6 @@ public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_
itemRewriter.register();
PlayerPacketRewriter1_11.register(this);
SoundRewriter<ClientboundPackets1_9_3> soundRewriter = new SoundRewriter<>(this);
soundRewriter.registerNamedSound(ClientboundPackets1_9_3.CUSTOM_SOUND);
soundRewriter.registerSound(ClientboundPackets1_9_3.SOUND);
componentRewriter = new JsonNBTComponentRewriter<>(this, ComponentRewriterBase.ReadType.JSON);
componentRewriter.registerComponentPacket(ClientboundPackets1_9_3.CHAT);
}
@@ -84,12 +79,8 @@ public class Protocol1_11To1_10 extends BackwardsProtocol<ClientboundPackets1_9_
return itemRewriter;
}
@Override
public JsonNBTComponentRewriter<ClientboundPackets1_9_3> getComponentRewriter() {
return componentRewriter;
}
@Override
public boolean hasMappingDataToLoad() {
return true;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -50,8 +50,8 @@ public class Protocol1_12To1_11_1 extends BackwardsProtocol<ClientboundPackets1_
@Override
protected void registerPackets() {
itemRewriter.register();
entityRewriter.register();
super.registerPackets();
componentRewriter.registerComponentPacket(ClientboundPackets1_12.CHAT);
new SoundPacketRewriter1_12(this).register();
@@ -92,12 +92,8 @@ public class Protocol1_12To1_11_1 extends BackwardsProtocol<ClientboundPackets1_
return itemRewriter;
}
@Override
public ComponentRewriter1_12 getComponentRewriter() {
return componentRewriter;
}
@Override
public boolean hasMappingDataToLoad() {
return true;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -114,7 +114,7 @@ public class BlockItemPacketRewriter1_12 extends LegacyBlockItemRewriter<Clientb
PacketWrapper confirm = wrapper.create(ServerboundPackets1_12.CONTAINER_ACK);
confirm.write(Types.BYTE, wrapper.get(Types.BYTE, 0));
confirm.write(Types.SHORT, wrapper.get(Types.SHORT, 1));
confirm.write(Types.BOOLEAN, false); // Success - not used
confirm.write(Types.BOOLEAN, true); // Success - not used
wrapper.sendToServer(Protocol1_12To1_11_1.class);
wrapper.cancel();
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -32,20 +32,7 @@ public class SoundPacketRewriter1_12 extends LegacySoundRewriter<Protocol1_12To1
@Override
protected void registerPackets() {
protocol.registerClientbound(ClientboundPackets1_12.CUSTOM_SOUND, new PacketHandlers() {
@Override
public void register() {
map(Types.STRING); // 0 - Sound name
map(Types.VAR_INT); // 1 - Sound Category
map(Types.INT); // 2 - x
map(Types.INT); // 3 - y
map(Types.INT); // 4 - z
map(Types.FLOAT); // 5 - Volume
map(Types.FLOAT); // 6 - Pitch
}
});
protocol.registerClientbound(ClientboundPackets1_12.SOUND, new PacketHandlers() {
protocol.replaceClientbound(ClientboundPackets1_12.SOUND, new PacketHandlers() {
@Override
public void register() {
map(Types.VAR_INT); // 0 - Sound name
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -41,7 +41,6 @@ import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPacke
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_13to1_13_1.Protocol1_13To1_13_1;
import com.viaversion.viaversion.rewriter.ParticleRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import com.viaversion.viaversion.rewriter.TagRewriter;
import com.viaversion.viaversion.rewriter.text.ComponentRewriterBase;
import com.viaversion.viaversion.util.ComponentUtil;
@@ -65,17 +64,8 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
WorldPacketRewriter1_13_1.register(this);
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT);
translatableRewriter.registerPlayerCombat(ClientboundPackets1_13.PLAYER_COMBAT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.DISCONNECT);
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
translatableRewriter.registerTitle(ClientboundPackets1_13.SET_TITLES);
translatableRewriter.registerPing();
new CommandRewriter1_13_1(this).registerDeclareCommands(ClientboundPackets1_13.COMMANDS);
particleRewriter.registerLevelParticles1_13(ClientboundPackets1_13.LEVEL_PARTICLES, Types.FLOAT);
registerServerbound(ServerboundPackets1_13.COMMAND_SUGGESTION, new PacketHandlers() {
@Override
public void register() {
@@ -142,7 +132,7 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
}
});
registerClientbound(ClientboundPackets1_13.BOSS_EVENT, new PacketHandlers() {
replaceClientbound(ClientboundPackets1_13.BOSS_EVENT, new PacketHandlers() {
@Override
public void register() {
map(Types.UUID);
@@ -164,41 +154,7 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
}
});
registerClientbound(ClientboundPackets1_13.UPDATE_ADVANCEMENTS, wrapper -> {
wrapper.passthrough(Types.BOOLEAN); // Reset/clear
int size = wrapper.passthrough(Types.VAR_INT); // Mapping size
for (int i = 0; i < size; i++) {
wrapper.passthrough(Types.STRING); // Identifier
wrapper.passthrough(Types.OPTIONAL_STRING); // Parent
// Display data
if (wrapper.passthrough(Types.BOOLEAN)) {
wrapper.passthrough(Types.COMPONENT); // Title
wrapper.passthrough(Types.COMPONENT); // Description
Item icon = itemRewriter.handleItemToClient(wrapper.user(), wrapper.read(Types.ITEM1_13));
wrapper.write(Types.ITEM1_13, icon);
wrapper.passthrough(Types.VAR_INT); // Frame type
int flags = wrapper.passthrough(Types.INT); // Flags
if ((flags & 1) != 0)
wrapper.passthrough(Types.STRING); // Background texture
wrapper.passthrough(Types.FLOAT); // X
wrapper.passthrough(Types.FLOAT); // Y
}
wrapper.passthrough(Types.STRING_ARRAY); // Criteria
int arrayLength = wrapper.passthrough(Types.VAR_INT);
for (int array = 0; array < arrayLength; array++) {
wrapper.passthrough(Types.STRING_ARRAY); // String array
}
}
});
tagRewriter.register(ClientboundPackets1_13.UPDATE_TAGS, RegistryType.ITEM);
new StatisticsRewriter<>(this).
register(ClientboundPackets1_13.AWARD_STATS);
}
@Override
@@ -227,6 +183,11 @@ public class Protocol1_13_1To1_13 extends BackwardsProtocol<ClientboundPackets1_
return particleRewriter;
}
@Override
public JsonNBTComponentRewriter<ClientboundPackets1_13> getComponentRewriter() {
return translatableRewriter;
}
public JsonNBTComponentRewriter<ClientboundPackets1_13> translatableRewriter() {
return translatableRewriter;
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -122,7 +122,6 @@ public class EntityPacketRewriter1_13_1 extends LegacyEntityRewriter<Clientbound
registerTracker(ClientboundPackets1_13.ADD_PAINTING, EntityTypes1_13.EntityType.PAINTING);
registerJoinGame(ClientboundPackets1_13.LOGIN, EntityTypes1_13.EntityType.PLAYER);
registerRespawn(ClientboundPackets1_13.RESPAWN);
registerRemoveEntities(ClientboundPackets1_13.REMOVE_ENTITIES);
registerSetEntityData(ClientboundPackets1_13.SET_ENTITY_DATA, Types1_13.ENTITY_DATA_LIST);
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -18,7 +18,6 @@
package com.viaversion.viabackwards.protocol.v1_13_1to1_13.rewriter;
import com.viaversion.viabackwards.protocol.v1_13_1to1_13.Protocol1_13_1To1_13;
import com.viaversion.viaversion.api.minecraft.item.Item;
import com.viaversion.viaversion.api.type.Types;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.v1_12_2to1_13.packet.ServerboundPackets1_13;
@@ -32,10 +31,6 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter<ClientboundPackets1_1
@Override
public void registerPackets() {
registerCooldown(ClientboundPackets1_13.COOLDOWN);
registerSetContent(ClientboundPackets1_13.CONTAINER_SET_CONTENT);
registerSetSlot(ClientboundPackets1_13.CONTAINER_SET_SLOT);
protocol.registerClientbound(ClientboundPackets1_13.CUSTOM_PAYLOAD, wrapper -> {
String channel = wrapper.passthrough(Types.STRING);
if (channel.equals("minecraft:trader_list")) {
@@ -57,9 +52,5 @@ public class ItemPacketRewriter1_13_1 extends ItemRewriter<ClientboundPackets1_1
}
}
});
registerSetEquippedItem(ClientboundPackets1_13.SET_EQUIPPED_ITEM);
registerContainerClick(ServerboundPackets1_13.CONTAINER_CLICK);
registerSetCreativeModeSlot(ServerboundPackets1_13.SET_CREATIVE_MODE_SLOT);
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -37,6 +37,7 @@ import com.viaversion.viaversion.api.Via;
import com.viaversion.viaversion.api.connection.UserConnection;
import com.viaversion.viaversion.api.minecraft.ClientWorld;
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_13;
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
import com.viaversion.viaversion.libs.gson.JsonElement;
import com.viaversion.viaversion.libs.gson.JsonObject;
@@ -82,13 +83,12 @@ public class Protocol1_13To1_12_2 extends BackwardsProtocol<ClientboundPackets1_
@Override
protected void registerPackets() {
executeAsyncAfterLoaded(Protocol1_12_2To1_13.class, () -> {
MAPPINGS.load();
PaintingNames1_13.init();
Via.getManager().getProviders().register(BackwardsBlockEntityProvider.class, new BackwardsBlockEntityProvider());
});
super.registerPackets();
translatableRewriter.registerPing();
PaintingNames1_13.init();
Via.getManager().getProviders().register(BackwardsBlockEntityProvider.class, new BackwardsBlockEntityProvider());
translatableRewriter.registerLoginDisconnect();
translatableRewriter.registerBossEvent(ClientboundPackets1_13.BOSS_EVENT);
translatableRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT);
translatableRewriter.registerLegacyOpenWindow(ClientboundPackets1_13.OPEN_SCREEN);
@@ -97,17 +97,15 @@ public class Protocol1_13To1_12_2 extends BackwardsProtocol<ClientboundPackets1_
translatableRewriter.registerTitle(ClientboundPackets1_13.SET_TITLES);
translatableRewriter.registerTabList(ClientboundPackets1_13.TAB_LIST);
blockItemPackets.register();
entityRewriter.register();
new PlayerPacketRewriter1_13(this).register();
new SoundPacketRewriter1_13(this).register();
cancelClientbound(ClientboundPackets1_13.TAG_QUERY);
cancelClientbound(ClientboundPackets1_13.PLACE_GHOST_RECIPE);
cancelClientbound(ClientboundPackets1_13.RECIPE);
cancelClientbound(ClientboundPackets1_13.UPDATE_ADVANCEMENTS);
cancelClientbound(ClientboundPackets1_13.UPDATE_RECIPES);
cancelClientbound(ClientboundPackets1_13.UPDATE_TAGS);
replaceClientbound(ClientboundPackets1_13.UPDATE_ADVANCEMENTS, PacketWrapper::cancel);
cancelServerbound(ServerboundPackets1_12_1.PLACE_RECIPE);
cancelServerbound(ServerboundPackets1_12_1.RECIPE_BOOK_UPDATE);
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -1,6 +1,6 @@
/*
* This file is part of ViaBackwards - https://github.com/ViaVersion/ViaBackwards
* Copyright (C) 2016-2025 ViaVersion and contributors
* Copyright (C) 2016-2026 ViaVersion and contributors
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Loaded 100 of 335 files, more files were not shown because too many files have changed in this diff. Show more