diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 000000000..2513020ad --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,28 @@ +name: ViaRewind CI +on: [pull_request, push, workflow_dispatch] + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 8 + check-latest: true + - name: Cache Dependencies + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - name: Build with Gradle + run: ./gradlew build diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml deleted file mode 100644 index 772882bcf..000000000 --- a/.github/workflows/maven.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Java CI with Maven - -on: [push, pull_request] - -jobs: - build: - - runs-on: ubuntu-22.04 - - steps: - - name: Checkout Repository - uses: actions/checkout@v3 - - name: Set up JDK 11 - uses: actions/setup-java@v3 - with: - distribution: 'temurin' - java-version: 11 - - name: Build with Maven - run: mvn install - - name: Upload Artifacts - uses: actions/upload-artifact@v3 - with: - name: artifact - path: all/target - diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 000000000..87012121c --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,27 @@ +name: Publish to Hangar and Modrinth +on: + push: + branches: + - master + - dev + +jobs: + publish: + if: github.repository_owner == 'ViaVersion' + runs-on: ubuntu-22.04 + steps: + - name: Checkout Repository + uses: actions/checkout@v3 + - name: Validate Gradle Wrapper + uses: gradle/wrapper-validation-action@v1 + - name: Set up JDK 8 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: 8 + check-latest: true + - name: Publish + env: + HANGAR_TOKEN: ${{ secrets.HANGAR_TOKEN }} + MODRINTH_TOKEN: ${{ secrets.MODRINTH_TOKEN }} + run: ./gradlew build modrinth publishAllPublicationsToHangar diff --git a/.idea/copyright/profile_settings.xml b/.idea/copyright/profile_settings.xml new file mode 100644 index 000000000..a81181027 --- /dev/null +++ b/.idea/copyright/profile_settings.xml @@ -0,0 +1,10 @@ + + + + + + + + + \ No newline at end of file diff --git a/.idea/copyright/viarewind_gpl.xml b/.idea/copyright/viarewind_gpl.xml new file mode 100644 index 000000000..9cb82b9a4 --- /dev/null +++ b/.idea/copyright/viarewind_gpl.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/README.md b/README.md index 563abdcae..8db6845f3 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,30 @@ # ViaRewind -Allow 1.8.x and 1.7.x on your newer server +[![Build Status](https://github.com/ViaVersion/ViaRewind/actions/workflows/build.yml/badge.svg?branch=master)](https://github.com/ViaVersion/ViaRewind/actions) +[![Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord) -Releases / Dev Builds +**ViaVersion addon to allow 1.8.x and 1.7.x clients on newer server versions.**
+Runs on 1.9-latest servers or 1.8 clients and lower. + +**On Fabric, use either [ViaFabric](https://modrinth.com/mod/viafabric) or [ViaFabricPlus](https://modrinth.com/mod/viafabricplus). To override the included version** +- in **ViaFabric**, put ViaRewind into the `mods` folder +- in **ViaFabricPlus**, put ViaRewind into the `ViaFabricPlus/jars` folder + +**Depending on the platform and version, this also requires [ViaVersion](https://modrinth.com/mod/viaversion) and [ViaBackwards](https://modrinth.com/mod/viabackwards).** + +Support Status - -**Requires [ViaVersion](https://viaversion.com/) ([ViaFabric](https://viaversion.com/fabric) on Fabric) to be installed** - -You can find the latest dev builds here:\ -**Jenkins:** https://ci.viaversion.com/view/ViaRewind/ +While ViaRewind will keep getting updates to function with changes to ViaVersion or ViaBackwards, it will likely not receive many bug fixes or additional features anymore. -**Spigot page:** https://www.spigotmc.org/resources/viarewind.52109/ +Releases / Dev Builds +- +Dev builds for **all** of our projects are on our Jenkins server: -**CurseForge mod page:** https://www.curseforge.com/minecraft/mc-mods/viarewind +- **Jenkins**: https://ci.viaversion.com/view/ViaRewind/ Other Links - **Maven:** https://repo.viaversion.com/ + +**Issue tracker:** https://github.com/ViaVersion/ViaRewind/issues + +**List of contributors:** https://github.com/ViaVersion/ViaRewind/graphs/contributors \ No newline at end of file diff --git a/all/pom.xml b/all/pom.xml deleted file mode 100644 index 1724bd7ad..000000000 --- a/all/pom.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - 4.0.0 - - - com.viaversion - viarewind-parent - 2.0.4-SNAPSHOT - - - viarewind-all - ViaRewind - - - ${project.name}-${project.version} - clean install - - - - - net.md-5 - scriptus - 0.3.2 - - git-ViaRewind-${project.parent.version}:%s - - - - initialize - - describe - - - - - - org.apache.maven.plugins - maven-jar-plugin - 3.3.0 - - - - - ${describe} - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.10.1 - - 1.8 - 1.8 - false - false - - - - org.apache.maven.plugins - maven-shade-plugin - 3.4.1 - - false - false - - - com.github.steveice10.opennbt - com.viaversion.viaversion.libs.opennbt - - - com.google.gson - com.viaversion.viaversion.libs.gson - - - - - - package - - shade - - - - - - - - - - com.viaversion - viarewind-core - ${project.parent.version} - - - - com.viaversion - viarewind-bukkit - ${project.parent.version} - - - - com.viaversion - viarewind-bungee - ${project.parent.version} - - - - com.viaversion - viarewind-fabric - ${project.parent.version} - - - - com.viaversion - viarewind-sponge - ${project.parent.version} - - - - com.viaversion - viarewind-velocity - ${project.parent.version} - - - - diff --git a/buildSrc/build.gradle b/buildSrc/build.gradle new file mode 100644 index 000000000..abe72b3d8 --- /dev/null +++ b/buildSrc/build.gradle @@ -0,0 +1,7 @@ +plugins { + id "groovy-gradle-plugin" +} + +repositories { + gradlePluginPortal() +} \ No newline at end of file diff --git a/buildSrc/src/main/groovy/com.viaversion.java-conventions.gradle b/buildSrc/src/main/groovy/com.viaversion.java-conventions.gradle new file mode 100644 index 000000000..ea07f856f --- /dev/null +++ b/buildSrc/src/main/groovy/com.viaversion.java-conventions.gradle @@ -0,0 +1,91 @@ +plugins { + id "java-library" + id "maven-publish" +} + +repositories { + mavenLocal() + maven { + url = uri("https://repo.viaversion.com") + } + + maven { + url = uri("https://repo.maven.apache.org/maven2/") + } + + maven { + url = uri("https://hub.spigotmc.org/nexus/content/repositories/snapshots/") + } + + maven { + url = uri("https://oss.sonatype.org/content/repositories/snapshots") + } + + maven { + url = uri("https://maven.fabricmc.net/") + } + + maven { + url = uri("https://repo.spongepowered.org/repository/maven-public/") + } + + maven { + url = uri("https://nexus.velocitypowered.com/repository/maven-public/") + } +} + +dependencies { + compileOnly "com.viaversion:viaversion:${project.viaversion_version}" + compileOnly "io.netty:netty-all:${project.netty_version}" + compileOnly "com.google.guava:guava:${project.guava_version}" +} + +archivesBaseName = project.maven_name +group = project.maven_group +version = project.maven_version + +java.sourceCompatibility = JavaVersion.VERSION_1_8 + +tasks { + // Variable replacements + processResources { + inputs.property "version", project.version + + for (final def file in ["plugin.yml", "bungee.yml", "META-INF/sponge_plugins.json", "fabric.mod.json"]) { + filesMatching(file) { + expand "version": version + } + } + } +} + +publishing { + repositories { + maven { + name = "Via" + url = "https://repo.viaversion.com/" + + credentials(PasswordCredentials) + authentication { + basic(BasicAuthentication) + } + } + } + publications { + main(MavenPublication) { + artifactId = project.maven_name + groupId = project.maven_group + version = project.maven_version + + from(components.java) + } + } +} + +tasks.withType(JavaCompile) { + options.encoding = 'UTF-8' +} + +tasks.withType(Javadoc) { + options.encoding = 'UTF-8' +} diff --git a/bukkit/build.gradle b/bukkit/build.gradle new file mode 100644 index 000000000..a9d026d70 --- /dev/null +++ b/bukkit/build.gradle @@ -0,0 +1,9 @@ +plugins { + id "com.viaversion.java-conventions" +} + +dependencies { + api project(":viarewind-common") + + compileOnly(annotationProcessor("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT")) +} diff --git a/bukkit/gradle.properties b/bukkit/gradle.properties new file mode 100644 index 000000000..a86c35ffd --- /dev/null +++ b/bukkit/gradle.properties @@ -0,0 +1 @@ +maven_name=viarewind-bukkit diff --git a/bukkit/pom.xml b/bukkit/pom.xml deleted file mode 100644 index 5dcf758ff..000000000 --- a/bukkit/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - 4.0.0 - - - com.viaversion - viarewind-parent - 2.0.4-SNAPSHOT - - - viarewind-bukkit - - - - spigot-repo - https://hub.spigotmc.org/nexus/content/repositories/snapshots/ - - - - - - - org.spigotmc - spigot-api - 1.12.2-R0.1-SNAPSHOT - provided - - - - - com.viaversion - viarewind-core - ${project.parent.version} - - - - - - - . - true - src/main/resources/ - - * - - - - - - diff --git a/bukkit/src/main/java/com/viaversion/viarewind/BukkitPlugin.java b/bukkit/src/main/java/com/viaversion/viarewind/BukkitPlugin.java new file mode 100644 index 000000000..8b132b2c1 --- /dev/null +++ b/bukkit/src/main/java/com/viaversion/viarewind/BukkitPlugin.java @@ -0,0 +1,34 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind; + +import com.viaversion.viarewind.api.ViaRewindPlatform; +import org.bukkit.plugin.java.JavaPlugin; + +import java.io.File; + +public class BukkitPlugin extends JavaPlugin implements ViaRewindPlatform { + + @Override + public void onEnable() { + ViaRewindConfig conf = new ViaRewindConfig(new File(getDataFolder(), "config.yml")); + conf.reloadConfig(); + this.init(conf); + } +} diff --git a/bukkit/src/main/java/de/gerrygames/viarewind/BukkitPlugin.java b/bukkit/src/main/java/de/gerrygames/viarewind/BukkitPlugin.java deleted file mode 100644 index 1e8ef2ea2..000000000 --- a/bukkit/src/main/java/de/gerrygames/viarewind/BukkitPlugin.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.gerrygames.viarewind; - -import de.gerrygames.viarewind.api.ViaRewindConfigImpl; -import de.gerrygames.viarewind.api.ViaRewindPlatform; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.File; - -public class BukkitPlugin extends JavaPlugin implements ViaRewindPlatform { - @Override - public void onEnable() { - ViaRewindConfigImpl conf = new ViaRewindConfigImpl(new File(getDataFolder(), "config.yml")); - conf.reloadConfig(); - this.init(conf); - } -} diff --git a/bukkit/src/main/resources/plugin.yml b/bukkit/src/main/resources/plugin.yml index 27f86b57c..8a32d391d 100644 --- a/bukkit/src/main/resources/plugin.yml +++ b/bukkit/src/main/resources/plugin.yml @@ -1,10 +1,10 @@ name: ViaRewind -version: ${project.version} -main: de.gerrygames.viarewind.BukkitPlugin +version: ${version} +main: com.viaversion.viarewind.BukkitPlugin api-version: 1.13 folia-supported: true -authors: [Gerrygames] +authors: [Gerrygames, FlorianMichael/EnZaXD, creeper123321123] website: https://viaversion.com/rewind load: STARTUP diff --git a/bungee/build.gradle b/bungee/build.gradle new file mode 100644 index 000000000..1b71e06de --- /dev/null +++ b/bungee/build.gradle @@ -0,0 +1,9 @@ +plugins { + id "com.viaversion.java-conventions" +} + +dependencies { + api project(":viarewind-common") + + compileOnly(annotationProcessor("net.md-5:bungeecord-api:1.16-R0.5-SNAPSHOT")) +} diff --git a/bungee/gradle.properties b/bungee/gradle.properties new file mode 100644 index 000000000..d75fd14cb --- /dev/null +++ b/bungee/gradle.properties @@ -0,0 +1 @@ +maven_name=viarewind-bungee diff --git a/bungee/pom.xml b/bungee/pom.xml deleted file mode 100644 index 1b5775ade..000000000 --- a/bungee/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - 4.0.0 - - - com.viaversion - viarewind-parent - 2.0.4-SNAPSHOT - - - viarewind-bungee - - - - - bungeecord-repo - https://oss.sonatype.org/content/repositories/snapshots - - - - - - - net.md-5 - bungeecord-api - 1.16-R0.5-SNAPSHOT - provided - - - - - com.viaversion - viarewind-core - ${project.parent.version} - - - - - - - . - true - src/main/resources/ - - * - - - - - - diff --git a/bungee/src/main/java/com/viaversion/viarewind/BungeePlugin.java b/bungee/src/main/java/com/viaversion/viarewind/BungeePlugin.java new file mode 100644 index 000000000..48f7e89f6 --- /dev/null +++ b/bungee/src/main/java/com/viaversion/viarewind/BungeePlugin.java @@ -0,0 +1,34 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind; + +import com.viaversion.viarewind.api.ViaRewindPlatform; +import net.md_5.bungee.api.plugin.Plugin; + +import java.io.File; + +public class BungeePlugin extends Plugin implements ViaRewindPlatform { + + @Override + public void onEnable() { + ViaRewindConfig conf = new ViaRewindConfig(new File(getDataFolder(), "config.yml")); + conf.reloadConfig(); + this.init(conf); + } +} diff --git a/bungee/src/main/java/de/gerrygames/viarewind/BungeePlugin.java b/bungee/src/main/java/de/gerrygames/viarewind/BungeePlugin.java deleted file mode 100644 index ed21c86e5..000000000 --- a/bungee/src/main/java/de/gerrygames/viarewind/BungeePlugin.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.gerrygames.viarewind; - -import de.gerrygames.viarewind.api.ViaRewindConfigImpl; -import de.gerrygames.viarewind.api.ViaRewindPlatform; -import net.md_5.bungee.api.plugin.Plugin; - -import java.io.File; - -public class BungeePlugin extends Plugin implements ViaRewindPlatform { - @Override - public void onEnable() { - ViaRewindConfigImpl conf = new ViaRewindConfigImpl(new File(getDataFolder(), "config.yml")); - conf.reloadConfig(); - this.init(conf); - } -} diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml index c0db56034..96414e286 100644 --- a/bungee/src/main/resources/bungee.yml +++ b/bungee/src/main/resources/bungee.yml @@ -1,7 +1,7 @@ name: ViaRewind -main: de.gerrygames.viarewind.BungeePlugin -author: Gerrygames -version: ${project.version} +main: com.viaversion.viarewind.BungeePlugin +authors: [Gerrygames, FlorianMichael/EnZaXD, creeper123321123] +version: ${version} depends: [ViaVersion] softdepends: [ViaBackwards] website: https://viaversion.com/rewind diff --git a/common/build.gradle b/common/build.gradle new file mode 100644 index 000000000..9de966e46 --- /dev/null +++ b/common/build.gradle @@ -0,0 +1,28 @@ +plugins { + id "com.viaversion.java-conventions" +} + +plugins { + id "net.raphimc.class-token-replacer" version "1.0.0" +} + +dependencies { +} + +sourceSets { + main { + classTokenReplacer { + property("\${version}", rootProject.maven_version) + property("\${impl_version}", "git-${project.name}-${rootProject.maven_version}:${project.latestCommitHash()}") + } + } +} + +String latestCommitHash() { + def stdout = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--short', 'HEAD' + standardOutput = stdout + } + return stdout.toString().trim() +} diff --git a/common/gradle.properties b/common/gradle.properties new file mode 100644 index 000000000..5adf84606 --- /dev/null +++ b/common/gradle.properties @@ -0,0 +1 @@ +maven_name=viarewind-common diff --git a/common/src/main/java/com/viaversion/viarewind/ViaRewind.java b/common/src/main/java/com/viaversion/viarewind/ViaRewind.java new file mode 100644 index 000000000..9426725de --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/ViaRewind.java @@ -0,0 +1,41 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind; + +import com.viaversion.viarewind.api.ViaRewindConfig; +import com.viaversion.viarewind.api.ViaRewindPlatform; + +public class ViaRewind { + + private static ViaRewindPlatform platform; + private static ViaRewindConfig config; + + public static void init(ViaRewindPlatform platform, ViaRewindConfig config) { + ViaRewind.platform = platform; + ViaRewind.config = config; + } + + public static ViaRewindPlatform getPlatform() { + return ViaRewind.platform; + } + + public static ViaRewindConfig getConfig() { + return ViaRewind.config; + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/api/ViaRewindConfigImpl.java b/common/src/main/java/com/viaversion/viarewind/ViaRewindConfig.java similarity index 55% rename from core/src/main/java/de/gerrygames/viarewind/api/ViaRewindConfigImpl.java rename to common/src/main/java/com/viaversion/viarewind/ViaRewindConfig.java index 0086b9984..11af2f6ec 100644 --- a/core/src/main/java/de/gerrygames/viarewind/api/ViaRewindConfigImpl.java +++ b/common/src/main/java/com/viaversion/viarewind/ViaRewindConfig.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.api; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind; import com.viaversion.viaversion.util.Config; @@ -8,8 +26,8 @@ import java.util.List; import java.util.Map; -public class ViaRewindConfigImpl extends Config implements ViaRewindConfig { - public ViaRewindConfigImpl(File configFile) { +public class ViaRewindConfig extends Config implements com.viaversion.viarewind.api.ViaRewindConfig { + public ViaRewindConfig(File configFile) { super(configFile); reloadConfig(); } diff --git a/common/src/main/java/com/viaversion/viarewind/api/ViaRewindConfig.java b/common/src/main/java/com/viaversion/viarewind/api/ViaRewindConfig.java new file mode 100644 index 000000000..a99e28a25 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/api/ViaRewindConfig.java @@ -0,0 +1,70 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.api; + +/** + * This class is used to get the platform specific config + */ +public interface ViaRewindConfig { + + enum CooldownIndicator { + TITLE, ACTION_BAR, BOSS_BAR, DISABLED + } + + /** + * Specifies how 1.8.x clients should see the cooldown indicator + * You can choose between TITLE, ACTION_BAR, BOSS_BAR and DISABLED + * ONLY DISABLE IF YOU HAVE 1.9 COOLDOWN DISABLED ON YOUR SERVER + * 1.8 PLAYERS MAY ASK WHY PVP IS NOT WORKING OTHERWISE + * + * @return the cooldown indicator + */ + CooldownIndicator getCooldownIndicator(); + + /** + * Replaces Adventure mode with Survival mode for 1.7.x clients + * Enable this option if your server is using the 'CanDestroy' + * or 'CanPlaceOn' flags on items + * + * @return true if enabled + */ + boolean isReplaceAdventureMode(); + + /** + * Whether 1.9 particles should be replaced by similar ones in + * 1.8 and lower + * + * @return true if enabled + */ + boolean isReplaceParticles(); + + /** + * Max amount of pages for written books before a client gets kicked + * + * @return the max amount of pages + */ + int getMaxBookPages(); + + /** + * Max amount of characters in the json (!) string of a book page before a client gets kicked + * + * @return the max amount of characters + */ + int getMaxBookPageSize(); +} diff --git a/common/src/main/java/com/viaversion/viarewind/api/ViaRewindPlatform.java b/common/src/main/java/com/viaversion/viarewind/api/ViaRewindPlatform.java new file mode 100644 index 000000000..80f5fde35 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/api/ViaRewindPlatform.java @@ -0,0 +1,60 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.api; + +import com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10.Protocol1_7_2_5To1_7_6_10; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viaversion.api.Via; +import com.viaversion.viaversion.api.protocol.ProtocolManager; +import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; +import com.viaversion.viarewind.ViaRewind; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; + +import java.util.logging.Logger; + +/** + * The platform API for ViaRewind + */ +public interface ViaRewindPlatform { + + String VERSION = "${version}"; + String IMPL_VERSION = "${impl_version}"; + + /** + * Initialize ViaRewind + */ + default void init(ViaRewindConfig config) { + ViaRewind.init(this, config); + + Via.getManager().getSubPlatforms().add(IMPL_VERSION); + + final ProtocolManager protocolManager = Via.getManager().getProtocolManager(); + + protocolManager.registerProtocol(new Protocol1_8To1_9(), ProtocolVersion.v1_8, ProtocolVersion.v1_9); + protocolManager.registerProtocol(new Protocol1_7_6_10To1_8(), ProtocolVersion.v1_7_6, ProtocolVersion.v1_8); + protocolManager.registerProtocol(new Protocol1_7_2_5To1_7_6_10(), ProtocolVersion.v1_7_1, ProtocolVersion.v1_7_6); + } + + /** + * Get the platform logger + * + * @return the logger + */ + Logger getLogger(); +} diff --git a/common/src/main/java/com/viaversion/viarewind/netty/EmptyChannelHandler.java b/common/src/main/java/com/viaversion/viarewind/netty/EmptyChannelHandler.java new file mode 100644 index 000000000..dfb3d1cdf --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/netty/EmptyChannelHandler.java @@ -0,0 +1,26 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.netty; + +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelHandlerAdapter; + +@ChannelHandler.Sharable +public class EmptyChannelHandler extends ChannelHandlerAdapter { +} diff --git a/common/src/main/java/com/viaversion/viarewind/netty/ForwardMessageToByteEncoder.java b/common/src/main/java/com/viaversion/viarewind/netty/ForwardMessageToByteEncoder.java new file mode 100644 index 000000000..d145d7437 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/netty/ForwardMessageToByteEncoder.java @@ -0,0 +1,31 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.netty; + +import io.netty.buffer.ByteBuf; +import io.netty.channel.ChannelHandlerContext; +import io.netty.handler.codec.MessageToByteEncoder; + +public class ForwardMessageToByteEncoder extends MessageToByteEncoder { + + @Override + protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) { + out.writeBytes(msg); + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_0_5to1_7_6_10/Protocol1_7_0_5to1_7_6_10.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_2_5to1_7_6_10/Protocol1_7_2_5To1_7_6_10.java similarity index 70% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_0_5to1_7_6_10/Protocol1_7_0_5to1_7_6_10.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_2_5to1_7_6_10/Protocol1_7_2_5To1_7_6_10.java index 3983b998e..d3f8e857d 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_0_5to1_7_6_10/Protocol1_7_0_5to1_7_6_10.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_2_5to1_7_6_10/Protocol1_7_2_5To1_7_6_10.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_0_5to1_7_6_10; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_2_5to1_7_6_10; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.AbstractProtocol; @@ -7,15 +25,15 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.protocol.remapper.ValueTransformer; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ServerboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ServerboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -public class Protocol1_7_0_5to1_7_6_10 extends AbstractProtocol { +public class Protocol1_7_2_5To1_7_6_10 extends AbstractProtocol { public static final ValueTransformer REMOVE_DASHES = new ValueTransformer(Type.STRING) { @Override public String transform(PacketWrapper packetWrapper, String s) { @@ -23,7 +41,7 @@ public String transform(PacketWrapper packetWrapper, String s) { } }; - public Protocol1_7_0_5to1_7_6_10() { + public Protocol1_7_2_5To1_7_6_10() { super(ClientboundPackets1_7.class, ClientboundPackets1_7.class, ServerboundPackets1_7.class, ServerboundPackets1_7.class); } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/ClientboundPackets1_7.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/ClientboundPackets1_7.java similarity index 68% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/ClientboundPackets1_7.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/ClientboundPackets1_7.java index cc65a8d2e..344014d67 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/ClientboundPackets1_7.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/ClientboundPackets1_7.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10TO1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10To1_8.java similarity index 75% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10TO1_8.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10To1_8.java index 582569eb4..42cb7b5dd 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10TO1_8.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/Protocol1_7_6_10To1_8.java @@ -1,5 +1,27 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.packets.*; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.provider.CompressionHandlerProvider; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.*; +import com.viaversion.viarewind.utils.Ticker; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.platform.providers.ViaProviders; @@ -12,15 +34,11 @@ import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.packets.*; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.provider.CompressionHandlerProvider; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.*; -import de.gerrygames.viarewind.utils.Ticker; -public class Protocol1_7_6_10TO1_8 extends AbstractProtocol { - public Protocol1_7_6_10TO1_8() { + public Protocol1_7_6_10To1_8() { super(ClientboundPackets1_8.class, ClientboundPackets1_7.class, ServerboundPackets1_8.class, ServerboundPackets1_7.class); } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/ServerboundPackets1_7.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/ServerboundPackets1_7.java similarity index 51% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/ServerboundPackets1_7.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/ServerboundPackets1_7.java index 5d0275911..9ce1eadb1 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/ServerboundPackets1_7.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/ServerboundPackets1_7.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8; import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ChunkPacketTransformer.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ChunkPacketTransformer.java similarity index 84% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ChunkPacketTransformer.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ChunkPacketTransformer.java index b358f72e6..dcffd821f 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ChunkPacketTransformer.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ChunkPacketTransformer.java @@ -1,5 +1,24 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.chunks; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.chunks; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items.ReplacementRegistry1_7_6_10to1_8; import com.viaversion.viaversion.api.minecraft.chunks.ChunkSection; import com.viaversion.viaversion.api.minecraft.chunks.DataPalette; import com.viaversion.viaversion.api.minecraft.chunks.PaletteType; @@ -7,7 +26,6 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.CustomByteType; import com.viaversion.viaversion.api.type.types.version.Types1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items.ReplacementRegistry1_7_6_10to1_8; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.Unpooled; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ExtendedBlockStorage.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ExtendedBlockStorage.java similarity index 77% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ExtendedBlockStorage.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ExtendedBlockStorage.java index a6372141b..7cdd4c227 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ExtendedBlockStorage.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/chunks/ExtendedBlockStorage.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.chunks; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.chunks; import com.viaversion.viaversion.api.minecraft.chunks.NibbleArray; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java similarity index 80% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java index 840169c57..85095ce25 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/ArmorStandReplacement.java @@ -1,19 +1,37 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.utils.math.AABB; +import com.viaversion.viarewind.utils.math.Vector3d; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.MetaType1_7_6_10; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.utils.PacketUtil; -import de.gerrygames.viarewind.utils.math.AABB; -import de.gerrygames.viarewind.utils.math.Vector3d; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.MetaType1_7_6_10; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.ArrayList; import java.util.List; @@ -141,7 +159,7 @@ private void updateHologramLocation(boolean remount) { detach.write(Type.INT, entityIds[1]); detach.write(Type.INT, -1); detach.write(Type.BOOLEAN, false); - PacketUtil.sendPacket(detach, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(detach, Protocol1_7_6_10To1_8.class, true, true); } // Don't ask me where this offset is coming from @@ -154,7 +172,7 @@ private void updateHologramLocation(boolean remount) { attach.write(Type.INT, entityIds[1]); attach.write(Type.INT, entityIds[0]); attach.write(Type.BOOLEAN, false); - PacketUtil.sendPacket(attach, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(attach, Protocol1_7_6_10To1_8.class, true, true); } } @@ -171,7 +189,7 @@ public void updateMetadata() { return; } - PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10To1_8.class, true, true); } private void writeZombieMeta(PacketWrapper metadataPacket) { @@ -230,7 +248,7 @@ private void spawnHologram() { spawnSkull.write(Type.BYTE, (byte) 0); spawnSkull.write(Type.BYTE, (byte) 0); spawnSkull.write(Type.INT, 0); - PacketUtil.sendPacket(spawnSkull, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(spawnSkull, Protocol1_7_6_10To1_8.class, true, true); sendSpawn(entityIds[1], 100, locX, locY, locZ); // Horse @@ -257,6 +275,6 @@ public void despawn() { despawn.write(Type.INT, id); } entityIds = null; - PacketUtil.sendPacket(despawn, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(despawn, Protocol1_7_6_10To1_8.class, true, true); } } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java similarity index 64% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java index bec899e43..366094a30 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EndermiteReplacement.java @@ -1,15 +1,33 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; +import com.viaversion.viarewind.utils.PacketUtil; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.ArrayList; import java.util.List; @@ -81,7 +99,7 @@ public void updateMetadata() { metadataPacket.write(Types1_7_6_10.METADATA_LIST, metadataList); - PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10To1_8.class); } @Override @@ -94,7 +112,7 @@ public void despawn() { PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7.DESTROY_ENTITIES, null, user); despawn.write(Types1_7_6_10.INT_ARRAY, new int[]{entityId}); - PacketUtil.sendPacket(despawn, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(despawn, Protocol1_7_6_10To1_8.class, true, true); } public int getEntityId() { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java similarity index 59% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java index 2281f0aea..d1e50e086 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/EntityReplacement1_7to1_8.java @@ -1,13 +1,31 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; + +import com.viaversion.viarewind.replacement.EntityReplacement; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.replacement.EntityReplacement; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.ArrayList; @@ -32,14 +50,14 @@ protected void sendTeleport(int entityId, double locX, double locY, double locZ, teleport.write(Type.BYTE, (byte) ((yaw / 360f) * 256)); teleport.write(Type.BYTE, (byte) ((pitch / 360f) * 256)); - PacketUtil.sendPacket(teleport, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(teleport, Protocol1_7_6_10To1_8.class, true, true); } protected void sendHeadYaw(int entityId, float headYaw) { PacketWrapper head = PacketWrapper.create(ClientboundPackets1_7.ENTITY_HEAD_LOOK, null, user); head.write(Type.INT, entityId); head.write(Type.BYTE, (byte) ((headYaw / 360f) * 256)); - PacketUtil.sendPacket(head, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(head, Protocol1_7_6_10To1_8.class, true, true); } protected void sendSpawn(int entityId, int type, double locX, double locY, double locZ) { @@ -57,6 +75,6 @@ protected void sendSpawn(int entityId, int type, double locX, double locY, doubl spawn.write(Type.SHORT, (short) 0); spawn.write(Types1_7_6_10.METADATA_LIST, new ArrayList<>()); - PacketUtil.sendPacket(spawn, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(spawn, Protocol1_7_6_10To1_8.class, true, true); } } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java similarity index 64% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java index f0fcc0a87..aed307b5d 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/GuardianReplacement.java @@ -1,15 +1,33 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; +import com.viaversion.viarewind.utils.PacketUtil; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.ArrayList; import java.util.List; @@ -82,7 +100,7 @@ public void updateMetadata() { metadataPacket.write(Types1_7_6_10.METADATA_LIST, metadataList); - PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10To1_8.class); } @Override @@ -95,7 +113,7 @@ public void despawn() { PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7.DESTROY_ENTITIES, null, user); despawn.write(Types1_7_6_10.INT_ARRAY, new int[]{entityId}); - PacketUtil.sendPacket(despawn, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(despawn, Protocol1_7_6_10To1_8.class, true, true); } public int getEntityId() { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java similarity index 64% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java index 4cde1d3c9..17f7bd245 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/entityreplacements/RabbitReplacement.java @@ -1,15 +1,33 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; +import com.viaversion.viarewind.utils.PacketUtil; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.ArrayList; import java.util.List; @@ -81,7 +99,7 @@ public void updateMetadata() { metadataPacket.write(Types1_7_6_10.METADATA_LIST, metadataList); - PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(metadataPacket, Protocol1_7_6_10To1_8.class, true, true); } @Override @@ -94,7 +112,7 @@ public void despawn() { PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7.DESTROY_ENTITIES, null, user); despawn.write(Types1_7_6_10.INT_ARRAY, new int[]{entityId}); - PacketUtil.sendPacket(despawn, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(despawn, Protocol1_7_6_10To1_8.class, true, true); } public int getEntityId() { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/items/ItemRewriter.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/items/ItemRewriter.java similarity index 79% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/items/ItemRewriter.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/items/ItemRewriter.java index e46b0611f..e012d74d9 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/items/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/items/ItemRewriter.java @@ -1,9 +1,27 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items; + +import com.viaversion.viarewind.utils.ChatUtil; +import com.viaversion.viarewind.utils.Enchantments; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.libs.opennbt.tag.builtin.*; -import de.gerrygames.viarewind.utils.ChatUtil; -import de.gerrygames.viarewind.utils.Enchantments; import java.util.ArrayList; import java.util.List; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/items/ReplacementRegistry1_7_6_10to1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/items/ReplacementRegistry1_7_6_10to1_8.java similarity index 85% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/items/ReplacementRegistry1_7_6_10to1_8.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/items/ReplacementRegistry1_7_6_10to1_8.java index abbaadcf0..a74f91716 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/items/ReplacementRegistry1_7_6_10to1_8.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/items/ReplacementRegistry1_7_6_10to1_8.java @@ -1,9 +1,27 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items; + +import com.viaversion.viarewind.replacement.Replacement; +import com.viaversion.viarewind.storage.BlockState; import com.viaversion.viaversion.api.minecraft.item.Item; -import de.gerrygames.viarewind.replacement.Replacement; -import de.gerrygames.viarewind.replacement.ReplacementRegistry; -import de.gerrygames.viarewind.storage.BlockState; +import com.viaversion.viarewind.replacement.ReplacementRegistry; public class ReplacementRegistry1_7_6_10to1_8 { private static final ReplacementRegistry registry = new ReplacementRegistry(); diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetaIndex1_7_6_10to1_8.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetaIndex1_7_6_10to1_8.java new file mode 100644 index 000000000..9c2f3886b --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetaIndex1_7_6_10to1_8.java @@ -0,0 +1,60 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata; + +import com.viaversion.viarewind.protocol.protocol1_8to1_7_6_10.metadata.MetaIndex1_8To1_7_6_10; +import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; +import com.viaversion.viaversion.util.Pair; + +import java.util.HashMap; +import java.util.Optional; + +public class MetaIndex1_7_6_10to1_8 { + + private static final HashMap, MetaIndex1_8To1_7_6_10> metadataRewrites = new HashMap<>(); + + static { + for (MetaIndex1_8To1_7_6_10 index : MetaIndex1_8To1_7_6_10.values()) + metadataRewrites.put(new Pair<>(index.getClazz(), index.getNewIndex()), index); + } + + private static Optional getIndex(Entity1_10Types.EntityType type, int index) { + Pair pair = new Pair<>(type, index); + if (metadataRewrites.containsKey(pair)) { + return Optional.of(metadataRewrites.get(pair)); + } + + return Optional.empty(); + } + + public static MetaIndex1_8To1_7_6_10 searchIndex(Entity1_10Types.EntityType type, int index) { + Entity1_10Types.EntityType currentType = type; + do { + Optional optMeta = getIndex(currentType, index); + + if (optMeta.isPresent()) { + return optMeta.get(); + } + + currentType = currentType.getParent(); + } while (currentType != null); + + return null; + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java similarity index 62% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java index ff70f09f8..3638b278c 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java @@ -1,14 +1,31 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata; + +import com.viaversion.viarewind.ViaRewind; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items.ItemRewriter; +import com.viaversion.viarewind.protocol.protocol1_8to1_7_6_10.metadata.MetaIndex1_8To1_7_6_10; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types.EntityType; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8; -import de.gerrygames.viarewind.ViaRewind; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items.ItemRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.MetaType1_7_6_10; -import de.gerrygames.viarewind.protocol.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6_10; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.MetaType1_7_6_10; import java.util.ArrayList; import java.util.List; @@ -17,7 +34,7 @@ public class MetadataRewriter { public static void transform(Entity1_10Types.EntityType type, List list) { for (Metadata entry : new ArrayList<>(list)) { - MetaIndex1_8to1_7_6_10 metaIndex = MetaIndex1_7_6_10to1_8.searchIndex(type, entry.id()); + MetaIndex1_8To1_7_6_10 metaIndex = MetaIndex1_7_6_10to1_8.searchIndex(type, entry.id()); try { if (metaIndex == null) throw new Exception("Could not find valid metadata"); if (metaIndex.getOldType() == MetaType1_7_6_10.NonExistent) { @@ -35,7 +52,7 @@ public static void transform(Entity1_10Types.EntityType type, List lis case Int: if (metaIndex.getNewType() == MetaType1_8.Byte) { entry.setValue(((Byte) value).intValue()); - if (metaIndex==MetaIndex1_8to1_7_6_10.ENTITY_AGEABLE_AGE) { + if (metaIndex == MetaIndex1_8To1_7_6_10.ENTITY_AGEABLE_AGE) { if ((Integer) entry.getValue() < 0) { entry.setValue(-25000); } @@ -53,12 +70,12 @@ public static void transform(Entity1_10Types.EntityType type, List lis entry.setValue(((Integer) value).byteValue()); } if (metaIndex.getNewType() == MetaType1_8.Byte) { - if (metaIndex==MetaIndex1_8to1_7_6_10.ITEM_FRAME_ROTATION) { - value = ((Integer)((Byte)value / 2)).byteValue(); + if (metaIndex == MetaIndex1_8To1_7_6_10.ITEM_FRAME_ROTATION) { + value = ((Integer) ((Byte) value / 2)).byteValue(); } entry.setValue(value); } - if (metaIndex==MetaIndex1_8to1_7_6_10.HUMAN_SKIN_FLAGS) { + if (metaIndex == MetaIndex1_8To1_7_6_10.HUMAN_SKIN_FLAGS) { byte flags = (byte) value; boolean cape = (flags & 0x01) != 0; flags = (byte) (cape ? 0x00 : 0x02); diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java similarity index 87% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java index 636d3cd2a..0183ab3f1 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/EntityPackets.java @@ -1,7 +1,33 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.packets; import com.google.common.collect.Lists; import com.google.common.primitives.Ints; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.EntityTracker; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.GameProfileStorage; +import com.viaversion.viarewind.replacement.EntityReplacement; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items.ItemRewriter; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -11,22 +37,14 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items.ItemRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.EntityTracker; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.GameProfileStorage; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.replacement.EntityReplacement; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.List; import java.util.UUID; public class EntityPackets { - public static void register(Protocol1_7_6_10TO1_8 protocol) { + public static void register(Protocol1_7_6_10To1_8 protocol) { /* OUTGOING */ @@ -111,7 +129,7 @@ public void register() { packetWrapper.user()); destroy.write(Types1_7_6_10.INT_ARRAY, parts.get(i).stream() .mapToInt(Integer::intValue).toArray()); - PacketUtil.sendPacket(destroy, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(destroy, Protocol1_7_6_10To1_8.class); } packetWrapper.write(Types1_7_6_10.INT_ARRAY, parts.get(parts.size() - 1).stream() diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/InventoryPackets.java similarity index 84% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/InventoryPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/InventoryPackets.java index 7c9821c40..5a9277fce 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/InventoryPackets.java @@ -1,24 +1,42 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.packets; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.EntityTracker; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.GameProfileStorage; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.Windows; +import com.viaversion.viarewind.utils.ChatUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ServerboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items.ItemRewriter; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ServerboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items.ItemRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.EntityTracker; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.GameProfileStorage; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.Windows; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.utils.ChatUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.UUID; public class InventoryPackets { - public static void register(Protocol1_7_6_10TO1_8 protocol) { + public static void register(Protocol1_7_6_10To1_8 protocol) { /* OUTGOING */ diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java similarity index 91% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java index 583f88ba3..53f078cd0 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/PlayerPackets.java @@ -1,5 +1,38 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.packets; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.packets; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.ArmorStandReplacement; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.provider.TitleRenderProvider; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.*; +import com.viaversion.viarewind.replacement.EntityReplacement; +import com.viaversion.viarewind.utils.ChatUtil; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.utils.math.AABB; +import com.viaversion.viarewind.utils.math.Ray3d; +import com.viaversion.viarewind.utils.math.RayTracing; +import com.viaversion.viarewind.utils.math.Vector3d; +import com.viaversion.viarewind.ViaRewind; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ServerboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items.ItemRewriter; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; @@ -14,23 +47,7 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; -import de.gerrygames.viarewind.ViaRewind; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ServerboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.ArmorStandReplacement; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items.ItemRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.provider.TitleRenderProvider; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.*; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.replacement.EntityReplacement; -import de.gerrygames.viarewind.utils.ChatUtil; -import de.gerrygames.viarewind.utils.PacketUtil; -import de.gerrygames.viarewind.utils.Utils; -import de.gerrygames.viarewind.utils.math.AABB; -import de.gerrygames.viarewind.utils.math.Ray3d; -import de.gerrygames.viarewind.utils.math.RayTracing; -import de.gerrygames.viarewind.utils.math.Vector3d; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.buffer.Unpooled; @@ -41,7 +58,7 @@ public class PlayerPackets { - public static void register(Protocol1_7_6_10TO1_8 protocol) { + public static void register(Protocol1_7_6_10To1_8 protocol) { /* OUTGOING */ @@ -231,7 +248,7 @@ public void register() { setSlot.write(Type.BYTE, (byte) 0); setSlot.write(Type.SHORT, (short) (8 - i)); setSlot.write(Types1_7_6_10.COMPRESSED_NBT_ITEM, equipment[i]); - PacketUtil.sendPacket(setSlot, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(setSlot, Protocol1_7_6_10To1_8.class); } } }); @@ -298,7 +315,7 @@ public void register() { packet.write(Type.STRING, gameProfile.getDisplayName()); packet.write(Type.BOOLEAN, true); packet.write(Type.SHORT, (short) ping); - PacketUtil.sendPacket(packet, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(packet, Protocol1_7_6_10To1_8.class); } else if (action == 1) { int gamemode = packetWrapper.read(Type.VAR_INT); @@ -325,7 +342,7 @@ public void register() { equipmentPacket.write(Type.INT, entityId); equipmentPacket.write(Type.SHORT, slot); equipmentPacket.write(Types1_7_6_10.COMPRESSED_NBT_ITEM, equipment[slot]); - PacketUtil.sendPacket(equipmentPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(equipmentPacket, Protocol1_7_6_10To1_8.class); } } } @@ -341,7 +358,7 @@ public void register() { packet.write(Type.STRING, gameProfile.getDisplayName()); packet.write(Type.BOOLEAN, false); packet.write(Type.SHORT, (short) gameProfile.ping); - PacketUtil.sendPacket(packet, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(packet, Protocol1_7_6_10To1_8.class); gameProfile.ping = ping; @@ -349,7 +366,7 @@ public void register() { packet.write(Type.STRING, gameProfile.getDisplayName()); packet.write(Type.BOOLEAN, true); packet.write(Type.SHORT, (short) ping); - PacketUtil.sendPacket(packet, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(packet, Protocol1_7_6_10To1_8.class); } else if (action == 3) { JsonElement displayNameComponent = packetWrapper.read(Type.OPTIONAL_COMPONENT); String displayName = displayNameComponent != null ? ChatUtil.jsonToLegacy(displayNameComponent) : null; @@ -361,7 +378,7 @@ public void register() { packet.write(Type.STRING, gameProfile.getDisplayName()); packet.write(Type.BOOLEAN, false); packet.write(Type.SHORT, (short) gameProfile.ping); - PacketUtil.sendPacket(packet, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(packet, Protocol1_7_6_10To1_8.class); if (gameProfile.displayName == null && displayName != null || gameProfile.displayName != null && displayName == null || !gameProfile.displayName.equals(displayName)) { gameProfile.setDisplayName(displayName); @@ -371,7 +388,7 @@ public void register() { packet.write(Type.STRING, gameProfile.getDisplayName()); packet.write(Type.BOOLEAN, true); packet.write(Type.SHORT, (short) gameProfile.ping); - PacketUtil.sendPacket(packet, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(packet, Protocol1_7_6_10To1_8.class); } else if (action == 4) { GameProfileStorage.GameProfile gameProfile = gameProfileStorage.remove(uuid); if (gameProfile == null) continue; @@ -380,7 +397,7 @@ public void register() { packet.write(Type.STRING, gameProfile.getDisplayName()); packet.write(Type.BOOLEAN, false); packet.write(Type.SHORT, (short) gameProfile.ping); - PacketUtil.sendPacket(packet, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(packet, Protocol1_7_6_10To1_8.class); } } }); @@ -456,7 +473,7 @@ public void register() { newWrapper.passthrough(Type.STRING); if (newPacketBuf.readableBytes() <= Short.MAX_VALUE) { newWrapper.write(Type.SHORT, (short) newPacketBuf.readableBytes()); - newWrapper.send(Protocol1_7_6_10TO1_8.class); + newWrapper.send(Protocol1_7_6_10To1_8.class); } }); } @@ -490,7 +507,7 @@ public void register() { TitleRenderProvider titleRenderProvider = Via.getManager().getProviders().get(TitleRenderProvider.class); if (titleRenderProvider == null) return; int action = packetWrapper.read(Type.VAR_INT); - UUID uuid = Utils.getUUID(packetWrapper.user()); + UUID uuid = packetWrapper.user().getProtocolInfo().getUuid(); switch (action) { case 0: titleRenderProvider.setTitle(uuid, packetWrapper.read(Type.STRING)); @@ -554,7 +571,7 @@ public void register() { PacketWrapper teleportPacket = PacketWrapper.create(0x18, null, packetWrapper.user()); teleportPacket.write(Type.UUID, profile.uuid); - PacketUtil.sendToServer(teleportPacket, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendToServer(teleportPacket, Protocol1_7_6_10To1_8.class, true, true); } } }); @@ -728,7 +745,7 @@ public void register() { entityAction.write(Type.VAR_INT, entityId); entityAction.write(Type.VAR_INT, animation); entityAction.write(Type.VAR_INT, 0); - PacketUtil.sendPacket(entityAction, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(entityAction, Protocol1_7_6_10To1_8.class, true, true); }); } }); @@ -748,7 +765,7 @@ public void register() { abilitiesPacket.write(Type.BYTE, abilities.getFlags()); abilitiesPacket.write(Type.FLOAT, abilities.isSprinting() ? abilities.getFlySpeed() * 2.0f : abilities.getFlySpeed()); abilitiesPacket.write(Type.FLOAT, abilities.getWalkSpeed()); - PacketUtil.sendPacket(abilitiesPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(abilitiesPacket, Protocol1_7_6_10To1_8.class); } }); } @@ -780,7 +797,7 @@ public void register() { unsneakPacket.write(Type.VAR_INT, 1); //Stop sneaking unsneakPacket.write(Type.VAR_INT, 0); //Action Parameter - PacketUtil.sendToServer(sneakPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendToServer(sneakPacket, Protocol1_7_6_10To1_8.class); } } }); @@ -842,7 +859,7 @@ public void register() { tabComplete.write(Type.STRING, profile.name); } - PacketUtil.sendPacket(tabComplete, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(tabComplete, Protocol1_7_6_10To1_8.class); } } }); @@ -891,7 +908,7 @@ public void register() { updateCost.write(Type.SHORT, (short) 0); updateCost.write(Type.SHORT, windows.levelCost); - PacketUtil.sendPacket(updateCost, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(updateCost, Protocol1_7_6_10To1_8.class, true, true); break; } case "MC|BEdit": diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/ScoreboardPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/ScoreboardPackets.java similarity index 85% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/ScoreboardPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/ScoreboardPackets.java index c7fced073..c76f0cd19 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/ScoreboardPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/ScoreboardPackets.java @@ -1,16 +1,31 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ -import com.viaversion.viaversion.api.protocol.Protocol; +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.packets; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.Scoreboard; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.packet.State; -import com.viaversion.viaversion.api.protocol.remapper.PacketHandler; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.util.ChatColorUtil; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.Scoreboard; -import de.gerrygames.viarewind.utils.PacketUtil; import java.util.ArrayList; import java.util.List; @@ -18,7 +33,7 @@ public class ScoreboardPackets { - public static void register(Protocol1_7_6_10TO1_8 protocol) { + public static void register(Protocol1_7_6_10To1_8 protocol) { /* OUTGOING */ @@ -54,7 +69,7 @@ public void register() { PacketWrapper sidebarPacket = PacketWrapper.create(0x3D, null, packetWrapper.user()); sidebarPacket.write(Type.BYTE, (byte) 1); sidebarPacket.write(Type.STRING, scoreboard.getColorIndependentSidebar()); - PacketUtil.sendPacket(sidebarPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(sidebarPacket, Protocol1_7_6_10To1_8.class); } } } @@ -179,7 +194,7 @@ public void register() { PacketWrapper remove = PacketWrapper.create(0x3E, null, packetWrapper.user()); remove.write(Type.STRING, team); remove.write(Type.BYTE, (byte) 1); - PacketUtil.sendPacket(remove, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(remove, Protocol1_7_6_10To1_8.class, true, true); } if (mode == 0) { @@ -201,7 +216,7 @@ public void register() { PacketWrapper sidebarPacket = packetWrapper.create(0x3D); sidebarPacket.write(Type.BYTE, (byte) 1); sidebarPacket.write(Type.STRING, sidebar == null ? "" : sidebar); - PacketUtil.sendPacket(sidebarPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(sidebarPacket, Protocol1_7_6_10To1_8.class); } scoreboard.setTeamColor(team, color); } @@ -221,7 +236,7 @@ public void register() { PacketWrapper sidebarPacket = packetWrapper.create(0x3D); sidebarPacket.write(Type.BYTE, (byte) 1); sidebarPacket.write(Type.STRING, scoreboard.getColorIndependentSidebar() == null ? "" : scoreboard.getColorIndependentSidebar()); - PacketUtil.sendPacket(sidebarPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(sidebarPacket, Protocol1_7_6_10To1_8.class); } } else { scoreboard.addPlayerToTeam(entry, team); @@ -229,7 +244,7 @@ public void register() { PacketWrapper displayObjective = packetWrapper.create(0x3D); displayObjective.write(Type.BYTE, (byte) 1); displayObjective.write(Type.STRING, scoreboard.getColorDependentSidebar().get(color)); - PacketUtil.sendPacket(displayObjective, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(displayObjective, Protocol1_7_6_10To1_8.class); } } entryList.add(entry); diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java similarity index 82% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java index 691bec7fb..7c9c8cf0e 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/SpawnPackets.java @@ -1,5 +1,36 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.packets; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.ArmorStandReplacement; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.EndermiteReplacement; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.GuardianReplacement; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.RabbitReplacement; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.EntityTracker; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.GameProfileStorage; +import com.viaversion.viarewind.replacement.EntityReplacement; +import com.viaversion.viarewind.replacement.Replacement; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items.ReplacementRegistry1_7_6_10to1_8; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -8,27 +39,14 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.ArmorStandReplacement; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.EndermiteReplacement; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.GuardianReplacement; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.entityreplacements.RabbitReplacement; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items.ReplacementRegistry1_7_6_10to1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.EntityTracker; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.GameProfileStorage; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.replacement.EntityReplacement; -import de.gerrygames.viarewind.replacement.Replacement; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; import java.util.List; import java.util.UUID; public class SpawnPackets { - public static void register(Protocol1_7_6_10TO1_8 protocol) { + public static void register(Protocol1_7_6_10To1_8 protocol) { /* OUTGOING */ @@ -64,7 +82,7 @@ public void register() { equipmentPacket.write(Type.INT, entityId); equipmentPacket.write(Type.SHORT, i); equipmentPacket.write(Types1_7_6_10.COMPRESSED_NBT_ITEM, i == 4 ? gameProfile.getSkull() :null); - PacketUtil.sendPacket(equipmentPacket, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(equipmentPacket, Protocol1_7_6_10To1_8.class); } } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/WorldPackets.java similarity index 86% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/WorldPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/WorldPackets.java index 40290c33f..b98314d78 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/packets/WorldPackets.java @@ -1,5 +1,29 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.packets; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.chunks.ChunkPacketTransformer; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.WorldBorder; +import com.viaversion.viarewind.utils.ChatUtil; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.items.ReplacementRegistry1_7_6_10to1_8; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; @@ -14,19 +38,13 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type; import com.viaversion.viaversion.util.ChatColorUtil; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.chunks.ChunkPacketTransformer; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.items.ReplacementRegistry1_7_6_10to1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.WorldBorder; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Chunk1_7_10Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Particle; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; -import de.gerrygames.viarewind.utils.ChatUtil; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Chunk1_7_10Type; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Particle; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.Types1_7_6_10; public class WorldPackets { - public static void register(Protocol1_7_6_10TO1_8 protocol) { + public static void register(Protocol1_7_6_10To1_8 protocol) { /* OUTGOING */ @@ -246,7 +264,7 @@ public void register() { columnUpdate.write(Type.SHORT, (short) columnData.length); columnUpdate.write(new CustomByteType(columnData.length), columnData); - PacketUtil.sendPacket(columnUpdate, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(columnUpdate, Protocol1_7_6_10To1_8.class, true, true); } } @@ -263,14 +281,14 @@ public void register() { iconUpdate.write(Type.SHORT, (short) iconData.length); CustomByteType customByteType = new CustomByteType(iconData.length); iconUpdate.write(customByteType, iconData); - PacketUtil.sendPacket(iconUpdate, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(iconUpdate, Protocol1_7_6_10To1_8.class, true, true); } PacketWrapper scaleUpdate = PacketWrapper.create(0x34, null, packetWrapper.user()); scaleUpdate.write(Type.VAR_INT, id); scaleUpdate.write(Type.SHORT, (short) 2); scaleUpdate.write(new CustomByteType(2), new byte[]{2, scale}); - PacketUtil.sendPacket(scaleUpdate, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(scaleUpdate, Protocol1_7_6_10To1_8.class, true, true); }); } }); diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java similarity index 83% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java index 19b74bd18..0e02ffbce 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/CompressionHandlerProvider.java @@ -1,12 +1,30 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.provider; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.provider; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage.CompressionSendStorage; import com.viaversion.viaversion.api.Via; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.platform.providers.Provider; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.netty.EmptyChannelHandler; -import de.gerrygames.viarewind.netty.ForwardMessageToByteEncoder; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage.CompressionSendStorage; +import com.viaversion.viarewind.netty.EmptyChannelHandler; +import com.viaversion.viarewind.netty.ForwardMessageToByteEncoder; import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBufAllocator; import io.netty.channel.ChannelHandler; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/provider/TitleRenderProvider.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/TitleRenderProvider.java similarity index 71% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/provider/TitleRenderProvider.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/TitleRenderProvider.java index a01d1ec3c..9394528fc 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/provider/TitleRenderProvider.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/provider/TitleRenderProvider.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.provider; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.provider; import com.viaversion.viaversion.api.platform.providers.Provider; diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java new file mode 100644 index 000000000..559215f09 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java @@ -0,0 +1,38 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage; + +import com.viaversion.viaversion.api.connection.StoredObject; +import com.viaversion.viaversion.api.connection.UserConnection; + +public class CompressionSendStorage extends StoredObject { + private boolean removeCompression = false; + + public CompressionSendStorage(UserConnection user) { + super(user); + } + + public boolean isRemoveCompression() { + return removeCompression; + } + + public void setRemoveCompression(boolean removeCompression) { + this.removeCompression = removeCompression; + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java similarity index 83% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java index 672c7392b..b833de7b7 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/EntityTracker.java @@ -1,5 +1,27 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; +import com.viaversion.viarewind.replacement.EntityReplacement; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.entity.ClientEntityIdChangeListener; @@ -9,10 +31,6 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata.MetadataRewriter; -import de.gerrygames.viarewind.replacement.EntityReplacement; -import de.gerrygames.viarewind.utils.PacketUtil; import java.util.HashMap; import java.util.List; @@ -110,7 +128,7 @@ public void sendMetadataBuffer(int entityId) { wrapper.write(Types1_8.METADATA_LIST, this.metadataBuffer.get(entityId)); MetadataRewriter.transform(type, this.metadataBuffer.get(entityId)); if (!this.metadataBuffer.get(entityId).isEmpty()) { - PacketUtil.sendPacket(wrapper, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(wrapper, Protocol1_7_6_10To1_8.class); } this.metadataBuffer.remove(entityId); @@ -141,7 +159,7 @@ public void setPassenger(int vehicleId, int passengerId) { unsneakPacket.write(Type.VAR_INT, 1); //Stop sneaking unsneakPacket.write(Type.VAR_INT, 0); //Action Parameter - PacketUtil.sendToServer(sneakPacket, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendToServer(sneakPacket, Protocol1_7_6_10To1_8.class, true, true); setSpectating(playerId); } catch (Exception ex) {ex.printStackTrace();} @@ -173,7 +191,7 @@ public boolean setSpectating(int spectating) { unsneakPacket.write(Type.VAR_INT, 1); //Stop sneaking unsneakPacket.write(Type.VAR_INT, 0); //Action Parameter - PacketUtil.sendToServer(sneakPacket, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendToServer(sneakPacket, Protocol1_7_6_10To1_8.class, true, true); setSpectating(this.playerId); return false; //Entity has Passenger @@ -184,7 +202,7 @@ public boolean setSpectating(int spectating) { unmount.write(Type.INT, this.playerId); unmount.write(Type.INT, -1); unmount.write(Type.BOOLEAN, false); - PacketUtil.sendPacket(unmount, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(unmount, Protocol1_7_6_10To1_8.class); } this.spectating = spectating; if (spectating!=this.playerId) { @@ -192,7 +210,7 @@ public boolean setSpectating(int spectating) { mount.write(Type.INT, this.playerId); mount.write(Type.INT, this.spectating); mount.write(Type.BOOLEAN, false); - PacketUtil.sendPacket(mount, Protocol1_7_6_10TO1_8.class); + PacketUtil.sendPacket(mount, Protocol1_7_6_10To1_8.class); } return true; } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/GameProfileStorage.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/GameProfileStorage.java similarity index 80% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/GameProfileStorage.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/GameProfileStorage.java index 0fc062995..88a9e41e8 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/GameProfileStorage.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/GameProfileStorage.java @@ -1,5 +1,24 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage; + +import com.viaversion.viarewind.utils.ChatUtil; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.DataItem; @@ -8,7 +27,6 @@ import com.viaversion.viaversion.libs.opennbt.tag.builtin.ListTag; import com.viaversion.viaversion.libs.opennbt.tag.builtin.StringTag; import com.viaversion.viaversion.util.ChatColorUtil; -import de.gerrygames.viarewind.utils.ChatUtil; import java.util.*; @@ -95,7 +113,7 @@ public Item getSkull() { ownerTag.put("Properties", properties); ListTag textures = new ListTag(CompoundTag.class); properties.put("textures", textures); - for (GameProfileStorage.Property property : this.properties) { + for (Property property : this.properties) { if (property.name.equals("textures")) { CompoundTag textureTag = new CompoundTag(); textureTag.put("Value", new StringTag(property.value)); diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java similarity index 78% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java index cff4882a5..751dd0743 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerAbilities.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java similarity index 63% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java index 585a0dd83..b33d0f7b3 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/PlayerPosition.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/Scoreboard.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Scoreboard.java similarity index 80% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/Scoreboard.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Scoreboard.java index 6e3e17ff5..6e1479037 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/Scoreboard.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Scoreboard.java @@ -1,12 +1,30 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage; + +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.utils.PacketUtil; import java.util.*; @@ -125,7 +143,7 @@ public String sendTeamForScore(String score) { teamPacket.write(Type.BYTE, (byte) 0); teamPacket.write(Type.SHORT, (short) 1); teamPacket.write(Type.STRING, name); - PacketUtil.sendPacket(teamPacket, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(teamPacket, Protocol1_7_6_10To1_8.class, true, true); return name; } @@ -138,7 +156,7 @@ public String removeTeamForScore(String score) { PacketWrapper teamPacket = PacketWrapper.create(ClientboundPackets1_7.TEAMS, getUser()); teamPacket.write(Type.STRING, scoreTeam.name); teamPacket.write(Type.BYTE, (byte) 1); - PacketUtil.sendPacket(teamPacket, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(teamPacket, Protocol1_7_6_10To1_8.class, true, true); return scoreTeam.name; } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java similarity index 78% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java index e69432d06..23e94dcfe 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/Windows.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java similarity index 80% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java index 7e01a6747..4b6408067 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/storage/WorldBorder.java @@ -1,12 +1,30 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.storage; + +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.utils.Tickable; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10To1_8; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.utils.PacketUtil; -import de.gerrygames.viarewind.utils.Tickable; public class WorldBorder extends StoredObject implements Tickable { private double x, z; @@ -97,7 +115,7 @@ private void sendPackets() { particles.write(Type.FLOAT, 0f); particles.write(Type.INT, a); - PacketUtil.sendPacket(particles, Protocol1_7_6_10TO1_8.class, true, true); + PacketUtil.sendPacket(particles, Protocol1_7_6_10To1_8.class, true, true); } } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Chunk1_7_10Type.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Chunk1_7_10Type.java similarity index 80% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Chunk1_7_10Type.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Chunk1_7_10Type.java index d10aef9b0..46246d40c 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Chunk1_7_10Type.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Chunk1_7_10Type.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; import com.viaversion.viaversion.api.minecraft.Environment; import com.viaversion.viaversion.api.minecraft.chunks.Chunk; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/CompressedNBTType.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CompressedNBTType.java similarity index 61% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/CompressedNBTType.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CompressedNBTType.java index a4a731e8b..2e4a1cb9f 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/CompressedNBTType.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CompressedNBTType.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.opennbt.NBTIO; diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java new file mode 100644 index 000000000..99a231040 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java @@ -0,0 +1,46 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; + +import com.viaversion.viaversion.api.type.PartialType; +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; + +public class CustomStringType extends PartialType { + + public CustomStringType(Integer param) { + super(param, String[].class); + } + + public String[] read(ByteBuf buffer, Integer size) throws Exception { + if (buffer.readableBytes() < size/4) { + throw new RuntimeException("Readable bytes does not match expected!"); + } else { + String[] array = new String[size]; + for (int i = 0; i. + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; + +import com.viaversion.viaversion.api.type.Type; +import io.netty.buffer.ByteBuf; + +public class IntArrayType extends Type { + + public IntArrayType() { + super(int[].class); + } + + @Override + public int[] read(ByteBuf byteBuf) throws Exception { + byte size = byteBuf.readByte(); + int[] array = new int[size]; + for (byte i = 0; i < size; i++) { + array[i] = byteBuf.readInt(); + } + return array; + } + + @Override + public void write(ByteBuf byteBuf, int[] array) throws Exception { + byteBuf.writeByte(array.length); + for (int i : array) byteBuf.writeInt(i); + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemArrayType.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemArrayType.java similarity index 51% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemArrayType.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemArrayType.java index a54cb49fb..794bd2b8e 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemArrayType.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemArrayType.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.type.Type; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemType.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemType.java similarity index 57% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemType.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemType.java index 9a5e4982a..cefa228fe 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemType.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/ItemType.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; import com.viaversion.viaversion.api.minecraft.item.DataItem; import com.viaversion.viaversion.api.minecraft.item.Item; diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetaType1_7_6_10.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetaType1_7_6_10.java new file mode 100644 index 000000000..9fd99cabe --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetaType1_7_6_10.java @@ -0,0 +1,53 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; + +import com.viaversion.viaversion.api.minecraft.metadata.MetaType; +import com.viaversion.viaversion.api.type.Type; + +public enum MetaType1_7_6_10 implements MetaType { + Byte(0, Type.BYTE), + Short(1, Type.SHORT), + Int(2, Type.INT), + Float(3, Type.FLOAT), + String(4, Type.STRING), + Slot(5, Types1_7_6_10.COMPRESSED_NBT_ITEM), + Position(6, Type.VECTOR), + NonExistent(-1, Type.NOTHING); + + private final int typeID; + private final Type type; + + public static MetaType1_7_6_10 byId(int id) { + return values()[id]; + } + + MetaType1_7_6_10(int typeID, Type type) { + this.typeID = typeID; + this.type = type; + } + + public int typeId() { + return this.typeID; + } + + public Type type() { + return this.type; + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataListType.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataListType.java similarity index 52% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataListType.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataListType.java index 8f33987df..7521277fd 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataListType.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataListType.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.type.types.minecraft.MetaListTypeTemplate; diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataType.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataType.java new file mode 100644 index 000000000..cf4e4e9bd --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataType.java @@ -0,0 +1,45 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; + +import com.viaversion.viaversion.api.minecraft.metadata.Metadata; +import com.viaversion.viaversion.api.type.types.minecraft.MetaTypeTemplate; +import io.netty.buffer.ByteBuf; + +public class MetadataType extends MetaTypeTemplate { + @Override + public Metadata read(ByteBuf buffer) throws Exception { + byte item = buffer.readByte(); + if (item == 127) { + return null; + } else { + int typeID = (item & 224) >> 5; + MetaType1_7_6_10 type = MetaType1_7_6_10.byId(typeID); + int id = item & 31; + return new Metadata(id, type, type.type().read(buffer)); + } + } + + @Override + public void write(ByteBuf buffer, Metadata meta) throws Exception { + int item = (meta.metaType().typeId() << 5 | meta.id() & 31) & 255; + buffer.writeByte(item); + meta.metaType().type().write(buffer, meta.getValue()); + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/NBTType.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/NBTType.java similarity index 62% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/NBTType.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/NBTType.java index 97cd1fcdf..7f1a0badd 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/NBTType.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/NBTType.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.libs.opennbt.NBTIO; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Particle.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Particle.java similarity index 67% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Particle.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Particle.java index e59551740..d3942e5e3 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Particle.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Particle.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; import java.util.HashMap; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Types1_7_6_10.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Types1_7_6_10.java similarity index 54% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Types1_7_6_10.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Types1_7_6_10.java index ca20b7116..28fafd7dc 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/Types1_7_6_10.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/Types1_7_6_10.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_7_6_10/metadata/MetaIndex1_8to1_7_6_10.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_7_6_10/metadata/MetaIndex1_8To1_7_6_10.java similarity index 87% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_7_6_10/metadata/MetaIndex1_8to1_7_6_10.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_7_6_10/metadata/MetaIndex1_8To1_7_6_10.java index 5ed5f7f7b..dc7330f30 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_7_6_10/metadata/MetaIndex1_8to1_7_6_10.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_7_6_10/metadata/MetaIndex1_8To1_7_6_10.java @@ -1,14 +1,32 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_7_6_10.metadata; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_7_6_10.metadata; + +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types.MetaType1_7_6_10; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8; import com.viaversion.viaversion.util.Pair; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types.MetaType1_7_6_10; import java.util.HashMap; import java.util.Optional; -public enum MetaIndex1_8to1_7_6_10 { +public enum MetaIndex1_8To1_7_6_10 { ENTITY_FLAGS(Entity1_10Types.EntityType.ENTITY, 0, MetaType1_7_6_10.Byte, MetaType1_8.Byte), ENTITY_AIR(Entity1_10Types.EntityType.ENTITY, 1, MetaType1_7_6_10.Short, MetaType1_8.Short), @@ -90,10 +108,10 @@ public enum MetaIndex1_8to1_7_6_10 { ENDER_CRYSTAL_HEALTH(Entity1_10Types.EntityType.ENDER_CRYSTAL, 8, MetaType1_7_6_10.Int, 9, MetaType1_8.Int), ; - private static final HashMap, MetaIndex1_8to1_7_6_10> metadataRewrites = new HashMap<>(); + private static final HashMap, MetaIndex1_8To1_7_6_10> metadataRewrites = new HashMap<>(); static { - for (MetaIndex1_8to1_7_6_10 index : MetaIndex1_8to1_7_6_10.values()) + for (MetaIndex1_8To1_7_6_10 index : MetaIndex1_8To1_7_6_10.values()) metadataRewrites.put(new Pair<>(index.getClazz(), index.getIndex()), index); } @@ -103,7 +121,7 @@ public enum MetaIndex1_8to1_7_6_10 { private final MetaType1_7_6_10 oldType; private final int index; - MetaIndex1_8to1_7_6_10(Entity1_10Types.EntityType type, int index, MetaType1_7_6_10 oldType, MetaType1_8 newType) { + MetaIndex1_8To1_7_6_10(Entity1_10Types.EntityType type, int index, MetaType1_7_6_10 oldType, MetaType1_8 newType) { this.clazz = type; this.index = index; this.newIndex = index; @@ -111,7 +129,7 @@ public enum MetaIndex1_8to1_7_6_10 { this.newType = newType; } - MetaIndex1_8to1_7_6_10(Entity1_10Types.EntityType type, int index, MetaType1_7_6_10 oldType, int newIndex, MetaType1_8 newType) { + MetaIndex1_8To1_7_6_10(Entity1_10Types.EntityType type, int index, MetaType1_7_6_10 oldType, int newIndex, MetaType1_8 newType) { this.clazz = type; this.index = index; this.oldType = oldType; @@ -119,7 +137,7 @@ public enum MetaIndex1_8to1_7_6_10 { this.newType = newType; } - private static Optional getIndex(Entity1_10Types.EntityType type, int index) { + private static Optional getIndex(Entity1_10Types.EntityType type, int index) { Pair pair = new Pair<>(type, index); if (metadataRewrites.containsKey(pair)) { return Optional.of(metadataRewrites.get(pair)); @@ -148,10 +166,10 @@ public int getIndex() { return index; } - public static MetaIndex1_8to1_7_6_10 searchIndex(Entity1_10Types.EntityType type, int index) { + public static MetaIndex1_8To1_7_6_10 searchIndex(Entity1_10Types.EntityType type, int index) { Entity1_10Types.EntityType currentType = type; do { - Optional optMeta = getIndex(currentType, index); + Optional optMeta = getIndex(currentType, index); if (optMeta.isPresent()) { return optMeta.get(); diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/Protocol1_8TO1_9.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/Protocol1_8To1_9.java similarity index 66% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/Protocol1_8TO1_9.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/Protocol1_8To1_9.java index 651cb685b..a4e89acb5 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/Protocol1_8TO1_9.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/Protocol1_8To1_9.java @@ -1,5 +1,27 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.packets.*; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.*; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.packets.*; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.*; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.AbstractProtocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; @@ -10,16 +32,12 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.packets.*; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.*; -import de.gerrygames.viarewind.utils.Ticker; +import com.viaversion.viarewind.utils.Ticker; import java.util.*; import java.util.concurrent.ConcurrentLinkedQueue; -public class Protocol1_8TO1_9 extends AbstractProtocol { - public static final Timer TIMER = new Timer("ViaRewind-1_8TO1_9", true); +public class Protocol1_8To1_9 extends AbstractProtocol { public Queue animationsToSend = new ConcurrentLinkedQueue<>(); @@ -46,7 +64,7 @@ public Byte transform(PacketWrapper packetWrapper, Float degrees) throws Excepti VALID_ATTRIBUTES.add("zombie.spawnReinforcements"); } - public Protocol1_8TO1_9() { + public Protocol1_8To1_9() { super(ClientboundPackets1_9.class, ClientboundPackets1_8.class, ServerboundPackets1_9.class, ServerboundPackets1_8.class); } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/bossbar/WitherBossBar.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/bossbar/WitherBossBar.java similarity index 83% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/bossbar/WitherBossBar.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/bossbar/WitherBossBar.java index 409011b5f..8e70b0dfd 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/bossbar/WitherBossBar.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/bossbar/WitherBossBar.java @@ -1,5 +1,24 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.bossbar; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.bossbar; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.legacy.bossbar.BossBar; import com.viaversion.viaversion.api.legacy.bossbar.BossColor; @@ -10,8 +29,7 @@ import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.utils.PacketUtil; import java.util.*; @@ -182,7 +200,7 @@ private void spawnWither() { packetWrapper.write(Types1_8.METADATA_LIST, metadata); - PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, false); + PacketUtil.sendPacket(packetWrapper, Protocol1_8To1_9.class, true, false); } private void updateLocation() { @@ -195,7 +213,7 @@ private void updateLocation() { packetWrapper.write(Type.BYTE, (byte)0); packetWrapper.write(Type.BOOLEAN, false); - PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, false); + PacketUtil.sendPacket(packetWrapper, Protocol1_8To1_9.class, true, false); } private void updateMetadata() { @@ -208,14 +226,14 @@ private void updateMetadata() { packetWrapper.write(Types1_8.METADATA_LIST, metadata); - PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, false); + PacketUtil.sendPacket(packetWrapper, Protocol1_8To1_9.class, true, false); } private void despawnWither() { PacketWrapper packetWrapper = PacketWrapper.create(0x13, null, this.connection); packetWrapper.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[] {entityId}); - PacketUtil.sendPacket(packetWrapper, Protocol1_8TO1_9.class, true, false); + PacketUtil.sendPacket(packetWrapper, Protocol1_8To1_9.class, true, false); } public void setPlayerLocation(double posX, double posY, double posZ, float yaw, float pitch) { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java similarity index 67% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java index a68f55f7a..27a9f2287 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/EntityReplacement1_8to1_9.java @@ -1,14 +1,32 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.entityreplacement; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.replacement.EntityReplacement; +import com.viaversion.viarewind.utils.PacketUtil; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.replacement.EntityReplacement; -import de.gerrygames.viarewind.utils.PacketUtil; import java.util.ArrayList; import java.util.List; @@ -35,14 +53,14 @@ protected void sendTeleport(int entityId, double locX, double locY, double locZ, teleport.write(Type.BYTE, (byte) ((pitch / 360f) * 256)); teleport.write(Type.BOOLEAN, true); - PacketUtil.sendPacket(teleport, Protocol1_8TO1_9.class, true, true); + PacketUtil.sendPacket(teleport, Protocol1_8To1_9.class, true, true); } protected void sendHeadYaw(int entityId, float headYaw) { PacketWrapper head = PacketWrapper.create(ClientboundPackets1_8.ENTITY_HEAD_LOOK, null, user); head.write(Type.VAR_INT, entityId); head.write(Type.BYTE, (byte) ((headYaw / 360f) * 256)); - PacketUtil.sendPacket(head, Protocol1_8TO1_9.class, true, true); + PacketUtil.sendPacket(head, Protocol1_8To1_9.class, true, true); } protected void sendSpawn(int entityId, int type) { @@ -61,7 +79,7 @@ protected void sendSpawn(int entityId, int type) { List list = new ArrayList<>(); spawn.write(Types1_8.METADATA_LIST, list); - PacketUtil.sendPacket(spawn, Protocol1_8TO1_9.class, true, true); + PacketUtil.sendPacket(spawn, Protocol1_8To1_9.class, true, true); } protected void sendSpawnEntity(int entityId, int type) { @@ -75,6 +93,6 @@ protected void sendSpawnEntity(int entityId, int type) { spawn.write(Type.BYTE, (byte) 0); spawn.write(Type.INT, 0); - PacketUtil.sendPacket(spawn, Protocol1_8TO1_9.class, true, true); + PacketUtil.sendPacket(spawn, Protocol1_8To1_9.class, true, true); } } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java similarity index 64% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java index 36405be5a..f17a8af8a 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerBulletReplacement.java @@ -1,12 +1,30 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.entityreplacement; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.utils.PacketUtil; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.utils.PacketUtil; import java.util.ArrayList; import java.util.List; @@ -70,7 +88,7 @@ public void despawn() { PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_8.DESTROY_ENTITIES, null, user); despawn.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{entityId}); - PacketUtil.sendPacket(despawn, Protocol1_8TO1_9.class, true, true); + PacketUtil.sendPacket(despawn, Protocol1_8To1_9.class, true, true); } public int getEntityId() { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java similarity index 67% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java index 400ceec79..ec098e76c 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/entityreplacement/ShulkerReplacement.java @@ -1,5 +1,25 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.entityreplacement; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.utils.PacketUtil; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -8,10 +28,8 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.ClientboundPackets1_7; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter; import java.util.ArrayList; import java.util.List; @@ -74,7 +92,7 @@ public void updateMetadata() { metadataPacket.write(Types1_8.METADATA_LIST, metadataList); - PacketUtil.sendPacket(metadataPacket, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(metadataPacket, Protocol1_8To1_9.class); } @Override @@ -88,7 +106,7 @@ public void despawn() { PacketWrapper despawn = PacketWrapper.create(ClientboundPackets1_7.DESTROY_ENTITIES, null, user); despawn.write(Type.VAR_INT_ARRAY_PRIMITIVE, new int[]{entityId}); - PacketUtil.sendPacket(despawn, Protocol1_8TO1_9.class, true, true); + PacketUtil.sendPacket(despawn, Protocol1_8To1_9.class, true, true); } public int getEntityId() { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/items/ItemRewriter.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/items/ItemRewriter.java similarity index 91% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/items/ItemRewriter.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/items/ItemRewriter.java index a313ad0fa..b562dc780 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/items/ItemRewriter.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/items/ItemRewriter.java @@ -1,9 +1,27 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.items; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.items; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.libs.opennbt.tag.builtin.*; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.utils.Enchantments; +import com.viaversion.viarewind.utils.Enchantments; import java.lang.reflect.Field; import java.util.ArrayList; @@ -22,7 +40,7 @@ public class ItemRewriter { private static final Map POTION_NAME_INDEX = new HashMap<>(); static { - for (Field field : de.gerrygames.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter.class.getDeclaredFields()) { + for (Field field : ItemRewriter.class.getDeclaredFields()) { try { Field other = com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter.class.getDeclaredField(field.getName()); other.setAccessible(true); @@ -205,7 +223,7 @@ public static Item toClient(Item item) { for (int i = 0; i. + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.items; + +import com.viaversion.viarewind.replacement.Replacement; +import com.viaversion.viarewind.replacement.ReplacementRegistry; import com.viaversion.viaversion.api.minecraft.item.Item; -import de.gerrygames.viarewind.replacement.Replacement; -import de.gerrygames.viarewind.replacement.ReplacementRegistry; -import de.gerrygames.viarewind.storage.BlockState; +import com.viaversion.viarewind.storage.BlockState; public class ReplacementRegistry1_8to1_9 { private static final ReplacementRegistry registry = new ReplacementRegistry(); diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/metadata/MetaIndex1_8to1_9.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/metadata/MetaIndex1_8to1_9.java similarity index 57% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/metadata/MetaIndex1_8to1_9.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/metadata/MetaIndex1_8to1_9.java index d7326e134..054612d16 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/metadata/MetaIndex1_8to1_9.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/metadata/MetaIndex1_8to1_9.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.metadata; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetaIndex; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/metadata/MetadataRewriter.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/metadata/MetadataRewriter.java similarity index 77% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/metadata/MetadataRewriter.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/metadata/MetadataRewriter.java index 22660d40d..9de677e85 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/metadata/MetadataRewriter.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/metadata/MetadataRewriter.java @@ -1,15 +1,32 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.metadata; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter; import com.viaversion.viaversion.api.minecraft.EulerAngle; import com.viaversion.viaversion.api.minecraft.Vector; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_8; -import com.viaversion.viaversion.api.minecraft.metadata.types.MetaType1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.metadata.MetaIndex; -import de.gerrygames.viarewind.ViaRewind; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter; +import com.viaversion.viarewind.ViaRewind; import java.util.ArrayList; import java.util.List; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java similarity index 87% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java index 86b73d005..068e4a7db 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/EntityPackets.java @@ -1,5 +1,30 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.packets; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.packets; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.Cooldown; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.Levitation; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.PlayerPosition; +import com.viaversion.viarewind.replacement.EntityReplacement; import com.viaversion.viaversion.api.minecraft.Vector; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; @@ -14,23 +39,14 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9; import com.viaversion.viaversion.util.Pair; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.Cooldown; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.Levitation; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.PlayerPosition; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.util.RelativeMoveUtil; -import de.gerrygames.viarewind.replacement.EntityReplacement; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.util.RelativeMoveUtil; +import com.viaversion.viarewind.utils.PacketUtil; import java.util.ArrayList; import java.util.List; import java.util.UUID; -import static de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9.VALID_ATTRIBUTES; - public class EntityPackets { public static void register(Protocol { if (packetWrapper.isCancelled()) return; PlayerPosition position = packetWrapper.user().get(PlayerPosition.class); @@ -343,7 +359,7 @@ public void register() { detach.write(Type.INT, passenger); detach.write(Type.INT, -1); detach.write(Type.BOOLEAN, false); - PacketUtil.sendPacket(detach, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(detach, Protocol1_8To1_9.class); } } for (int i = 0; i < count; i++) { @@ -353,7 +369,7 @@ public void register() { attach.write(Type.INT, p); attach.write(Type.INT, v); attach.write(Type.BOOLEAN, false); - PacketUtil.sendPacket(attach, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(attach, Protocol1_8To1_9.class); } }); } @@ -366,9 +382,9 @@ public void register() { @Override public void register() { map(Type.VAR_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); map(Type.BYTE); map(Type.BYTE); map(Type.BOOLEAN); @@ -418,7 +434,7 @@ public void register() { int removed = 0; for (int i = 0; i < size; i++) { String key = packetWrapper.read(Type.STRING); - boolean skip = !VALID_ATTRIBUTES.contains(key); + boolean skip = !Protocol1_8To1_9.VALID_ATTRIBUTES.contains(key); double value = packetWrapper.read(Type.DOUBLE); int modifiersize = packetWrapper.read(Type.VAR_INT); if (!skip) { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/InventoryPackets.java similarity index 86% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/InventoryPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/InventoryPackets.java index 0e11e5497..53394cbe3 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/InventoryPackets.java @@ -1,5 +1,24 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.packets; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.Windows; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; @@ -9,8 +28,7 @@ import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.Windows; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter; public class InventoryPackets { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/PlayerPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/PlayerPackets.java similarity index 90% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/PlayerPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/PlayerPackets.java index 2eed455fc..6077b2fd9 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/PlayerPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/PlayerPackets.java @@ -1,5 +1,27 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.packets; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.packets; + +import com.viaversion.viarewind.ViaRewind; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.*; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.*; import com.viaversion.viaversion.api.minecraft.Position; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.item.Item; @@ -18,12 +40,9 @@ import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9; -import de.gerrygames.viarewind.ViaRewind; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.*; -import de.gerrygames.viarewind.utils.ChatUtil; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.items.ItemRewriter; +import com.viaversion.viarewind.utils.ChatUtil; +import com.viaversion.viarewind.utils.PacketUtil; import java.util.ArrayList; import java.util.UUID; @@ -251,7 +270,7 @@ public void register() { swapItems.write(Type.POSITION, new Position(0, 0, 0)); swapItems.write(Type.BYTE, (byte) 255); - PacketUtil.sendToServer(swapItems, Protocol1_8TO1_9.class, true, true); + PacketUtil.sendToServer(swapItems, Protocol1_8To1_9.class, true, true); } }); } @@ -287,8 +306,8 @@ public void register() { handler(packetWrapper -> { //Sending any queued animations. PacketWrapper animation = null; - while((animation = ((Protocol1_8TO1_9)protocol).animationsToSend.poll()) != null) { - PacketUtil.sendToServer(animation, Protocol1_8TO1_9.class, true, true); + while((animation = ((Protocol1_8To1_9)protocol).animationsToSend.poll()) != null) { + PacketUtil.sendToServer(animation, Protocol1_8To1_9.class, true, true); } EntityTracker tracker = packetWrapper.user().get(EntityTracker.class); @@ -309,8 +328,8 @@ public void register() { handler(packetWrapper -> { //Sending any queued animations. PacketWrapper animation = null; - while((animation = ((Protocol1_8TO1_9)protocol).animationsToSend.poll()) != null) { - PacketUtil.sendToServer(animation, Protocol1_8TO1_9.class, + while((animation = ((Protocol1_8To1_9)protocol).animationsToSend.poll()) != null) { + PacketUtil.sendToServer(animation, Protocol1_8To1_9.class, true, true); } @@ -334,8 +353,8 @@ public void register() { handler(packetWrapper -> { //Sending any queued animations. PacketWrapper animation = null; - while((animation = ((Protocol1_8TO1_9)protocol).animationsToSend.poll()) != null) { - PacketUtil.sendToServer(animation, Protocol1_8TO1_9.class, true, true); + while((animation = ((Protocol1_8To1_9)protocol).animationsToSend.poll()) != null) { + PacketUtil.sendToServer(animation, Protocol1_8To1_9.class, true, true); } PlayerPosition pos = packetWrapper.user().get(PlayerPosition.class); @@ -361,8 +380,8 @@ public void register() { handler(packetWrapper -> { //Sending any queued animations. PacketWrapper animation = null; - while((animation = ((Protocol1_8TO1_9)protocol).animationsToSend.poll()) != null) { - PacketUtil.sendToServer(animation, Protocol1_8TO1_9.class, true, true); + while((animation = ((Protocol1_8To1_9)protocol).animationsToSend.poll()) != null) { + PacketUtil.sendToServer(animation, Protocol1_8To1_9.class, true, true); } double x = packetWrapper.get(Type.DOUBLE, 0); @@ -379,7 +398,7 @@ public void register() { PacketWrapper confirmTeleport = packetWrapper.create(0x00); confirmTeleport.write(Type.VAR_INT, pos.getConfirmId()); PacketUtil.sendToServer(confirmTeleport, - Protocol1_8TO1_9.class, true, true); + Protocol1_8To1_9.class, true, true); pos.setConfirmId(-1); } @@ -436,7 +455,7 @@ public void register() { PacketWrapper useItem = PacketWrapper.create(0x1D, null, packetWrapper.user()); useItem.write(Type.VAR_INT, 0); - PacketUtil.sendToServer(useItem, Protocol1_8TO1_9.class, true, true); + PacketUtil.sendToServer(useItem, Protocol1_8To1_9.class, true, true); } }); handler(packetWrapper -> { @@ -474,7 +493,7 @@ public void register() { null, packetWrapper.user()); delayedPacket.write(Type.VAR_INT, 0); //Main Hand - ((Protocol1_8TO1_9)protocol).animationsToSend.add(delayedPacket); + ((Protocol1_8To1_9)protocol).animationsToSend.add(delayedPacket); }); handler(packetWrapper -> { packetWrapper.user().get(BlockPlaceDestroyTracker.class).updateMining(); @@ -501,7 +520,7 @@ public void register() { elytra.write(Type.VAR_INT, packetWrapper.get(Type.VAR_INT, 0)); elytra.write(Type.VAR_INT, 8); elytra.write(Type.VAR_INT, 0); - PacketUtil.sendToServer(elytra, Protocol1_8TO1_9.class, true, false); + PacketUtil.sendToServer(elytra, Protocol1_8To1_9.class, true, false); } } }); @@ -525,7 +544,7 @@ public void register() { float forward = packetWrapper.get(Type.FLOAT, 1); steerBoat.write(Type.BOOLEAN, forward != 0.0f || left < 0.0f); steerBoat.write(Type.BOOLEAN, forward != 0.0f || left > 0.0f); - PacketUtil.sendToServer(steerBoat, Protocol1_8TO1_9.class); + PacketUtil.sendToServer(steerBoat, Protocol1_8To1_9.class); } }); } @@ -577,7 +596,7 @@ public void register() { updateSkin.write(Types1_8.METADATA_LIST, metadata); - PacketUtil.sendPacket(updateSkin, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(updateSkin, Protocol1_8To1_9.class); }); } }); diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/ScoreboardPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/ScoreboardPackets.java similarity index 65% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/ScoreboardPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/ScoreboardPackets.java index d751a02b7..09502d3f1 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/ScoreboardPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/ScoreboardPackets.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.packets; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java similarity index 78% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java index 1dba98a27..7d18dc6b9 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/SpawnPackets.java @@ -1,5 +1,31 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.packets; + +import com.viaversion.viarewind.replacement.EntityReplacement; +import com.viaversion.viarewind.replacement.Replacement; +import com.viaversion.viarewind.ViaRewind; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement.ShulkerBulletReplacement; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.entityreplacement.ShulkerReplacement; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker; import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; import com.viaversion.viaversion.api.minecraft.metadata.Metadata; import com.viaversion.viaversion.api.protocol.Protocol; @@ -12,16 +38,8 @@ import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9; -import de.gerrygames.viarewind.ViaRewind; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.entityreplacement.ShulkerBulletReplacement; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.entityreplacement.ShulkerReplacement; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.items.ReplacementRegistry1_8to1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker; -import de.gerrygames.viarewind.replacement.EntityReplacement; -import de.gerrygames.viarewind.replacement.Replacement; -import de.gerrygames.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.items.ReplacementRegistry1_8to1_9; +import com.viaversion.viarewind.utils.PacketUtil; import java.util.List; @@ -38,9 +56,9 @@ public void register() { map(Type.VAR_INT); map(Type.UUID, Type.NOTHING); map(Type.BYTE); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); map(Type.BYTE); map(Type.BYTE); map(Type.INT); @@ -109,7 +127,7 @@ public void register() { velocityPacket.write(Type.SHORT, vX); velocityPacket.write(Type.SHORT, vY); velocityPacket.write(Type.SHORT, vZ); - PacketUtil.sendPacket(velocityPacket, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(velocityPacket, Protocol1_8To1_9.class); } tracker.getClientEntityTypes().put(entityId, type); @@ -123,9 +141,9 @@ public void register() { @Override public void register() { map(Type.VAR_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); map(Type.SHORT); handler(packetWrapper -> { int entityId = packetWrapper.get(Type.VAR_INT, 0); @@ -142,9 +160,9 @@ public void register() { public void register() { map(Type.VAR_INT); map(Type.BYTE); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); handler(packetWrapper -> { int entityId = packetWrapper.get(Type.VAR_INT, 0); EntityTracker tracker = packetWrapper.user().get(EntityTracker.class); @@ -161,9 +179,9 @@ public void register() { map(Type.VAR_INT); map(Type.UUID, Type.NOTHING); map(Type.UNSIGNED_BYTE); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); map(Type.BYTE); map(Type.BYTE); map(Type.BYTE); @@ -240,9 +258,9 @@ public void register() { public void register() { map(Type.VAR_INT); map(Type.UUID); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); - map(Type.DOUBLE, Protocol1_8TO1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); + map(Type.DOUBLE, Protocol1_8To1_9.TO_OLD_INT); map(Type.BYTE); map(Type.BYTE); handler(packetWrapper -> packetWrapper.write(Type.SHORT, (short) 0)); diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/WorldPackets.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/WorldPackets.java similarity index 88% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/WorldPackets.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/WorldPackets.java index 89de80d97..c6698e343 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/packets/WorldPackets.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/packets/WorldPackets.java @@ -1,5 +1,29 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.packets; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.packets; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.items.ReplacementRegistry1_8to1_9; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.sound.Effect; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.sound.SoundRemapper; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.ViaRewind; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.BlockChangeRecord; import com.viaversion.viaversion.api.minecraft.Environment; @@ -23,19 +47,13 @@ import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ServerboundPackets1_9; import com.viaversion.viaversion.protocols.protocol1_9to1_8.types.Chunk1_8Type; -import de.gerrygames.viarewind.ViaRewind; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.items.ReplacementRegistry1_8to1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.sound.Effect; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.sound.SoundRemapper; -import de.gerrygames.viarewind.utils.PacketUtil; import java.util.ArrayList; public class WorldPackets { public static void register(Protocol protocol) { + ServerboundPackets1_9, ServerboundPackets1_8> protocol) { /* OUTGOING */ //Block Break Animation @@ -236,7 +254,7 @@ public void register() { updateTileEntity.write(Type.UNSIGNED_BYTE, action); updateTileEntity.write(Type.NBT, nbt); - PacketUtil.sendPacket(updateTileEntity, Protocol1_8TO1_9.class, false, false); + PacketUtil.sendPacket(updateTileEntity, Protocol1_8To1_9.class, false, false); }); }); } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/sound/Effect.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/sound/Effect.java similarity index 58% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/sound/Effect.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/sound/Effect.java index 8f37d3143..9a5d46e56 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/sound/Effect.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/sound/Effect.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.sound; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.sound; import java.util.HashMap; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/sound/SoundRemapper.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/sound/SoundRemapper.java similarity index 98% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/sound/SoundRemapper.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/sound/SoundRemapper.java index 78826d1e9..dd58ab6a8 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/sound/SoundRemapper.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/sound/SoundRemapper.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.sound; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.sound; import java.util.HashMap; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/BlockPlaceDestroyTracker.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/BlockPlaceDestroyTracker.java similarity index 53% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/BlockPlaceDestroyTracker.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/BlockPlaceDestroyTracker.java index 563495768..ebcc682b2 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/BlockPlaceDestroyTracker.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/BlockPlaceDestroyTracker.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.storage; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/BossBarStorage.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/BossBarStorage.java similarity index 64% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/BossBarStorage.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/BossBarStorage.java index db67331f9..ec0b8bbb0 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/BossBarStorage.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/BossBarStorage.java @@ -1,8 +1,26 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.storage; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.bossbar.WitherBossBar; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.bossbar.WitherBossBar; import java.util.HashMap; import java.util.Map; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Cooldown.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Cooldown.java similarity index 79% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Cooldown.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Cooldown.java index fd9167997..147555609 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Cooldown.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Cooldown.java @@ -1,5 +1,27 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.storage; + +import com.viaversion.viarewind.api.ViaRewindConfig; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.utils.Tickable; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; @@ -8,11 +30,7 @@ import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9; import com.viaversion.viaversion.util.Pair; -import de.gerrygames.viarewind.ViaRewind; -import de.gerrygames.viarewind.api.ViaRewindConfig; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.utils.PacketUtil; -import de.gerrygames.viarewind.utils.Tickable; +import com.viaversion.viarewind.ViaRewind; import java.util.ArrayList; import java.util.UUID; @@ -88,7 +106,7 @@ private void hideBossBar() { PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.BOSSBAR, null, getUser()); wrapper.write(Type.UUID, bossUUID); wrapper.write(Type.VAR_INT, 1); - PacketUtil.sendPacket(wrapper, Protocol1_8TO1_9.class, false, true); + PacketUtil.sendPacket(wrapper, Protocol1_8To1_9.class, false, true); bossUUID = null; } @@ -108,13 +126,13 @@ private void sendBossBar(float cooldown) { wrapper.write(Type.VAR_INT, 2); wrapper.write(Type.FLOAT, cooldown); } - PacketUtil.sendPacket(wrapper, Protocol1_8TO1_9.class, false, true); + PacketUtil.sendPacket(wrapper, Protocol1_8To1_9.class, false, true); } private void hideTitle() { PacketWrapper hide = PacketWrapper.create(ClientboundPackets1_8.TITLE, null, getUser()); hide.write(Type.VAR_INT, 3); - PacketUtil.sendPacket(hide, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(hide, Protocol1_8To1_9.class); } private void sendTitle(String title, String subTitle, int fadeIn, int stay, int fadeOut) { @@ -130,9 +148,9 @@ private void sendTitle(String title, String subTitle, int fadeIn, int stay, int subtitlePacket.write(Type.VAR_INT, 1); subtitlePacket.write(Type.COMPONENT, new JsonPrimitive(subTitle)); - PacketUtil.sendPacket(titlePacket, Protocol1_8TO1_9.class); - PacketUtil.sendPacket(subtitlePacket, Protocol1_8TO1_9.class); - PacketUtil.sendPacket(timePacket, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(titlePacket, Protocol1_8To1_9.class); + PacketUtil.sendPacket(subtitlePacket, Protocol1_8To1_9.class); + PacketUtil.sendPacket(timePacket, Protocol1_8To1_9.class); } private void sendActionBar(String bar) { @@ -140,7 +158,7 @@ private void sendActionBar(String bar) { actionBarPacket.write(Type.COMPONENT, new JsonPrimitive(bar)); actionBarPacket.write(Type.BYTE, (byte) 2); - PacketUtil.sendPacket(actionBarPacket, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(actionBarPacket, Protocol1_8To1_9.class); } public boolean hasCooldown() { diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java similarity index 82% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java index 3134f19ee..f2d79bc06 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/EntityTracker.java @@ -1,5 +1,26 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage; - +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.storage; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter; +import com.viaversion.viarewind.replacement.EntityReplacement; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.data.entity.ClientEntityIdChangeListener; @@ -10,9 +31,6 @@ import com.viaversion.viaversion.api.type.Type; import com.viaversion.viaversion.api.type.types.version.Types1_8; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.metadata.MetadataRewriter; -import de.gerrygames.viarewind.replacement.EntityReplacement; import java.util.ArrayList; import java.util.List; @@ -146,7 +164,7 @@ public void sendMetadataBuffer(int entityId) { MetadataRewriter.transform(this.getClientEntityTypes().get(entityId), this.metadataBuffer.get(entityId)); if (!this.metadataBuffer.get(entityId).isEmpty()) { try { - wrapper.send(Protocol1_8TO1_9.class); + wrapper.send(Protocol1_8To1_9.class); } catch (Exception ex) { ex.printStackTrace(); } diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Levitation.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Levitation.java new file mode 100644 index 000000000..a2a29e88e --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Levitation.java @@ -0,0 +1,59 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.storage; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.utils.PacketUtil; +import com.viaversion.viarewind.utils.Tickable; +import com.viaversion.viaversion.api.connection.StoredObject; +import com.viaversion.viaversion.api.connection.UserConnection; +import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; +import com.viaversion.viaversion.api.type.Type; + +public class Levitation extends StoredObject implements Tickable { + private int amplifier; + private volatile boolean active = false; + + public Levitation(UserConnection user) { + super(user); + } + + @Override + public void tick() { + if (!active) { + return; + } + + int vY = (amplifier+1) * 360; + PacketWrapper packet = PacketWrapper.create(0x12, null, Levitation.this.getUser()); + packet.write(Type.VAR_INT, getUser().get(EntityTracker.class).getPlayerId()); + packet.write(Type.SHORT, (short)0); + packet.write(Type.SHORT, (short)vY); + packet.write(Type.SHORT, (short)0); + PacketUtil.sendPacket(packet, Protocol1_8To1_9.class); + } + + public void setActive(boolean active) { + this.active = active; + } + + public void setAmplifier(int amplifier) { + this.amplifier = amplifier; + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/PlayerPosition.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/PlayerPosition.java similarity index 78% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/PlayerPosition.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/PlayerPosition.java index 4103b172d..e1ba72a7c 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/PlayerPosition.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/PlayerPosition.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.protocol.protocol1_8to1_9.storage; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Windows.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Windows.java similarity index 70% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Windows.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Windows.java index 96feab88c..b1d58752b 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Windows.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/storage/Windows.java @@ -1,5 +1,25 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.storage; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.Protocol1_8To1_9; +import com.viaversion.viarewind.utils.PacketUtil; import com.viaversion.viaversion.api.connection.StoredObject; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.item.DataItem; @@ -10,8 +30,6 @@ import com.viaversion.viaversion.libs.kyori.adventure.text.format.NamedTextColor; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.utils.PacketUtil; import java.util.HashMap; @@ -58,7 +76,7 @@ public static void updateBrewingStand(UserConnection user, Item blazePowder, sho .append(Component.translatable("item.blazePowder.name", NamedTextColor.DARK_RED)); openWindow.write(Type.COMPONENT, GsonComponentSerializer.colorDownsamplingGson().serializeToTree(title)); openWindow.write(Type.UNSIGNED_BYTE, (short) 420); - PacketUtil.sendPacket(openWindow, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(openWindow, Protocol1_8To1_9.class); Item[] items = user.get(Windows.class).getBrewingItems(windowId); for (int i = 0; i < items.length; i++) { @@ -66,7 +84,7 @@ public static void updateBrewingStand(UserConnection user, Item blazePowder, sho setSlot.write(Type.UNSIGNED_BYTE, windowId); setSlot.write(Type.SHORT, (short) i); setSlot.write(Type.ITEM, items[i]); - PacketUtil.sendPacket(setSlot, Protocol1_8TO1_9.class); + PacketUtil.sendPacket(setSlot, Protocol1_8To1_9.class); } } } diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/util/RelativeMoveUtil.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/util/RelativeMoveUtil.java similarity index 70% rename from core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/util/RelativeMoveUtil.java rename to common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/util/RelativeMoveUtil.java index 0f5ea0804..0af5218d0 100644 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/util/RelativeMoveUtil.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_8to1_9/util/RelativeMoveUtil.java @@ -1,8 +1,26 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.util; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.protocol.protocol1_8to1_9.util; + +import com.viaversion.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker; import com.viaversion.viaversion.api.connection.UserConnection; import com.viaversion.viaversion.api.minecraft.Vector; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage.EntityTracker; public class RelativeMoveUtil { diff --git a/common/src/main/java/com/viaversion/viarewind/replacement/EntityReplacement.java b/common/src/main/java/com/viaversion/viarewind/replacement/EntityReplacement.java new file mode 100644 index 000000000..aa403dd6b --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/replacement/EntityReplacement.java @@ -0,0 +1,42 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.replacement; + +import com.viaversion.viaversion.api.minecraft.metadata.Metadata; + +import java.util.List; + +public interface EntityReplacement { + + int getEntityId(); + + void setLocation(double x, double y, double z); + + void relMove(double x, double y, double z); + + void setYawPitch(float yaw, float pitch); + + void setHeadYaw(float yaw); + + void spawn(); + + void despawn(); + + void updateMetadata(List metadataList); +} diff --git a/core/src/main/java/de/gerrygames/viarewind/replacement/Replacement.java b/common/src/main/java/com/viaversion/viarewind/replacement/Replacement.java similarity index 66% rename from core/src/main/java/de/gerrygames/viarewind/replacement/Replacement.java rename to common/src/main/java/com/viaversion/viarewind/replacement/Replacement.java index 05c4a0ccd..f5b39908e 100644 --- a/core/src/main/java/de/gerrygames/viarewind/replacement/Replacement.java +++ b/common/src/main/java/com/viaversion/viarewind/replacement/Replacement.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.replacement; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.replacement; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.libs.opennbt.tag.builtin.CompoundTag; diff --git a/core/src/main/java/de/gerrygames/viarewind/replacement/ReplacementRegistry.java b/common/src/main/java/com/viaversion/viarewind/replacement/ReplacementRegistry.java similarity index 68% rename from core/src/main/java/de/gerrygames/viarewind/replacement/ReplacementRegistry.java rename to common/src/main/java/com/viaversion/viarewind/replacement/ReplacementRegistry.java index c537ff683..290f6245c 100644 --- a/core/src/main/java/de/gerrygames/viarewind/replacement/ReplacementRegistry.java +++ b/common/src/main/java/com/viaversion/viarewind/replacement/ReplacementRegistry.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.replacement; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.replacement; import com.viaversion.viaversion.api.minecraft.item.Item; import com.viaversion.viaversion.libs.fastutil.ints.Int2ObjectMap; @@ -8,7 +26,6 @@ public class ReplacementRegistry { private final Int2ObjectMap itemReplacements = new Int2ObjectOpenHashMap<>(); private final Int2ObjectMap blockReplacements = new Int2ObjectOpenHashMap<>(); - public void registerItem(int id, Replacement replacement) { registerItem(id, -1, replacement); } diff --git a/common/src/main/java/com/viaversion/viarewind/storage/BlockState.java b/common/src/main/java/com/viaversion/viarewind/storage/BlockState.java new file mode 100644 index 000000000..351c48886 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/storage/BlockState.java @@ -0,0 +1,35 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.storage; + +public class BlockState { + + public static int extractId(int raw) { + return raw >> 4; + } + + public static int extractData(int raw) { + return raw & 0xF; + } + + public static int stateToRaw(int id, int data) { + return (id << 4) | (data & 0xF); + } + +} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/ChatUtil.java b/common/src/main/java/com/viaversion/viarewind/utils/ChatUtil.java similarity index 78% rename from core/src/main/java/de/gerrygames/viarewind/utils/ChatUtil.java rename to common/src/main/java/com/viaversion/viarewind/utils/ChatUtil.java index 1d3724413..ce859af53 100644 --- a/core/src/main/java/de/gerrygames/viarewind/utils/ChatUtil.java +++ b/common/src/main/java/com/viaversion/viarewind/utils/ChatUtil.java @@ -1,16 +1,33 @@ -package de.gerrygames.viarewind.utils; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.utils; + +import com.viaversion.viarewind.ViaRewind; import com.viaversion.viaversion.api.protocol.packet.ClientboundPacketType; import com.viaversion.viaversion.libs.gson.JsonElement; import com.viaversion.viaversion.libs.gson.JsonObject; import com.viaversion.viaversion.libs.gson.JsonParser; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.gson.GsonComponentSerializer; import com.viaversion.viaversion.libs.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -import com.viaversion.viaversion.protocols.protocol1_12to1_11_1.data.AchievementTranslationMapping; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ChatRewriter; import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.Protocol1_13To1_12_2; import com.viaversion.viaversion.rewriter.ComponentRewriter; -import de.gerrygames.viarewind.ViaRewind; import java.util.logging.Level; import java.util.regex.Pattern; diff --git a/common/src/main/java/com/viaversion/viarewind/utils/Enchantments.java b/common/src/main/java/com/viaversion/viarewind/utils/Enchantments.java new file mode 100644 index 000000000..946ba91c6 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/utils/Enchantments.java @@ -0,0 +1,39 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.utils; + +import java.util.HashMap; +import java.util.Map; + +public class Enchantments { + public static final Map ENCHANTMENTS = new HashMap<>(); + + static { + ENCHANTMENTS.put((short) 1, "I"); + ENCHANTMENTS.put((short) 2, "II"); + ENCHANTMENTS.put((short) 3, "III"); + ENCHANTMENTS.put((short) 4, "IV"); + ENCHANTMENTS.put((short) 5, "V"); + ENCHANTMENTS.put((short) 6, "VI"); + ENCHANTMENTS.put((short) 7, "VII"); + ENCHANTMENTS.put((short) 8, "VIII"); + ENCHANTMENTS.put((short) 9, "IX"); + ENCHANTMENTS.put((short) 10, "X"); + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/PacketUtil.java b/common/src/main/java/com/viaversion/viarewind/utils/PacketUtil.java similarity index 69% rename from core/src/main/java/de/gerrygames/viarewind/utils/PacketUtil.java rename to common/src/main/java/com/viaversion/viarewind/utils/PacketUtil.java index 11f984f3b..94bd1a51d 100644 --- a/core/src/main/java/de/gerrygames/viarewind/utils/PacketUtil.java +++ b/common/src/main/java/com/viaversion/viarewind/utils/PacketUtil.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.utils; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.utils; import com.viaversion.viaversion.api.protocol.Protocol; import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; diff --git a/common/src/main/java/com/viaversion/viarewind/utils/Tickable.java b/common/src/main/java/com/viaversion/viarewind/utils/Tickable.java new file mode 100644 index 000000000..d68fc5b27 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/utils/Tickable.java @@ -0,0 +1,23 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.utils; + +public interface Tickable { + void tick(); +} diff --git a/common/src/main/java/com/viaversion/viarewind/utils/Ticker.java b/common/src/main/java/com/viaversion/viarewind/utils/Ticker.java new file mode 100644 index 000000000..250678820 --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/utils/Ticker.java @@ -0,0 +1,40 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.utils; + +import com.viaversion.viaversion.api.Via; + +public class Ticker { + private static boolean init = false; + + public static void init() { + if (init) return; + synchronized (Ticker.class) { + if (init) return; + init = true; + } + Via.getPlatform().runRepeatingSync(() -> + Via.getManager().getConnectionManager().getConnections().forEach(user -> + user.getStoredObjects().values().stream() + .filter(Tickable.class::isInstance) + .map(Tickable.class::cast) + .forEach(Tickable::tick) + ), 1L); + } +} diff --git a/common/src/main/java/com/viaversion/viarewind/utils/math/AABB.java b/common/src/main/java/com/viaversion/viarewind/utils/math/AABB.java new file mode 100644 index 000000000..6b9af5daf --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/utils/math/AABB.java @@ -0,0 +1,37 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.utils.math; + +public class AABB { + Vector3d min; + Vector3d max; + + public AABB(Vector3d min, Vector3d max) { + this.min = min; + this.max = max; + } + + public Vector3d getMin() { + return this.min; + } + + public Vector3d getMax() { + return this.max; + } +} diff --git a/common/src/main/java/com/viaversion/viarewind/utils/math/Ray3d.java b/common/src/main/java/com/viaversion/viarewind/utils/math/Ray3d.java new file mode 100644 index 000000000..ebc94fcfd --- /dev/null +++ b/common/src/main/java/com/viaversion/viarewind/utils/math/Ray3d.java @@ -0,0 +1,37 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.utils.math; + +public class Ray3d { + Vector3d start; + Vector3d dir; + + public Ray3d(Vector3d start, Vector3d dir) { + this.start = start; + this.dir = dir; + } + + public Vector3d getStart() { + return this.start; + } + + public Vector3d getDir() { + return this.dir; + } +} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/math/RayTracing.java b/common/src/main/java/com/viaversion/viarewind/utils/math/RayTracing.java similarity index 59% rename from core/src/main/java/de/gerrygames/viarewind/utils/math/RayTracing.java rename to common/src/main/java/com/viaversion/viarewind/utils/math/RayTracing.java index 8f718c804..9f0146bcf 100644 --- a/core/src/main/java/de/gerrygames/viarewind/utils/math/RayTracing.java +++ b/common/src/main/java/com/viaversion/viarewind/utils/math/RayTracing.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.utils.math; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.utils.math; public class RayTracing { diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/math/Vector3d.java b/common/src/main/java/com/viaversion/viarewind/utils/math/Vector3d.java similarity index 68% rename from core/src/main/java/de/gerrygames/viarewind/utils/math/Vector3d.java rename to common/src/main/java/com/viaversion/viarewind/utils/math/Vector3d.java index 0cec37f8d..2ff10dbd5 100644 --- a/core/src/main/java/de/gerrygames/viarewind/utils/math/Vector3d.java +++ b/common/src/main/java/com/viaversion/viarewind/utils/math/Vector3d.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind.utils.math; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind.utils.math; import java.util.Objects; diff --git a/common/src/main/resources/assets/viarewind/config.yml b/common/src/main/resources/assets/viarewind/config.yml new file mode 100644 index 000000000..aa802dff6 --- /dev/null +++ b/common/src/main/resources/assets/viarewind/config.yml @@ -0,0 +1,22 @@ +# If you need help, you can join our Discord - https://viaversion.com/discord +# +# Specifies how 1.8.x clients should see the cooldown indicator +# You can choose between TITLE, ACTION_BAR, BOSS_BAR and DISABLED +# ONLY DISABLE IF YOU HAVE 1.9 COOLDOWN DISABLED ON YOUR SERVER +# 1.8 PLAYERS MAY ASK WHY PVP IS NOT WORKING OTHERWISE +cooldown-indicator: 'TITLE' +# +# Replaces Adventure mode with Survival mode for 1.7.x clients +# Enable this option if your server is using the 'CanDestroy' +# or 'CanPlaceOn' flags on items +replace-adventure: false +# +# Whether 1.9 particles should be replaced by similar ones in +# 1.8 and lower +replace-particles: false +# +# Max amount of pages for written books before a client gets kicked +max-book-pages: 100 +# +# Max amount of characters in the json (!) string of a book page before a client gets kicked +max-book-page-length: 5000 \ No newline at end of file diff --git a/core/pom.xml b/core/pom.xml deleted file mode 100644 index 391c4c74c..000000000 --- a/core/pom.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - 4.0.0 - - - com.viaversion - viarewind-parent - 2.0.4-SNAPSHOT - - - viarewind-core - - - - - - io.netty - netty-all - 4.0.20.Final - provided - true - - - - - - - . - true - src/main/resources/ - - ** - - - - - - diff --git a/core/src/main/java/de/gerrygames/viarewind/ViaRewind.java b/core/src/main/java/de/gerrygames/viarewind/ViaRewind.java deleted file mode 100644 index 15c2a5b7e..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/ViaRewind.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.gerrygames.viarewind; - -import de.gerrygames.viarewind.api.ViaRewindConfig; -import de.gerrygames.viarewind.api.ViaRewindPlatform; - -public class ViaRewind { - private static ViaRewindPlatform platform; - private static ViaRewindConfig config; - - public static void init(ViaRewindPlatform platform, ViaRewindConfig config) { - ViaRewind.platform = platform; - ViaRewind.config = config; - } - - public static ViaRewindPlatform getPlatform() { - return ViaRewind.platform; - } - - public static ViaRewindConfig getConfig() { - return ViaRewind.config; - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/api/ViaRewindConfig.java b/core/src/main/java/de/gerrygames/viarewind/api/ViaRewindConfig.java deleted file mode 100644 index a3864e593..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/api/ViaRewindConfig.java +++ /dev/null @@ -1,18 +0,0 @@ -package de.gerrygames.viarewind.api; - -public interface ViaRewindConfig { - - enum CooldownIndicator { - TITLE, ACTION_BAR, BOSS_BAR, DISABLED - } - - CooldownIndicator getCooldownIndicator(); - - boolean isReplaceAdventureMode(); - - boolean isReplaceParticles(); - - int getMaxBookPages(); - - int getMaxBookPageSize(); -} diff --git a/core/src/main/java/de/gerrygames/viarewind/api/ViaRewindPlatform.java b/core/src/main/java/de/gerrygames/viarewind/api/ViaRewindPlatform.java deleted file mode 100644 index bb3dd3ee2..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/api/ViaRewindPlatform.java +++ /dev/null @@ -1,25 +0,0 @@ -package de.gerrygames.viarewind.api; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import de.gerrygames.viarewind.ViaRewind; -import de.gerrygames.viarewind.protocol.protocol1_7_0_5to1_7_6_10.Protocol1_7_0_5to1_7_6_10; -import de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.Protocol1_7_6_10TO1_8; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; - -import java.util.logging.Logger; - -public interface ViaRewindPlatform { - default void init(ViaRewindConfig config) { - ViaRewind.init(this, config); - - String version = ViaRewind.class.getPackage().getImplementationVersion(); - Via.getManager().getSubPlatforms().add(version != null ? version : "UNKNOWN"); - - Via.getManager().getProtocolManager().registerProtocol(new Protocol1_8TO1_9(), ProtocolVersion.v1_8, ProtocolVersion.v1_9); - Via.getManager().getProtocolManager().registerProtocol(new Protocol1_7_6_10TO1_8(), ProtocolVersion.v1_7_6, ProtocolVersion.v1_8); - Via.getManager().getProtocolManager().registerProtocol(new Protocol1_7_0_5to1_7_6_10(), ProtocolVersion.v1_7_1, ProtocolVersion.v1_7_6); - } - - Logger getLogger(); -} diff --git a/core/src/main/java/de/gerrygames/viarewind/netty/EmptyChannelHandler.java b/core/src/main/java/de/gerrygames/viarewind/netty/EmptyChannelHandler.java deleted file mode 100644 index f544619bb..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/netty/EmptyChannelHandler.java +++ /dev/null @@ -1,8 +0,0 @@ -package de.gerrygames.viarewind.netty; - -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerAdapter; - -@ChannelHandler.Sharable -public class EmptyChannelHandler extends ChannelHandlerAdapter { -} diff --git a/core/src/main/java/de/gerrygames/viarewind/netty/ForwardMessageToByteEncoder.java b/core/src/main/java/de/gerrygames/viarewind/netty/ForwardMessageToByteEncoder.java deleted file mode 100644 index 12fcdef1a..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/netty/ForwardMessageToByteEncoder.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.gerrygames.viarewind.netty; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToByteEncoder; - -public class ForwardMessageToByteEncoder extends MessageToByteEncoder { - @Override - protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception { - out.writeBytes(msg); - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetaIndex1_7_6_10to1_8.java b/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetaIndex1_7_6_10to1_8.java deleted file mode 100644 index 4c1ebf310..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetaIndex1_7_6_10to1_8.java +++ /dev/null @@ -1,42 +0,0 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.metadata; - -import com.viaversion.viaversion.api.minecraft.entities.Entity1_10Types; -import com.viaversion.viaversion.util.Pair; -import de.gerrygames.viarewind.protocol.protocol1_8to1_7_6_10.metadata.MetaIndex1_8to1_7_6_10; - -import java.util.HashMap; -import java.util.Optional; - -public class MetaIndex1_7_6_10to1_8 { - - private static final HashMap, MetaIndex1_8to1_7_6_10> metadataRewrites = new HashMap<>(); - - static { - for (MetaIndex1_8to1_7_6_10 index : MetaIndex1_8to1_7_6_10.values()) - metadataRewrites.put(new Pair<>(index.getClazz(), index.getNewIndex()), index); - } - - private static Optional getIndex(Entity1_10Types.EntityType type, int index) { - Pair pair = new Pair<>(type, index); - if (metadataRewrites.containsKey(pair)) { - return Optional.of(metadataRewrites.get(pair)); - } - - return Optional.empty(); - } - - public static MetaIndex1_8to1_7_6_10 searchIndex(Entity1_10Types.EntityType type, int index) { - Entity1_10Types.EntityType currentType = type; - do { - Optional optMeta = getIndex(currentType, index); - - if (optMeta.isPresent()) { - return optMeta.get(); - } - - currentType = currentType.getParent(); - } while (currentType != null); - - return null; - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java b/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java deleted file mode 100644 index 7f3bcb4fc..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/storage/CompressionSendStorage.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.storage; - -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; - -public class CompressionSendStorage extends StoredObject { - private boolean removeCompression = false; - - public CompressionSendStorage(UserConnection user) { - super(user); - } - - public boolean isRemoveCompression() { - return removeCompression; - } - - public void setRemoveCompression(boolean removeCompression) { - this.removeCompression = removeCompression; - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java b/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java deleted file mode 100644 index 3b0f0141f..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java +++ /dev/null @@ -1,28 +0,0 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; - -import com.viaversion.viaversion.api.type.PartialType; -import com.viaversion.viaversion.api.type.Type; -import io.netty.buffer.ByteBuf; - -public class CustomStringType extends PartialType { - - public CustomStringType(Integer param) { - super(param, String[].class); - } - - public String[] read(ByteBuf buffer, Integer size) throws Exception { - if (buffer.readableBytes() < size/4) { - throw new RuntimeException("Readable bytes does not match expected!"); - } else { - String[] array = new String[size]; - for (int i = 0; i { - - public IntArrayType() { - super(int[].class); - } - - @Override - public int[] read(ByteBuf byteBuf) throws Exception { - byte size = byteBuf.readByte(); - int[] array = new int[size]; - for (byte i = 0; i < size; i++) { - array[i] = byteBuf.readInt(); - } - return array; - } - - @Override - public void write(ByteBuf byteBuf, int[] array) throws Exception { - byteBuf.writeByte(array.length); - for (int i : array) byteBuf.writeInt(i); - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetaType1_7_6_10.java b/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetaType1_7_6_10.java deleted file mode 100644 index bf1c7e281..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetaType1_7_6_10.java +++ /dev/null @@ -1,35 +0,0 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; - -import com.viaversion.viaversion.api.minecraft.metadata.MetaType; -import com.viaversion.viaversion.api.type.Type; - -public enum MetaType1_7_6_10 implements MetaType { - Byte(0, Type.BYTE), - Short(1, Type.SHORT), - Int(2, Type.INT), - Float(3, Type.FLOAT), - String(4, Type.STRING), - Slot(5, Types1_7_6_10.COMPRESSED_NBT_ITEM), - Position(6, Type.VECTOR), - NonExistent(-1, Type.NOTHING); - - private final int typeID; - private final Type type; - - public static MetaType1_7_6_10 byId(int id) { - return values()[id]; - } - - MetaType1_7_6_10(int typeID, Type type) { - this.typeID = typeID; - this.type = type; - } - - public int typeId() { - return this.typeID; - } - - public Type type() { - return this.type; - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataType.java b/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataType.java deleted file mode 100644 index 96971377c..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_7_6_10to1_8/types/MetadataType.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.gerrygames.viarewind.protocol.protocol1_7_6_10to1_8.types; - -import com.viaversion.viaversion.api.minecraft.metadata.Metadata; -import com.viaversion.viaversion.api.type.types.minecraft.MetaTypeTemplate; -import io.netty.buffer.ByteBuf; - -public class MetadataType extends MetaTypeTemplate { - @Override - public Metadata read(ByteBuf buffer) throws Exception { - byte item = buffer.readByte(); - if (item == 127) { - return null; - } else { - int typeID = (item & 224) >> 5; - MetaType1_7_6_10 type = MetaType1_7_6_10.byId(typeID); - int id = item & 31; - return new Metadata(id, type, type.type().read(buffer)); - } - } - - @Override - public void write(ByteBuf buffer, Metadata meta) throws Exception { - int item = (meta.metaType().typeId() << 5 | meta.id() & 31) & 255; - buffer.writeByte(item); - meta.metaType().type().write(buffer, meta.getValue()); - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Levitation.java b/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Levitation.java deleted file mode 100644 index a27b63169..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/protocol/protocol1_8to1_9/storage/Levitation.java +++ /dev/null @@ -1,41 +0,0 @@ -package de.gerrygames.viarewind.protocol.protocol1_8to1_9.storage; - -import com.viaversion.viaversion.api.connection.StoredObject; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.type.Type; -import de.gerrygames.viarewind.protocol.protocol1_8to1_9.Protocol1_8TO1_9; -import de.gerrygames.viarewind.utils.PacketUtil; -import de.gerrygames.viarewind.utils.Tickable; - -public class Levitation extends StoredObject implements Tickable { - private int amplifier; - private volatile boolean active = false; - - public Levitation(UserConnection user) { - super(user); - } - - @Override - public void tick() { - if (!active) { - return; - } - - int vY = (amplifier+1) * 360; - PacketWrapper packet = PacketWrapper.create(0x12, null, Levitation.this.getUser()); - packet.write(Type.VAR_INT, getUser().get(EntityTracker.class).getPlayerId()); - packet.write(Type.SHORT, (short)0); - packet.write(Type.SHORT, (short)vY); - packet.write(Type.SHORT, (short)0); - PacketUtil.sendPacket(packet, Protocol1_8TO1_9.class); - } - - public void setActive(boolean active) { - this.active = active; - } - - public void setAmplifier(int amplifier) { - this.amplifier = amplifier; - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/replacement/EntityReplacement.java b/core/src/main/java/de/gerrygames/viarewind/replacement/EntityReplacement.java deleted file mode 100644 index 440f87770..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/replacement/EntityReplacement.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.gerrygames.viarewind.replacement; - -import com.viaversion.viaversion.api.minecraft.metadata.Metadata; - -import java.util.List; - -public interface EntityReplacement { - - int getEntityId(); - - void setLocation(double x, double y, double z); - - void relMove(double x, double y, double z); - - void setYawPitch(float yaw, float pitch); - - void setHeadYaw(float yaw); - - void spawn(); - - void despawn(); - - void updateMetadata(List metadataList); -} diff --git a/core/src/main/java/de/gerrygames/viarewind/storage/BlockState.java b/core/src/main/java/de/gerrygames/viarewind/storage/BlockState.java deleted file mode 100644 index 2df7b45ea..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/storage/BlockState.java +++ /dev/null @@ -1,17 +0,0 @@ -package de.gerrygames.viarewind.storage; - -public class BlockState { - - public static int extractId(int raw) { - return raw >> 4; - } - - public static int extractData(int raw) { - return raw & 0xF; - } - - public static int stateToRaw(int id, int data) { - return (id << 4) | (data & 0xF); - } - -} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/Enchantments.java b/core/src/main/java/de/gerrygames/viarewind/utils/Enchantments.java deleted file mode 100644 index b5318f847..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/utils/Enchantments.java +++ /dev/null @@ -1,21 +0,0 @@ -package de.gerrygames.viarewind.utils; - -import java.util.HashMap; -import java.util.Map; - -public class Enchantments { - public static final Map ENCHANTMENTS = new HashMap<>(); - - static { - ENCHANTMENTS.put((short) 1, "I"); - ENCHANTMENTS.put((short) 2, "II"); - ENCHANTMENTS.put((short) 3, "III"); - ENCHANTMENTS.put((short) 4, "IV"); - ENCHANTMENTS.put((short) 5, "V"); - ENCHANTMENTS.put((short) 6, "VI"); - ENCHANTMENTS.put((short) 7, "VII"); - ENCHANTMENTS.put((short) 8, "VIII"); - ENCHANTMENTS.put((short) 9, "IX"); - ENCHANTMENTS.put((short) 10, "X"); - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/ServerSender.java b/core/src/main/java/de/gerrygames/viarewind/utils/ServerSender.java deleted file mode 100644 index 24f8bb94c..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/utils/ServerSender.java +++ /dev/null @@ -1,10 +0,0 @@ -package de.gerrygames.viarewind.utils; - -import com.viaversion.viaversion.api.protocol.Protocol; -import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; - -public interface ServerSender { - - void sendToServer(PacketWrapper packet, Class packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception; - -} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/Tickable.java b/core/src/main/java/de/gerrygames/viarewind/utils/Tickable.java deleted file mode 100644 index 9ebc65486..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/utils/Tickable.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.gerrygames.viarewind.utils; - -public interface Tickable { - void tick(); -} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/Ticker.java b/core/src/main/java/de/gerrygames/viarewind/utils/Ticker.java deleted file mode 100644 index 839fa5977..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/utils/Ticker.java +++ /dev/null @@ -1,22 +0,0 @@ -package de.gerrygames.viarewind.utils; - -import com.viaversion.viaversion.api.Via; - -public class Ticker { - private static boolean init = false; - - public static void init() { - if (init) return; - synchronized (Ticker.class) { - if (init) return; - init = true; - } - Via.getPlatform().runRepeatingSync(() -> - Via.getManager().getConnectionManager().getConnections().forEach(user -> - user.getStoredObjects().values().stream() - .filter(Tickable.class::isInstance) - .map(Tickable.class::cast) - .forEach(Tickable::tick) - ), 1L); - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/Utils.java b/core/src/main/java/de/gerrygames/viarewind/utils/Utils.java deleted file mode 100644 index 589111607..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/utils/Utils.java +++ /dev/null @@ -1,12 +0,0 @@ -package de.gerrygames.viarewind.utils; - -import com.viaversion.viaversion.api.connection.UserConnection; - -import java.util.UUID; - -public class Utils { - - public static UUID getUUID(UserConnection user) { - return user.getProtocolInfo().getUuid(); - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/math/AABB.java b/core/src/main/java/de/gerrygames/viarewind/utils/math/AABB.java deleted file mode 100644 index 7125d131d..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/utils/math/AABB.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.gerrygames.viarewind.utils.math; - -public class AABB { - Vector3d min; - Vector3d max; - - public AABB(Vector3d min, Vector3d max) { - this.min = min; - this.max = max; - } - - public Vector3d getMin() { - return this.min; - } - - public Vector3d getMax() { - return this.max; - } -} diff --git a/core/src/main/java/de/gerrygames/viarewind/utils/math/Ray3d.java b/core/src/main/java/de/gerrygames/viarewind/utils/math/Ray3d.java deleted file mode 100644 index 69c4866ff..000000000 --- a/core/src/main/java/de/gerrygames/viarewind/utils/math/Ray3d.java +++ /dev/null @@ -1,19 +0,0 @@ -package de.gerrygames.viarewind.utils.math; - -public class Ray3d { - Vector3d start; - Vector3d dir; - - public Ray3d(Vector3d start, Vector3d dir) { - this.start = start; - this.dir = dir; - } - - public Vector3d getStart() { - return this.start; - } - - public Vector3d getDir() { - return this.dir; - } -} diff --git a/core/src/main/resources/assets/viarewind/config.yml b/core/src/main/resources/assets/viarewind/config.yml deleted file mode 100644 index d463efd2c..000000000 --- a/core/src/main/resources/assets/viarewind/config.yml +++ /dev/null @@ -1,16 +0,0 @@ -#Specifies how 1.8.x clients should see the cooldown indicator -#You can choose between TITLE, ACTION_BAR, BOSS_BAR and DISABLED -#ONLY DISABLE IF YOU HAVE 1.9 COOLDOWN DISABLED ON YOUR SERVER -#1.8 PLAYERS MAY ASK WHY PVP IS NOT WORKING OTHERWISE -cooldown-indicator: 'TITLE' -#Replaces Adventure mode with Survival mode for 1.7.x clients -#Enable this option if your server is using the 'CanDestroy' -#or 'CanPlaceOn' flags on items -replace-adventure: false -#Whether 1.9 particles should be replaced by similar ones in -#1.8 and lower -replace-particles: false -#Max amount of pages for written books before a client gets kicked -max-book-pages: 100 -#Max amount of characters in the json (!) string of a book page before a client gets kicked -max-book-page-length: 5000 \ No newline at end of file diff --git a/fabric/build.gradle b/fabric/build.gradle new file mode 100644 index 000000000..b44f04d91 --- /dev/null +++ b/fabric/build.gradle @@ -0,0 +1,10 @@ +plugins { + id "com.viaversion.java-conventions" +} + +dependencies { + api project(":viarewind-common") + + compileOnly(annotationProcessor("net.fabricmc:fabric-loader:0.11.3")) + compileOnly(annotationProcessor("org.apache.logging.log4j:log4j-api:2.17.1")) +} diff --git a/fabric/gradle.properties b/fabric/gradle.properties new file mode 100644 index 000000000..252dc33fb --- /dev/null +++ b/fabric/gradle.properties @@ -0,0 +1 @@ +maven_name=viarewind-fabric diff --git a/fabric/pom.xml b/fabric/pom.xml deleted file mode 100644 index 82cce68d9..000000000 --- a/fabric/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - - - com.viaversion - viarewind-parent - 2.0.4-SNAPSHOT - - - viarewind-fabric - - - - fabric-repo - https://maven.fabricmc.net/ - - - - - - - net.fabricmc - fabric-loader - 0.11.3 - provided - - - - - org.apache.logging.log4j - log4j-api - 2.17.1 - provided - - - - - com.viaversion - viarewind-core - ${project.parent.version} - - - - - - - . - true - src/main/resources/ - - * - - - - - - diff --git a/fabric/src/main/java/com/viaversion/viarewind/ViaFabricAddon.java b/fabric/src/main/java/com/viaversion/viarewind/ViaFabricAddon.java new file mode 100644 index 000000000..70333e026 --- /dev/null +++ b/fabric/src/main/java/com/viaversion/viarewind/ViaFabricAddon.java @@ -0,0 +1,41 @@ +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind; + +import com.viaversion.viarewind.api.ViaRewindPlatform; +import com.viaversion.viarewind.fabric.util.LoggerWrapper; +import net.fabricmc.loader.api.FabricLoader; +import org.apache.logging.log4j.LogManager; + +import java.util.logging.Logger; + +public class ViaFabricAddon implements ViaRewindPlatform, Runnable { + private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaRewind")); + + @Override + public void run() { + ViaRewindConfig conf = new ViaRewindConfig(FabricLoader.getInstance().getConfigDirectory().toPath().resolve("ViaRewind").resolve("config.yml").toFile()); + conf.reloadConfig(); + this.init(conf); + } + + public Logger getLogger() { + return this.logger; + } +} \ No newline at end of file diff --git a/fabric/src/main/java/de/gerrygames/viarewind/fabric/util/LoggerWrapper.java b/fabric/src/main/java/com/viaversion/viarewind/fabric/util/LoggerWrapper.java similarity index 70% rename from fabric/src/main/java/de/gerrygames/viarewind/fabric/util/LoggerWrapper.java rename to fabric/src/main/java/com/viaversion/viarewind/fabric/util/LoggerWrapper.java index 4b6db677b..1517de90f 100644 --- a/fabric/src/main/java/de/gerrygames/viarewind/fabric/util/LoggerWrapper.java +++ b/fabric/src/main/java/com/viaversion/viarewind/fabric/util/LoggerWrapper.java @@ -1,5 +1,22 @@ -package de.gerrygames.viarewind.fabric.util; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ +package com.viaversion.viarewind.fabric.util; import java.text.MessageFormat; import java.util.logging.Level; diff --git a/fabric/src/main/java/de/gerrygames/viarewind/ViaFabricAddon.java b/fabric/src/main/java/de/gerrygames/viarewind/ViaFabricAddon.java deleted file mode 100644 index 19d1e5039..000000000 --- a/fabric/src/main/java/de/gerrygames/viarewind/ViaFabricAddon.java +++ /dev/null @@ -1,24 +0,0 @@ -package de.gerrygames.viarewind; - -import de.gerrygames.viarewind.api.ViaRewindConfigImpl; -import de.gerrygames.viarewind.api.ViaRewindPlatform; -import de.gerrygames.viarewind.fabric.util.LoggerWrapper; -import net.fabricmc.loader.api.FabricLoader; -import org.apache.logging.log4j.LogManager; - -import java.util.logging.Logger; - -public class ViaFabricAddon implements ViaRewindPlatform, Runnable { - private final Logger logger = new LoggerWrapper(LogManager.getLogger("ViaRewind")); - - @Override - public void run() { - ViaRewindConfigImpl conf = new ViaRewindConfigImpl(FabricLoader.getInstance().getConfigDirectory().toPath().resolve("ViaRewind").resolve("config.yml").toFile()); - conf.reloadConfig(); - this.init(conf); - } - - public Logger getLogger() { - return this.logger; - } -} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 6de0e1700..fc88e1758 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -2,7 +2,7 @@ "schemaVersion": 1, "id": "viarewind", "name": "ViaRewind", - "version": "${project.version}", + "version": "${version}", "license": "GPL-3.0", "contact": { "homepage": "https://viaversion.com/rewind", @@ -12,11 +12,13 @@ "icon": "assets/viarewind/textures/squarelogo.png", "environment": "*", "authors": [ - "Gerrygames" + "Gerrygames", + "FlorianMichael/EnZaXD", + "creeper123123321" ], "entrypoints": { "viafabric:via_api_initialized": [ - "de.gerrygames.viarewind.ViaFabricAddon" + "com.viaversion.viarewind.ViaFabricAddon" ] }, "depends": { @@ -26,4 +28,4 @@ "recommends": { "viabackwards": "*" } -} +} \ No newline at end of file diff --git a/gradle.properties b/gradle.properties new file mode 100644 index 000000000..193897ede --- /dev/null +++ b/gradle.properties @@ -0,0 +1,18 @@ +# gradle +org.gradle.jvmargs=-Xmx8G +org.gradle.parallel=true + +# project +maven_version=3.0.0 +maven_group=com.viaversion + +# libraries +viaversion_version=4.8.0 +netty_version=4.0.20.Final +guava_version=17.0 + +# Smile emoji +mcVersions=1.20.2, 1.20.1, 1.20, 1.19.4, 1.19.3, 1.19.2, 1.19.1, 1.19, 1.18.2, 1.18.1, 1.18, 1.17.1, 1.17, 1.16.5, 1.16.4, 1.16.3, 1.16.2, 1.16.1, 1.16, 1.15.2, 1.15.1, 1.15, 1.14.4, 1.14.3, 1.14.2, 1.14.1, 1.14, 1.13.2, 1.13.1, 1.13, 1.12.2, 1.12.1, 1.12, 1.11.2, 1.11.1, 1.11, 1.10.2, 1.10.1, 1.10, 1.9.4, 1.9.3, 1.9.2, 1.9.1, 1.9, 1.8.9, 1.8.8 +mcVersionRange=1.8-1.20.2 +waterfallVersion=1.20 +velocityVersion=3.2 \ No newline at end of file diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 000000000..033e24c4c Binary files /dev/null and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 000000000..9f4197d5f --- /dev/null +++ b/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,7 @@ +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip +networkTimeout=10000 +validateDistributionUrl=true +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew new file mode 100755 index 000000000..fcb6fca14 --- /dev/null +++ b/gradlew @@ -0,0 +1,248 @@ +#!/bin/sh + +# +# Copyright © 2015-2021 the original authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +############################################################################## +# +# Gradle start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh Gradle +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# +############################################################################## + +# Attempt to set APP_HOME + +# Resolve links: $0 may be a link +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac +done + +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD=maximum + +warn () { + echo "$*" +} >&2 + +die () { + echo + echo "$*" + echo + exit 1 +} >&2 + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD=$JAVA_HOME/jre/sh/java + else + JAVACMD=$JAVA_HOME/bin/java + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +fi + +# Increase the maximum file descriptors if we can. +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac +fi + +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. + +# For Cygwin or MSYS, switch paths to Windows format before running java +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + + # Now convert the arguments - kludge to limit ourselves to /bin/sh + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) + fi + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg + done +fi + + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command; +# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of +# shell script including quotes and variable substitutions, so put them in +# double quotes to make sure that they get re-expanded; and +# * put everything else in single quotes, so that it's not re-expanded. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -classpath "$CLASSPATH" \ + org.gradle.wrapper.GradleWrapperMain \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' + +exec "$JAVACMD" "$@" diff --git a/gradlew.bat b/gradlew.bat new file mode 100644 index 000000000..93e3f59f1 --- /dev/null +++ b/gradlew.bat @@ -0,0 +1,92 @@ +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* + +:end +@rem End local scope for the variables with windows NT shell +if %ERRORLEVEL% equ 0 goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +set EXIT_CODE=%ERRORLEVEL% +if %EXIT_CODE% equ 0 set EXIT_CODE=1 +if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% +exit /b %EXIT_CODE% + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/pom.xml b/pom.xml deleted file mode 100644 index 8fc131abb..000000000 --- a/pom.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - 4.0.0 - - com.viaversion - viarewind-parent - 2.0.4-SNAPSHOT - pom - - - core - bukkit - bungee - fabric - sponge - velocity - all - - - - - UTF-8 - ${projectEncoding} - ${projectEncoding} - 1.8 - 1.8 - - - - - viaversion-repo - https://repo.viaversion.com - - - - - - - com.viaversion - viaversion - 4.6.2-SNAPSHOT - provided - - - - com.google.guava - guava - - 17.0 - provided - - - - diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 000000000..e341ce294 --- /dev/null +++ b/settings.gradle @@ -0,0 +1,16 @@ +include "viarewind-universal" +include "viarewind-common" +include "viarewind-bukkit" +include "viarewind-bungee" +include "viarewind-fabric" +include "viarewind-sponge" +include "viarewind-velocity" + +project(":viarewind-universal").projectDir = file("universal") +project(":viarewind-common").projectDir = file("common") +project(":viarewind-bukkit").projectDir = file("bukkit") +project(":viarewind-bungee").projectDir = file("bungee") +project(":viarewind-fabric").projectDir = file("fabric") +project(":viarewind-sponge").projectDir = file("sponge") +project(":viarewind-velocity").projectDir = file("velocity") + diff --git a/sponge/build.gradle b/sponge/build.gradle new file mode 100644 index 000000000..c63eaf1b2 --- /dev/null +++ b/sponge/build.gradle @@ -0,0 +1,9 @@ +plugins { + id "com.viaversion.java-conventions" +} + +dependencies { + api project(":viarewind-common") + + compileOnly(annotationProcessor("org.spongepowered:spongeapi:8.0.0")) +} diff --git a/sponge/gradle.properties b/sponge/gradle.properties new file mode 100644 index 000000000..2e5dcad53 --- /dev/null +++ b/sponge/gradle.properties @@ -0,0 +1 @@ +maven_name=viarewind-sponge diff --git a/sponge/pom.xml b/sponge/pom.xml deleted file mode 100644 index 40a82fcf6..000000000 --- a/sponge/pom.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - 4.0.0 - - - com.viaversion - viarewind-parent - 2.0.4-SNAPSHOT - - - viarewind-sponge - - - - - . - true - src/main/resources/ - - ** - - - - - - - - sponge-maven-repo - Sponge maven repo - https://repo.spongepowered.org/repository/maven-public/ - - - - - - - com.viaversion - viarewind-core - ${project.parent.version} - - - - - org.spongepowered - spongeapi - 8.0.0 - provided - - - - diff --git a/sponge/src/main/java/de/gerrygames/viarewind/SpongePlugin.java b/sponge/src/main/java/com/viaversion/viarewind/SpongePlugin.java similarity index 54% rename from sponge/src/main/java/de/gerrygames/viarewind/SpongePlugin.java rename to sponge/src/main/java/com/viaversion/viarewind/SpongePlugin.java index 4458d453e..de056520b 100644 --- a/sponge/src/main/java/de/gerrygames/viarewind/SpongePlugin.java +++ b/sponge/src/main/java/com/viaversion/viarewind/SpongePlugin.java @@ -1,9 +1,26 @@ -package de.gerrygames.viarewind; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind; import com.google.inject.Inject; import com.viaversion.viaversion.sponge.util.LoggerWrapper; -import de.gerrygames.viarewind.api.ViaRewindConfigImpl; -import de.gerrygames.viarewind.api.ViaRewindPlatform; +import com.viaversion.viarewind.api.ViaRewindPlatform; import org.spongepowered.api.config.ConfigDir; import org.spongepowered.api.event.Listener; import org.spongepowered.api.event.Order; @@ -24,14 +41,14 @@ public class SpongePlugin implements ViaRewindPlatform { @Inject @ConfigDir(sharedRoot = false) private Path configDir; - private ViaRewindConfigImpl conf; + private ViaRewindConfig conf; @Listener(order = Order.LATE) public void loadPlugin(ConstructPluginEvent e) { // Setup Logger this.logger = new LoggerWrapper(loggerSlf4j); // Init! - conf = new ViaRewindConfigImpl(configDir.resolve("config.yml").toFile()); + conf = new ViaRewindConfig(configDir.resolve("config.yml").toFile()); conf.reloadConfig(); this.init(conf); } diff --git a/sponge/src/main/resources/META-INF/sponge_plugins.json b/sponge/src/main/resources/META-INF/sponge_plugins.json index f38f40a5f..d09655dd9 100644 --- a/sponge/src/main/resources/META-INF/sponge_plugins.json +++ b/sponge/src/main/resources/META-INF/sponge_plugins.json @@ -5,7 +5,7 @@ }, "license": "GNU GPLv3", "global": { - "version": "${project.version}", + "version": "${version}", "links": { "homepage": "https://viaversion.com/rewind", "source": "https://github.com/ViaVersion/ViaRewind", @@ -15,6 +15,14 @@ { "name": "Gerrygames", "description": "Author" + }, + { + "name": "FlorianMichael/EnZaXD", + "description": "Author" + }, + { + "name": "creeper123123321", + "description": "Maintainer" } ], "dependencies": [ @@ -32,7 +40,7 @@ { "id": "viarewind", "name": "ViaRewind", - "entrypoint": "de.gerrygames.viarewind.SpongePlugin" + "entrypoint": "com.viaversion.viarewind.SpongePlugin" } ] -} +} \ No newline at end of file diff --git a/universal/build.gradle b/universal/build.gradle new file mode 100644 index 000000000..add986143 --- /dev/null +++ b/universal/build.gradle @@ -0,0 +1,159 @@ +import io.papermc.hangarpublishplugin.model.Platforms + +plugins { + id "com.github.johnrengelman.shadow" version "8.1.1" + id "io.papermc.hangar-publish-plugin" version "0.1.0" + id "com.modrinth.minotaur" version "2.+" + id "java-library" + id "maven-publish" +} + +dependencies { + api project(":viarewind-common") + api project(":viarewind-bukkit") + api project(":viarewind-bungee") + api project(":viarewind-fabric") + api project(":viarewind-sponge") + api project(":viarewind-velocity") +} + +shadowJar { + archiveClassifier.set("") + archiveBaseName.set("ViaRewind-" + project.maven_version) + configurations { + api + } +} + +publishing { + repositories { + maven { + name = "Via" + url = "https://repo.viaversion.com/" + + credentials(PasswordCredentials) + authentication { + basic(BasicAuthentication) + } + } + } + publications { + shadow(MavenPublication) { publication -> + artifactId = project.maven_name + groupId = project.maven_group + version = project.maven_version + + from project.shadow.component(publication) + } + } +} + +build.dependsOn shadowJar + +// ----------------------------------------------------- +// Publishing + +def latestCommitHash() { + def byteOut = new ByteArrayOutputStream() + exec { + commandLine 'git', 'rev-parse', '--short', 'HEAD' + standardOutput = byteOut + } + return byteOut.toString('UTF-8').trim() +} + +def latestCommitMessage() { + def byteOut = new ByteArrayOutputStream() + exec { + commandLine 'git', 'log', '-1', '--pretty=%B' + standardOutput = byteOut + } + return byteOut.toString('UTF-8').trim() +} + +def branchName() { + def byteOut = new ByteArrayOutputStream() + exec { + commandLine 'git', 'branch' + standardOutput = byteOut + } + return byteOut.toString('UTF-8').trim() +} + +def branch = branchName() +def baseVersion = project.maven_version +def isRelease = !baseVersion.contains('-') +def suffixedVersion = isRelease ? baseVersion : baseVersion + "+" + System.getenv("GITHUB_RUN_NUMBER") +def commitHash = latestCommitHash() +def changelogContent = "[${commitHash}](https://github.com/ViaVersion/ViaRewind/commit/${commitHash}) ${latestCommitMessage()}" +def isMainBranch = branch == "master" +modrinth { + def mcVersions = project.mcVersions + .split(',') + .collect { it.trim() } + + token.set(System.getenv("MODRINTH_TOKEN")) + projectId.set("viarewind") + versionType.set(isRelease ? "release" : isMainBranch ? "beta" : "alpha") + versionNumber.set(suffixedVersion) + versionName.set(suffixedVersion) + changelog.set(changelogContent) + uploadFile.set(shadowJar.archiveFile) + gameVersions.set(mcVersions) + loaders.add("fabric") + loaders.add("paper") + loaders.add("folia") + loaders.add("velocity") + loaders.add("bungeecord") + loaders.add("sponge") + autoAddDependsOn.set(false) + detectLoaders.set(false) + dependencies { + optional.project("viafabric") + optional.project("viafabricplus") + optional.project("viaversion") + optional.project("viabackwards") + } +} + +hangarPublish { + publications.register("plugin") { + version.set(suffixedVersion) + id.set("ViaRewind") + channel.set(isRelease ? "Release" : isMainBranch ? "Snapshot" : "Alpha") + changelog.set(changelogContent) + apiKey.set(System.getenv("HANGAR_TOKEN")) + platforms { + register(Platforms.PAPER) { + jar.set(shadowJar.archiveFile) + platformVersions.set([property('mcVersionRange') as String]) + dependencies.hangar("ViaVersion") { + required.set(true) + } + dependencies.hangar("ViaBackwards") { + required.set(false) + } + } + register(Platforms.VELOCITY) { + jar.set(shadowJar.archiveFile) + platformVersions.set([property("velocityVersion") as String]) + dependencies.hangar("ViaVersion") { + required.set(true) + } + dependencies.hangar("ViaBackwards") { + required.set(false) + } + } + register(Platforms.WATERFALL) { + jar.set(shadowJar.archiveFile) + platformVersions.set([property("waterfallVersion") as String]) + dependencies.hangar("ViaVersion") { + required.set(true) + } + dependencies.hangar("ViaBackwards") { + required.set(false) + } + } + } + } +} diff --git a/universal/gradle.properties b/universal/gradle.properties new file mode 100644 index 000000000..2e9261074 --- /dev/null +++ b/universal/gradle.properties @@ -0,0 +1 @@ +maven_name=viarewind-universal diff --git a/velocity/build.gradle b/velocity/build.gradle new file mode 100644 index 000000000..d2763d0bd --- /dev/null +++ b/velocity/build.gradle @@ -0,0 +1,9 @@ +plugins { + id "com.viaversion.java-conventions" +} + +dependencies { + api project(":viarewind-common") + + compileOnly(annotationProcessor("com.velocitypowered:velocity-api:3.0.1")) +} diff --git a/velocity/gradle.properties b/velocity/gradle.properties new file mode 100644 index 000000000..ac8d47471 --- /dev/null +++ b/velocity/gradle.properties @@ -0,0 +1 @@ +maven_name=viarewind-velocity diff --git a/velocity/pom.xml b/velocity/pom.xml deleted file mode 100644 index 7e0d316e7..000000000 --- a/velocity/pom.xml +++ /dev/null @@ -1,69 +0,0 @@ - - - 4.0.0 - - - com.viaversion - viarewind-parent - 2.0.4-SNAPSHOT - - - viarewind-velocity - - - - - . - true - src/main/resources/ - - * - - - - - - - org.codehaus.mojo - templating-maven-plugin - 1.0.0 - - - filter-src - - filter-sources - - - - - - - - - - velocity-maven-repo - Velocity maven repo - https://nexus.velocitypowered.com/repository/maven-public/ - - - - - - - com.viaversion - viarewind-core - ${project.parent.version} - - - - - com.velocitypowered - velocity-api - 3.0.1 - provided - - - - diff --git a/velocity/src/main/java-templates/de/gerrygames/viarewind/velocity/VersionInfo.java b/velocity/src/main/java-templates/de/gerrygames/viarewind/velocity/VersionInfo.java deleted file mode 100644 index 9a8ffc181..000000000 --- a/velocity/src/main/java-templates/de/gerrygames/viarewind/velocity/VersionInfo.java +++ /dev/null @@ -1,5 +0,0 @@ -package de.gerrygames.viarewind.velocity; - -public class VersionInfo { - public static final String VERSION = "${project.version}"; -} diff --git a/velocity/src/main/java/de/gerrygames/viarewind/VelocityPlugin.java b/velocity/src/main/java/com/viaversion/viarewind/VelocityPlugin.java similarity index 53% rename from velocity/src/main/java/de/gerrygames/viarewind/VelocityPlugin.java rename to velocity/src/main/java/com/viaversion/viarewind/VelocityPlugin.java index d94d3462d..5e92bb4db 100644 --- a/velocity/src/main/java/de/gerrygames/viarewind/VelocityPlugin.java +++ b/velocity/src/main/java/com/viaversion/viarewind/VelocityPlugin.java @@ -1,4 +1,22 @@ -package de.gerrygames.viarewind; +/* + * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind + * Copyright (C) 2016-2023 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 . + */ + +package com.viaversion.viarewind; import com.google.inject.Inject; import com.velocitypowered.api.event.PostOrder; @@ -9,17 +27,15 @@ import com.velocitypowered.api.plugin.Plugin; import com.velocitypowered.api.plugin.annotation.DataDirectory; import com.viaversion.viaversion.velocity.util.LoggerWrapper; -import de.gerrygames.viarewind.api.ViaRewindConfigImpl; -import de.gerrygames.viarewind.api.ViaRewindPlatform; -import de.gerrygames.viarewind.velocity.VersionInfo; +import com.viaversion.viarewind.api.ViaRewindPlatform; import java.nio.file.Path; import java.util.logging.Logger; @Plugin(id = "viarewind", name = "ViaRewind", - version = VersionInfo.VERSION, - authors = {"Gerrygames"}, + version = ViaRewindPlatform.VERSION, + authors = {"Gerrygames", "FlorianMichael/EnZaXD", "creeper123123321"}, dependencies = { @Dependency(id = "viaversion"), @Dependency(id = "viabackwards", optional = true) @@ -34,14 +50,14 @@ public class VelocityPlugin implements ViaRewindPlatform { @Inject @DataDirectory private Path configDir; - private ViaRewindConfigImpl conf; + private ViaRewindConfig conf; @Subscribe(order = PostOrder.LATE) public void onProxyStart(ProxyInitializeEvent e) { // Setup Logger this.logger = new LoggerWrapper(loggerSlf4j); // Init! - conf = new ViaRewindConfigImpl(configDir.resolve("config.yml").toFile()); + conf = new ViaRewindConfig(configDir.resolve("config.yml").toFile()); conf.reloadConfig(); this.init(conf); } @@ -54,4 +70,4 @@ public void onReload(ProxyReloadEvent e) { public Logger getLogger() { return this.logger; } -} +} \ No newline at end of file