mirror of
https://github.com/ViaVersion/ViaRewind.git
synced 2026-11-04 17:00:20 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
14bad1d36f | ||
|
|
7a9bf5f465 | ||
|
|
f290af7b81 | ||
|
|
064d0008f5 | ||
|
|
fbe30d9da5 | ||
|
|
31490069ea | ||
|
|
1b8d5eacc0 | ||
|
|
abdb79598b | ||
|
|
1b5b59317c | ||
|
|
6e4ac65983 | ||
|
|
64cce82140 | ||
|
|
cb79316d6a | ||
|
|
7d34c3838a | ||
|
|
c60152532d | ||
|
|
1894bac11b | ||
|
|
a80ca442e5 | ||
|
|
c69ce24d32 | ||
|
|
e937a886ec |
No files matched your search
+1
-1
@@ -1,2 +1,2 @@
|
||||
github: FlorianMichael
|
||||
custom: ['https://florianmichael.de/donate', 'https://viaversion.com/donate', 'https://creeper123123321.github.io/#donate']
|
||||
custom: ['https://florianmichael.de/donate', 'https://creeper123123321.github.io/#donate']
|
||||
@@ -8,7 +8,7 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
uses: gradle/wrapper-validation-action@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
|
||||
@@ -13,7 +13,7 @@ jobs:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@v4
|
||||
- name: Validate Gradle Wrapper
|
||||
uses: gradle/wrapper-validation-action@v1
|
||||
uses: gradle/wrapper-validation-action@v3
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@v4
|
||||
with:
|
||||
|
||||
@@ -37,7 +37,7 @@ Other Links
|
||||
Building
|
||||
-
|
||||
After cloning this repository, build the project with Gradle by running `./gradlew build` and take the created jar out
|
||||
of the `universal/build/libs` directory.
|
||||
of the `build/libs` directory.
|
||||
|
||||
You need JDK 17 or newer to build ViaRewind.
|
||||
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
plugins {
|
||||
id "java-library"
|
||||
id "maven-publish"
|
||||
id "idea"
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenCentral()
|
||||
maven {
|
||||
name = "ViaVersion"
|
||||
url "https://repo.viaversion.com"
|
||||
}
|
||||
}
|
||||
|
||||
base {
|
||||
java.toolchain.languageVersion = JavaLanguageVersion.of(17)
|
||||
compileJava.options.encoding = compileTestJava.options.encoding = javadoc.options.encoding = "UTF-8"
|
||||
|
||||
group = rootProject.maven_group
|
||||
version = rootProject.maven_version
|
||||
description = rootProject.maven_description
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.viaversion:viaversion:${project.viaversion_version}"
|
||||
compileOnly "com.viaversion:viabackwards:${project.viabackwards_version}"
|
||||
}
|
||||
|
||||
publishing {
|
||||
repositories {
|
||||
maven {
|
||||
name = "Via"
|
||||
url = "https://repo.viaversion.com/"
|
||||
|
||||
credentials(PasswordCredentials)
|
||||
authentication {
|
||||
basic(BasicAuthentication)
|
||||
}
|
||||
}
|
||||
}
|
||||
publications {
|
||||
main(MavenPublication) {
|
||||
artifactId = project.name
|
||||
groupId = project.maven_group
|
||||
version = project.maven_version
|
||||
|
||||
from components.java
|
||||
|
||||
pom {
|
||||
name = "ViaRewind"
|
||||
description = project.description
|
||||
url = "https://github.com/ViaVersion/ViaRewind"
|
||||
licenses {
|
||||
license {
|
||||
name = "GPL-3.0 License"
|
||||
url = "https://github.com/ViaVersion/ViaRewind/blob/main/LICENSE"
|
||||
}
|
||||
}
|
||||
developers {
|
||||
developer {
|
||||
id = "FlorianMichael"
|
||||
name = "EnZaXD"
|
||||
email = "florian.michael07@gmail.com"
|
||||
}
|
||||
}
|
||||
scm {
|
||||
connection = "scm:git:git://github.com/ViaVersion/ViaRewind.git"
|
||||
developerConnection = "scm:git:ssh://github.com/ViaVersion/ViaRewind.git"
|
||||
url = "github.com/ViaVersion/ViaRewind"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
plugins {
|
||||
id "java-library"
|
||||
id "maven-publish"
|
||||
}
|
||||
|
||||
repositories {
|
||||
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 "com.viaversion:viabackwards:${project.viabackwards_version}"
|
||||
compileOnly "io.netty:netty-all:${project.netty_version}"
|
||||
compileOnly "com.google.guava:guava:${project.guava_version}"
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = project.maven_name
|
||||
group = project.maven_group
|
||||
version = project.maven_version
|
||||
description = "ViaBackwards addon to allow 1.8.x and 1.7.x clients on newer server versions."
|
||||
}
|
||||
|
||||
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
tasks {
|
||||
// Variable replacements
|
||||
processResources {
|
||||
for (final def file in ["plugin.yml", "fabric.mod.json"]) {
|
||||
filesMatching(file) {
|
||||
expand(
|
||||
"version": project.version,
|
||||
"description": project.description
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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'
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
plugins {
|
||||
id "vr.base-conventions"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly project(":viarewind-common")
|
||||
}
|
||||
@@ -1,59 +1,53 @@
|
||||
plugins {
|
||||
id "com.github.johnrengelman.shadow" version "8.1.1"
|
||||
id "vr.base-conventions"
|
||||
|
||||
id "io.papermc.hangar-publish-plugin" version "0.1.2"
|
||||
id "com.modrinth.minotaur" version "2.+"
|
||||
id "java-library"
|
||||
id "maven-publish"
|
||||
}
|
||||
|
||||
base {
|
||||
archivesName = "ViaRewind"
|
||||
}
|
||||
|
||||
configurations {
|
||||
publishInclude
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":viarewind-common")
|
||||
api project(":viarewind-bukkit")
|
||||
api project(":viarewind-fabric")
|
||||
api project(":viarewind-velocity")
|
||||
publishInclude project(":viarewind-common")
|
||||
publishInclude project(":viarewind-bukkit")
|
||||
publishInclude project(":viarewind-fabric")
|
||||
publishInclude project(":viarewind-velocity")
|
||||
}
|
||||
|
||||
java {
|
||||
withSourcesJar()
|
||||
withJavadocJar()
|
||||
}
|
||||
|
||||
shadowJar {
|
||||
jar {
|
||||
dependsOn configurations.publishInclude
|
||||
from {
|
||||
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||||
configurations.publishInclude.collect {
|
||||
zipTree(it)
|
||||
}
|
||||
} {
|
||||
exclude "META-INF/*.RSA", "META-INF/*.SF", "META-INF/*.DSA"
|
||||
}
|
||||
manifest {
|
||||
attributes["paperweight-mappings-namespace"] = "mojang"
|
||||
attributes(
|
||||
"paperweight-mappings-namespace": "mojang"
|
||||
)
|
||||
}
|
||||
archiveClassifier.set("")
|
||||
archiveBaseName.set("ViaRewind-" + project.maven_version)
|
||||
configurations {
|
||||
api
|
||||
from("LICENSE") {
|
||||
rename { "${it}_${project.name ?: rootProject.name}" }
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
idea {
|
||||
module {
|
||||
["run"].each {
|
||||
excludeDirs << file("$it")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
build.dependsOn shadowJar
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Publishing
|
||||
|
||||
@@ -103,7 +97,7 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
|
||||
versionNumber.set(suffixedVersion)
|
||||
versionName.set(suffixedVersion)
|
||||
changelog.set(changelogContent)
|
||||
uploadFile.set(shadowJar.archiveFile)
|
||||
uploadFile.set(jar.archiveFile)
|
||||
gameVersions.set(mcVersions)
|
||||
loaders.add("fabric")
|
||||
loaders.add("paper")
|
||||
@@ -127,7 +121,7 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
|
||||
apiKey = System.getenv("HANGAR_TOKEN")
|
||||
platforms {
|
||||
PAPER {
|
||||
jar = shadowJar.archiveFile
|
||||
jar = project.jar.archiveFile
|
||||
platformVersions = [property('mcVersionRange') as String]
|
||||
dependencies {
|
||||
hangar("ViaVersion") {
|
||||
@@ -139,7 +133,7 @@ if (!isRelease || isMainBranch) { // Only publish releases from the main branch
|
||||
}
|
||||
}
|
||||
VELOCITY {
|
||||
jar = shadowJar.archiveFile
|
||||
jar = project.jar.archiveFile
|
||||
platformVersions = [property("velocityVersion") as String]
|
||||
dependencies {
|
||||
hangar("ViaVersion") {
|
||||
+18
-3
@@ -1,9 +1,24 @@
|
||||
plugins {
|
||||
id "vr.java-conventions"
|
||||
id "vr.platform-conventions"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "SpigotMC"
|
||||
url "https://hub.spigotmc.org/nexus/content/repositories/snapshots/"
|
||||
}
|
||||
maven {
|
||||
name = "SpongePowered"
|
||||
url "https://repo.spongepowered.org/repository/maven-public/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":viarewind-common")
|
||||
|
||||
compileOnly(annotationProcessor("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT"))
|
||||
}
|
||||
|
||||
processResources {
|
||||
filesMatching("plugin.yml") {
|
||||
expand("version": project.version, "description": project.description)
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
maven_name=viarewind-bukkit
|
||||
+4
-13
@@ -1,28 +1,19 @@
|
||||
plugins {
|
||||
id "vr.java-conventions"
|
||||
}
|
||||
id "vr.base-conventions"
|
||||
|
||||
plugins {
|
||||
id "net.raphimc.class-token-replacer" version "1.0.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly "io.netty:netty-all:${project.netty_version}"
|
||||
compileOnly "com.google.guava:guava:${project.guava_version}"
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
classTokenReplacer {
|
||||
property("\${version}", rootProject.maven_version)
|
||||
property("\${impl_version}", "git-ViaRewind-${rootProject.maven_version}:${project.latestCommitHash()}")
|
||||
property("\${impl_version}", "git-ViaRewind-${rootProject.maven_version}:${rootProject.latestCommitHash()}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String latestCommitHash() {
|
||||
def stdout = new ByteArrayOutputStream()
|
||||
exec {
|
||||
commandLine 'git', 'rev-parse', '--short', 'HEAD'
|
||||
standardOutput = stdout
|
||||
}
|
||||
return stdout.toString().trim()
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
maven_name=viarewind-common
|
||||
@@ -52,7 +52,7 @@ public abstract class VREntityRewriter<C extends ClientboundPacketType, T extend
|
||||
});
|
||||
}
|
||||
|
||||
protected void untrackEntities(final UserConnection connection, final int[] entities) {
|
||||
protected void removeEntities(final UserConnection connection, final int[] entities) {
|
||||
final EntityTrackerBase tracker = tracker(connection);
|
||||
for (int entityId : entities) {
|
||||
tracker.removeEntity(entityId);
|
||||
@@ -60,7 +60,7 @@ public abstract class VREntityRewriter<C extends ClientboundPacketType, T extend
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getDisplayVisibilityMetaValue() {
|
||||
protected Object getDisplayVisibilityDataValue() {
|
||||
return (byte) 1;
|
||||
}
|
||||
|
||||
|
||||
-4
@@ -199,10 +199,6 @@ public enum EntityDataIndex1_7_6_10 {
|
||||
}
|
||||
|
||||
public static EntityDataIndex1_7_6_10 searchIndex(EntityType type, int index) {
|
||||
if (type == null) {
|
||||
// Plugins sending metadata before an entity is spawned, causing exceptions while the game ignores them.
|
||||
return null;
|
||||
}
|
||||
EntityType currentType = type;
|
||||
do {
|
||||
Optional<EntityDataIndex1_7_6_10> optMeta = getIndex(currentType, index);
|
||||
|
||||
+2
-3
@@ -277,9 +277,8 @@ public class BlockItemPacketRewriter1_8 extends VRBlockItemRewriter<ClientboundP
|
||||
super.handleItemToClient(connection, item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) {
|
||||
item.setTag(tag = new CompoundTag());
|
||||
}
|
||||
if (tag == null) return item;
|
||||
|
||||
enchantmentRewriter.handleToClient(item);
|
||||
|
||||
if (item.identifier() == 387) {
|
||||
|
||||
+8
-3
@@ -92,7 +92,7 @@ public class EntityPacketRewriter1_8 extends VREntityRewriter<ClientboundPackets
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_8.REMOVE_ENTITIES, wrapper -> {
|
||||
final int[] entities = wrapper.read(Types.VAR_INT_ARRAY_PRIMITIVE);
|
||||
untrackEntities(wrapper.user(), entities);
|
||||
removeEntities(wrapper.user(), entities);
|
||||
|
||||
wrapper.cancel();
|
||||
|
||||
@@ -117,8 +117,13 @@ public class EntityPacketRewriter1_8 extends VREntityRewriter<ClientboundPackets
|
||||
if (tracker.getHolograms().containsKey(entityId)) {
|
||||
wrapper.cancel();
|
||||
tracker.getHolograms().get(entityId).syncState(EntityPacketRewriter1_8.this, entityData);
|
||||
} else {
|
||||
} else if (tracker.hasEntity(entityId)) {
|
||||
handleEntityData(entityId, entityData, wrapper.user());
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
if (tracker.clientEntityId() == entityId) {
|
||||
tracker.updateEntityData(entityData);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -333,7 +338,7 @@ public class EntityPacketRewriter1_8 extends VREntityRewriter<ClientboundPackets
|
||||
map(Types.SHORT); // Current item
|
||||
map(Types1_8.ENTITY_DATA_LIST, Types1_7_6_10.ENTITY_DATA_LIST); // Entity data
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_7_6_10.ENTITY_DATA_LIST, EntityTypes1_8.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_7_6_10.ENTITY_DATA_LIST, EntityTypes1_8.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
protocol.registerClientbound(ClientboundPackets1_8.SET_EQUIPPED_ITEM, new PacketHandlers() {
|
||||
|
||||
+15
-2
@@ -18,6 +18,7 @@
|
||||
package com.viaversion.viarewind.protocol.v1_8to1_7_6_10.rewriter;
|
||||
|
||||
import com.viaversion.viarewind.ViaRewind;
|
||||
import com.viaversion.viarewind.api.type.version.Types1_7_6_10;
|
||||
import com.viaversion.viarewind.protocol.v1_7_6_10to1_7_2_5.packet.ClientboundPackets1_7_2_5;
|
||||
import com.viaversion.viarewind.protocol.v1_8to1_7_6_10.Protocol1_8To1_7_6_10;
|
||||
import com.viaversion.viarewind.protocol.v1_7_6_10to1_7_2_5.packet.ServerboundPackets1_7_2_5;
|
||||
@@ -30,7 +31,6 @@ import com.viaversion.viarewind.api.minecraft.math.Ray3d;
|
||||
import com.viaversion.viarewind.api.minecraft.math.RayTracing;
|
||||
import com.viaversion.viarewind.api.minecraft.math.Vector3d;
|
||||
import com.viaversion.viaversion.api.Via;
|
||||
import com.viaversion.viaversion.api.minecraft.BlockPosition;
|
||||
import com.viaversion.viaversion.api.minecraft.Environment;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_8;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
@@ -110,6 +110,18 @@ public class PlayerPacketRewriter1_8 {
|
||||
tracker.clearEntities();
|
||||
tracker.addEntity(tracker.clientEntityId(), EntityTypes1_8.EntityType.PLAYER);
|
||||
}
|
||||
|
||||
wrapper.send(Protocol1_8To1_7_6_10.class);
|
||||
wrapper.cancel();
|
||||
|
||||
if (tracker.getEntityData().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
// 1.8 clients do keep entity data after respawn, 1.7 clients don't
|
||||
final PacketWrapper setEntityData = PacketWrapper.create(ClientboundPackets1_7_2_5.SET_ENTITY_DATA, wrapper.user());
|
||||
setEntityData.write(Types.VAR_INT, tracker.clientEntityId());
|
||||
setEntityData.write(Types1_7_6_10.ENTITY_DATA_LIST, tracker.getEntityData());
|
||||
setEntityData.send(Protocol1_8To1_7_6_10.class);
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -445,6 +457,7 @@ public class PlayerPacketRewriter1_8 {
|
||||
});
|
||||
|
||||
protocol.cancelClientbound(ClientboundPackets1_8.TAB_LIST);
|
||||
protocol.cancelClientbound(ClientboundPackets1_8.PLAYER_COMBAT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_8.RESOURCE_PACK, ClientboundPackets1_7_2_5.CUSTOM_PAYLOAD, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -664,7 +677,7 @@ public class PlayerPacketRewriter1_8 {
|
||||
protocol.registerServerbound(ServerboundPackets1_7_2_5.SIGN_UPDATE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Types.BLOCK_POSITION1_8, RewindTypes.SHORT_POSITION); // Position
|
||||
map(RewindTypes.SHORT_POSITION, Types.BLOCK_POSITION1_8); // Position
|
||||
handler(wrapper -> {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
final String line = wrapper.read(Types.STRING);
|
||||
|
||||
-1
@@ -263,7 +263,6 @@ public class WorldPacketRewriter1_8 {
|
||||
});
|
||||
|
||||
protocol.cancelClientbound(ClientboundPackets1_8.CHANGE_DIFFICULTY);
|
||||
protocol.cancelClientbound(ClientboundPackets1_8.PLAYER_COMBAT);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_8.SET_BORDER, null, wrapper -> {
|
||||
final WorldBorderEmulator emulator = wrapper.user().get(WorldBorderEmulator.class);
|
||||
|
||||
+23
@@ -24,6 +24,8 @@ import com.viaversion.viarewind.protocol.v1_8to1_7_6_10.data.VirtualHologramEnti
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityType;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_8;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.item.Item;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
@@ -35,6 +37,8 @@ import com.viaversion.viaversion.libs.fastutil.objects.Object2IntMap;
|
||||
import com.viaversion.viaversion.libs.fastutil.objects.Object2IntOpenHashMap;
|
||||
import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_8;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.logging.Level;
|
||||
@@ -46,6 +50,8 @@ public class EntityTracker1_8 extends EntityTrackerBase {
|
||||
private final Int2ObjectMap<UUID> entityIdToUUID = new Int2ObjectArrayMap<>();
|
||||
private final Object2IntMap<UUID> entityUUIDToId = new Object2IntOpenHashMap<>();
|
||||
|
||||
private List<EntityData> entityData = new ArrayList<>();
|
||||
|
||||
public int spectatingClientEntityId = -1;
|
||||
private int clientEntityGameMode;
|
||||
|
||||
@@ -180,4 +186,21 @@ public class EntityTracker1_8 extends EntityTrackerBase {
|
||||
public void setClientEntityGameMode(int clientEntityGameMode) {
|
||||
this.clientEntityGameMode = clientEntityGameMode;
|
||||
}
|
||||
|
||||
public void updateEntityData(List<EntityData> entityData) {
|
||||
entityData.removeIf(first -> entityData.stream().anyMatch(second -> first.id() == second.id()));
|
||||
for (final EntityData data : entityData) {
|
||||
final Object value = data.value();
|
||||
if (value instanceof Item item) {
|
||||
entityData.add(new EntityData(data.id(), data.dataType(), item.copy()));
|
||||
} else {
|
||||
entityData.add(new EntityData(data.id(), data.dataType(), value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public List<EntityData> getEntityData() {
|
||||
return entityData;
|
||||
}
|
||||
|
||||
}
|
||||
-4
@@ -41,10 +41,6 @@ public class EntityDataIndex1_8 {
|
||||
}
|
||||
|
||||
public static EntityDataIndex1_9 searchIndex(final EntityType type, final int index) {
|
||||
if (type == null) {
|
||||
// Plugins sending metadata before an entity is spawned, causing exceptions while the game ignores them.
|
||||
return null;
|
||||
}
|
||||
EntityType currentType = type;
|
||||
do {
|
||||
final Optional<EntityDataIndex1_9> optMeta = getIndex(currentType, index);
|
||||
|
||||
+1
-2
@@ -22,14 +22,13 @@ import com.viaversion.viaversion.protocols.v1_8to1_9.data.PotionIdMappings1_9;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
// TODO | Check if this is correct???
|
||||
public class PotionIdMappings1_8 {
|
||||
public static final Map<String, String> POTION_NAME_INDEX = new HashMap<>();
|
||||
public static final Map<String, Integer> POTION_NAME_TO_ID = new HashMap<>();
|
||||
|
||||
static {
|
||||
POTION_NAME_TO_ID.putAll(PotionIdMappings1_9.POTION_NAME_TO_ID);
|
||||
POTION_NAME_TO_ID.put("luck", 8203);
|
||||
POTION_NAME_TO_ID.put("luck", 8203); // Map new potion to similar one (luck->leaping)
|
||||
|
||||
POTION_NAME_INDEX.put("water", "§rWater Bottle");
|
||||
POTION_NAME_INDEX.put("mundane", "§rMundane Potion");
|
||||
|
||||
+23
-17
@@ -194,15 +194,11 @@ public class BlockItemPacketRewriter1_9 extends VRBlockItemRewriter<ClientboundP
|
||||
super.handleItemToClient(connection, item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) {
|
||||
item.setTag(tag = new CompoundTag());
|
||||
}
|
||||
|
||||
enchantmentRewriter.handleToClient(item);
|
||||
|
||||
CompoundTag displayTag = tag.getCompoundTag("display");
|
||||
if (item.data() != 0 && tag.contains("Unbreakable")) {
|
||||
final ByteTag unbreakableTag = tag.getByteTag("Unbreakable");
|
||||
CompoundTag displayTag = tag == null ? null : tag.getCompoundTag("display");
|
||||
if (item.data() != 0) {
|
||||
final ByteTag unbreakableTag = tag == null ? null : tag.getByteTag("Unbreakable");
|
||||
if (unbreakableTag != null && unbreakableTag.asByte() != 0) {
|
||||
tag.put(nbtTagName() + "|Unbreakable", new ByteTag(unbreakableTag.asByte()));
|
||||
tag.remove("Unbreakable");
|
||||
@@ -222,7 +218,7 @@ public class BlockItemPacketRewriter1_9 extends VRBlockItemRewriter<ClientboundP
|
||||
|
||||
if (item.identifier() == 383 && item.data() == 0) { // Spawn eggs
|
||||
int data = 0;
|
||||
final CompoundTag entityTag = tag.getCompoundTag("EntityTag");
|
||||
final CompoundTag entityTag = tag == null ? null : tag.getCompoundTag("EntityTag");
|
||||
if (entityTag != null) {
|
||||
final StringTag idTag = entityTag.getStringTag("id");
|
||||
if (idTag != null) {
|
||||
@@ -246,7 +242,7 @@ public class BlockItemPacketRewriter1_9 extends VRBlockItemRewriter<ClientboundP
|
||||
|
||||
if (potion || splashPotion || lingeringPotion) {
|
||||
int data = 0;
|
||||
final StringTag potionTag = tag.getStringTag("Potion");
|
||||
final StringTag potionTag = tag == null ? null : tag.getStringTag("Potion");
|
||||
if (potionTag != null) {
|
||||
String potionName = Key.stripMinecraftNamespace(potionTag.getValue());
|
||||
if (PotionIdMappings1_8.POTION_NAME_TO_ID.containsKey(potionName)) {
|
||||
@@ -272,7 +268,7 @@ public class BlockItemPacketRewriter1_9 extends VRBlockItemRewriter<ClientboundP
|
||||
item.setData((short) data);
|
||||
}
|
||||
|
||||
final ListTag<CompoundTag> attributeModifiers = tag.getListTag("AttributeModifiers", CompoundTag.class);
|
||||
final ListTag<CompoundTag> attributeModifiers = tag == null ? null : tag.getListTag("AttributeModifiers", CompoundTag.class);
|
||||
if (attributeModifiers != null) {
|
||||
tag.put(nbtTagName() + "|AttributeModifiers", attributeModifiers.copy());
|
||||
attributeModifiers.getValue().removeIf(entries -> {
|
||||
@@ -290,14 +286,14 @@ public class BlockItemPacketRewriter1_9 extends VRBlockItemRewriter<ClientboundP
|
||||
super.handleItemToServer(connection, item);
|
||||
|
||||
CompoundTag tag = item.tag();
|
||||
if (tag == null) {
|
||||
item.setTag(tag = new CompoundTag());
|
||||
}
|
||||
|
||||
enchantmentRewriter.handleToServer(item);
|
||||
|
||||
if (item.identifier() == 383 && item.data() != 0) { // Spawn eggs
|
||||
if (!tag.contains("EntityTag") && EntityIds1_8.ENTITY_ID_TO_NAME.containsKey((int) item.data())) {
|
||||
if ((tag == null || !tag.contains("EntityTag")) && EntityIds1_8.ENTITY_ID_TO_NAME.containsKey((int) item.data())) {
|
||||
if (tag == null) {
|
||||
item.setTag(tag = new CompoundTag());
|
||||
}
|
||||
final CompoundTag entityTag = new CompoundTag();
|
||||
entityTag.put("id", new StringTag(EntityIds1_8.ENTITY_ID_TO_NAME.get((int) item.data())));
|
||||
tag.put("EntityTag", entityTag);
|
||||
@@ -305,20 +301,30 @@ public class BlockItemPacketRewriter1_9 extends VRBlockItemRewriter<ClientboundP
|
||||
item.setData((short) 0);
|
||||
}
|
||||
|
||||
if (item.identifier() == 373 && !tag.contains("Potion")) { // Potions
|
||||
if (item.identifier() == 373 && (tag == null || !tag.contains("Potion"))) { // Potions
|
||||
if (item.data() >= 16384) {
|
||||
item.setIdentifier(438);
|
||||
item.setData((short) (item.data() - 8192));
|
||||
}
|
||||
|
||||
final String name = item.data() == 8192 ? "water" : PotionIdMappings1_9.potionNameFromDamage(item.data());
|
||||
tag.put("Potion", new StringTag("minecraft:" + name));
|
||||
if (tag == null) {
|
||||
item.setTag(tag = new CompoundTag());
|
||||
|
||||
final String name = item.data() == 8192 ? "water" : PotionIdMappings1_9.potionNameFromDamage(item.data());
|
||||
tag.put("Potion", new StringTag("minecraft:" + name));
|
||||
}
|
||||
item.setData((short) 0);
|
||||
}
|
||||
|
||||
if (tag == null) {
|
||||
return item;
|
||||
}
|
||||
final Tag noDisplayTag = tag.remove(nbtTagName() + "|noDisplay");
|
||||
if (noDisplayTag != null) {
|
||||
tag.remove("display");
|
||||
if (tag.isEmpty()) {
|
||||
item.setTag(null);
|
||||
}
|
||||
}
|
||||
final Tag unbreakableTag = tag.remove(nbtTagName() + "|Unbreakable");
|
||||
if (unbreakableTag != null) {
|
||||
|
||||
+13
-2
@@ -64,7 +64,18 @@ public class EntityPacketRewriter1_9 extends VREntityRewriter<ClientboundPackets
|
||||
protected void registerPackets() {
|
||||
registerJoinGame1_8(ClientboundPackets1_9.LOGIN);
|
||||
registerRemoveEntities(ClientboundPackets1_9.REMOVE_ENTITIES);
|
||||
registerSetEntityData(ClientboundPackets1_9.SET_ENTITY_DATA, Types1_9.ENTITY_DATA_LIST, Types1_8.ENTITY_DATA_LIST);
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9.SET_ENTITY_DATA, wrapper -> {
|
||||
final int entityId = wrapper.passthrough(Types.VAR_INT);
|
||||
if (!tracker(wrapper.user()).hasEntity(entityId)) {
|
||||
wrapper.cancel();
|
||||
return;
|
||||
}
|
||||
final List<EntityData> entityData = wrapper.read(Types1_9.ENTITY_DATA_LIST);
|
||||
handleEntityData(entityId, entityData, wrapper.user());
|
||||
|
||||
wrapper.write(Types1_8.ENTITY_DATA_LIST, entityData);
|
||||
});
|
||||
|
||||
protocol.registerClientbound(ClientboundPackets1_9.ADD_ENTITY, new PacketHandlers() {
|
||||
@Override
|
||||
@@ -218,7 +229,7 @@ public class EntityPacketRewriter1_9 extends VREntityRewriter<ClientboundPackets
|
||||
create(Types.SHORT, (short) 0); // Current item
|
||||
map(Types1_9.ENTITY_DATA_LIST, Types1_8.ENTITY_DATA_LIST); // Entity data
|
||||
|
||||
handler(getTrackerAndMetaHandler(Types1_8.ENTITY_DATA_LIST, EntityTypes1_9.EntityType.PLAYER));
|
||||
handler(getTrackerAndDataHandler(Types1_8.ENTITY_DATA_LIST, EntityTypes1_9.EntityType.PLAYER));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+29
-1
@@ -28,7 +28,6 @@ import com.viaversion.viaversion.api.minecraft.entitydata.EntityData;
|
||||
import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_8;
|
||||
import com.viaversion.viaversion.api.protocol.packet.PacketWrapper;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.rewriter.ItemRewriter;
|
||||
import com.viaversion.viaversion.api.type.Types;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_8;
|
||||
import com.viaversion.viaversion.libs.gson.JsonElement;
|
||||
@@ -174,6 +173,35 @@ public class PlayerPacketRewriter1_9 {
|
||||
}
|
||||
});
|
||||
|
||||
// Packet implementation doesn't do anything until 1.9
|
||||
protocol.registerClientbound(ClientboundPackets1_9.PLAYER_COMBAT, wrapper -> {
|
||||
final int action = wrapper.passthrough(Types.VAR_INT);
|
||||
if (action != 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
final EntityTracker1_9 tracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
final int entityId = wrapper.passthrough(Types.VAR_INT);
|
||||
wrapper.passthrough(Types.INT); // Killer id
|
||||
|
||||
if (entityId != tracker.clientEntityId()) {
|
||||
return;
|
||||
}
|
||||
|
||||
final JsonElement message = wrapper.passthrough(Types.COMPONENT);
|
||||
|
||||
final PacketWrapper killPlayer = wrapper.create(ClientboundPackets1_8.SET_HEALTH);
|
||||
killPlayer.write(Types.FLOAT, 0F); // Health
|
||||
killPlayer.write(Types.VAR_INT, 0); // Food
|
||||
killPlayer.write(Types.FLOAT, 0F); // Food Saturation
|
||||
killPlayer.scheduleSend(Protocol1_9To1_8.class);
|
||||
|
||||
final PacketWrapper chatMessage = wrapper.create(ClientboundPackets1_8.CHAT);
|
||||
chatMessage.write(Types.COMPONENT, message);
|
||||
chatMessage.write(Types.BYTE, (byte) 1); // Position - in chat
|
||||
chatMessage.scheduleSend(Protocol1_9To1_8.class);
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_8.CHAT, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
|
||||
+14
-3
@@ -1,10 +1,21 @@
|
||||
plugins {
|
||||
id "vr.java-conventions"
|
||||
id "vr.platform-conventions"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "FabricMC"
|
||||
url "https://maven.fabricmc.net/"
|
||||
}
|
||||
}
|
||||
|
||||
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"))
|
||||
}
|
||||
|
||||
processResources {
|
||||
filesMatching("fabric.mod.json") {
|
||||
expand("version": project.version, "description": project.description)
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
maven_name=viarewind-fabric
|
||||
@@ -25,7 +25,7 @@
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.0",
|
||||
"viafabric": ">=0.4.10",
|
||||
"viabackwards": "*"
|
||||
"viabackwards": ">=5.0.0"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu:api": true,
|
||||
|
||||
+4
-3
@@ -3,12 +3,13 @@ org.gradle.jvmargs=-Xmx8G
|
||||
org.gradle.parallel=true
|
||||
|
||||
# project
|
||||
maven_version=4.0.1
|
||||
maven_group=com.viaversion
|
||||
maven_version=4.0.2
|
||||
maven_description=ViaBackwards addon to allow 1.8.x and 1.7.x clients on newer server versions.
|
||||
|
||||
# libraries
|
||||
viaversion_version=5.0.0
|
||||
viabackwards_version=5.0.0
|
||||
viaversion_version=5.0.2
|
||||
viabackwards_version=5.0.2
|
||||
netty_version=4.0.20.Final
|
||||
guava_version=17.0
|
||||
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
|
||||
networkTimeout=10000
|
||||
validateDistributionUrl=true
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
|
||||
+5
-13
@@ -1,4 +1,4 @@
|
||||
import java.util.function.Consumer
|
||||
rootProject.name = "viarewind"
|
||||
|
||||
includeBuild("build-logic")
|
||||
|
||||
@@ -7,17 +7,9 @@ setupViaSubproject("bukkit")
|
||||
setupViaSubproject("fabric")
|
||||
setupViaSubproject("velocity")
|
||||
|
||||
setupSubproject("viarewind", project -> {
|
||||
project.projectDir = file("universal")
|
||||
})
|
||||
|
||||
void setupViaSubproject(String name) {
|
||||
setupSubproject("viarewind-" + name, project -> {
|
||||
project.projectDir = file(name)
|
||||
})
|
||||
}
|
||||
var pName = "viarewind-" + name
|
||||
|
||||
void setupSubproject(String name, Consumer<ProjectDescriptor> block) {
|
||||
include name
|
||||
block.accept(project(":" + name))
|
||||
}
|
||||
include pName
|
||||
project(":" + pName).projectDir = file(name)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
maven_name=viarewind
|
||||
@@ -1,9 +1,15 @@
|
||||
plugins {
|
||||
id "vr.java-conventions"
|
||||
id "vr.platform-conventions"
|
||||
}
|
||||
|
||||
repositories {
|
||||
maven {
|
||||
name = "VelocityPowered"
|
||||
url "https://nexus.velocitypowered.com/repository/maven-public/"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
api project(":viarewind-common")
|
||||
|
||||
compileOnly("com.viaversion:viaversion-velocity:5.0.0") // Needed for logger wrapper
|
||||
compileOnly(annotationProcessor("com.velocitypowered:velocity-api:3.1.1"))
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
maven_name=viarewind-velocity
|
||||
@@ -21,7 +21,6 @@ import com.google.inject.Inject;
|
||||
import com.velocitypowered.api.event.PostOrder;
|
||||
import com.velocitypowered.api.event.Subscribe;
|
||||
import com.velocitypowered.api.event.proxy.ProxyInitializeEvent;
|
||||
import com.velocitypowered.api.event.proxy.ProxyReloadEvent;
|
||||
import com.velocitypowered.api.plugin.Dependency;
|
||||
import com.velocitypowered.api.plugin.Plugin;
|
||||
import com.velocitypowered.api.plugin.annotation.DataDirectory;
|
||||
|
||||
Reference in new issue
Block a user