mirror of
https://github.com/ViaVersion/ViaRewind.git
synced 2026-11-04 17:00:20 -05:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7d6c75ad31 | ||
|
|
0bb7be88ff | ||
|
|
4b7264c944 | ||
|
|
db6afa5b1b | ||
|
|
02f55edb0c | ||
|
|
5ef900a61e | ||
|
|
4fe7e35f6b | ||
|
|
1af08ced41 | ||
|
|
fd1d3ed221 | ||
|
|
1d6ef8833f | ||
|
|
f2e2f18511 | ||
|
|
2adf7757f0 |
No files matched your search
@@ -10,16 +10,16 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
|
||||
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
|
||||
with:
|
||||
cache-disabled: false
|
||||
cache-provider: basic
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5.3.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
||||
@@ -15,16 +15,16 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout Repository
|
||||
uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
|
||||
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
|
||||
with:
|
||||
persist-credentials: false
|
||||
- name: Set up Gradle
|
||||
uses: gradle/actions/setup-gradle@50e97c2cd7a37755bbfafc9c5b7cafaece252f6e # v6.1.0
|
||||
uses: gradle/actions/setup-gradle@3f131e8634966bd73d06cc69884922b02e6faf92 # v6.2.0
|
||||
with:
|
||||
cache-disabled: false
|
||||
cache-provider: basic
|
||||
- name: Set up JDK 17
|
||||
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
|
||||
uses: actions/setup-java@ad2b38190b15e4d6bdf0c97fb4fca8412226d287 # v5.3.0
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: 17
|
||||
|
||||
+2
-2
@@ -24,8 +24,8 @@ allprojects {
|
||||
subprojects {
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.viaversion:viaversion:5.10.0")
|
||||
compileOnly("com.viaversion:viabackwards:5.10.0")
|
||||
compileOnly("com.viaversion:viaversion:5.11.0")
|
||||
compileOnly("com.viaversion:viabackwards:5.11.0")
|
||||
}
|
||||
|
||||
tasks {
|
||||
|
||||
@@ -20,6 +20,10 @@ package com.viaversion.viarewind.api.data;
|
||||
import com.viaversion.nbt.tag.CompoundTag;
|
||||
import com.viaversion.viabackwards.api.data.BackwardsMappingData;
|
||||
import com.viaversion.viarewind.ViaRewind;
|
||||
import com.viaversion.viaversion.api.data.FullMappings;
|
||||
import com.viaversion.viaversion.api.data.LegacyFullStringMappingsBase;
|
||||
import com.viaversion.viaversion.api.data.MappingDataLoader;
|
||||
import com.viaversion.viaversion.api.data.Mappings;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public class RewindMappingData extends BackwardsMappingData {
|
||||
@@ -37,4 +41,9 @@ public class RewindMappingData extends BackwardsMappingData {
|
||||
protected CompoundTag readMappingsFile(String name) {
|
||||
return RewindMappingDataLoader.INSTANCE.loadNBTFromDir(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FullMappings createFullMappings(MappingDataLoader.IdentifiersPair identifiersPair, Mappings mappings) {
|
||||
return new LegacyFullStringMappingsBase(identifiersPair, mappings);
|
||||
}
|
||||
}
|
||||
+98
-13
@@ -26,6 +26,18 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatNewlineRewriter {
|
||||
private static final String[] STYLE_KEYS = {
|
||||
"color",
|
||||
"bold",
|
||||
"italic",
|
||||
"underlined",
|
||||
"strikethrough",
|
||||
"obfuscated",
|
||||
"clickEvent",
|
||||
"hoverEvent",
|
||||
"insertion"
|
||||
};
|
||||
|
||||
public static List<JsonObject> splitChatComponentByNewline(JsonElement element) {
|
||||
return splitChatComponentByNewline(element, new JsonObject());
|
||||
}
|
||||
@@ -47,8 +59,28 @@ public class ChatNewlineRewriter {
|
||||
}
|
||||
|
||||
if (element.isJsonArray()) {
|
||||
List<JsonObject> currentLine = new ArrayList<>();
|
||||
JsonObject siblingStyle = inheritedStyle;
|
||||
boolean foundRoot = false;
|
||||
|
||||
for (JsonElement child : element.getAsJsonArray()) {
|
||||
results.addAll(splitChatComponentByNewline(child, inheritedStyle));
|
||||
List<JsonObject> splitParts = splitChatComponentByNewline(child, siblingStyle);
|
||||
for (int i = 0; i < splitParts.size(); i++) {
|
||||
currentLine.add(splitParts.get(i));
|
||||
if (i < splitParts.size() - 1) {
|
||||
results.add(mergeLine(currentLine));
|
||||
currentLine.clear();
|
||||
}
|
||||
}
|
||||
|
||||
if (!foundRoot && child != null && !child.isJsonNull()) {
|
||||
siblingStyle = rootStyle(inheritedStyle, child);
|
||||
foundRoot = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!currentLine.isEmpty()) {
|
||||
results.add(mergeLine(currentLine));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@@ -60,13 +92,7 @@ public class ChatNewlineRewriter {
|
||||
JsonObject obj = element.getAsJsonObject();
|
||||
|
||||
// Build the style for this node: inherit first, then override with this object's style
|
||||
JsonObject currentStyle = inheritedStyle.deepCopy();
|
||||
for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (!"text".equals(key) && !"extra".equals(key)) {
|
||||
currentStyle.add(key, entry.getValue());
|
||||
}
|
||||
}
|
||||
JsonObject currentStyle = mergeStyle(inheritedStyle, obj);
|
||||
|
||||
// Gather components in order: base text then extra array
|
||||
List<JsonElement> ordered = new ArrayList<>();
|
||||
@@ -81,12 +107,19 @@ public class ChatNewlineRewriter {
|
||||
|
||||
// If there is no text/extra, return a single object with the style
|
||||
if (ordered.isEmpty()) {
|
||||
results.add(currentStyle);
|
||||
JsonObject baseComponent = copyComponentWithoutExtra(obj, currentStyle);
|
||||
results.add(baseComponent != null ? baseComponent : currentStyle);
|
||||
return results;
|
||||
}
|
||||
|
||||
// Build lines by concatenating split pieces
|
||||
List<JsonObject> currentLine = new ArrayList<>();
|
||||
if (!obj.has("text")) {
|
||||
JsonObject baseComponent = copyComponentWithoutExtra(obj, currentStyle);
|
||||
if (baseComponent != null) {
|
||||
currentLine.add(baseComponent);
|
||||
}
|
||||
}
|
||||
for (JsonElement part : ordered) {
|
||||
if (part == null || part.isJsonNull()) {
|
||||
continue;
|
||||
@@ -127,6 +160,55 @@ public class ChatNewlineRewriter {
|
||||
return results;
|
||||
}
|
||||
|
||||
private static JsonObject rootStyle(JsonObject inheritedStyle, JsonElement element) {
|
||||
if (element == null || element.isJsonNull()) {
|
||||
return inheritedStyle;
|
||||
}
|
||||
if (element.isJsonObject()) {
|
||||
return mergeStyle(inheritedStyle, element.getAsJsonObject());
|
||||
}
|
||||
if (element.isJsonArray()) {
|
||||
for (JsonElement child : element.getAsJsonArray()) {
|
||||
if (child != null && !child.isJsonNull()) {
|
||||
return rootStyle(inheritedStyle, child);
|
||||
}
|
||||
}
|
||||
}
|
||||
return inheritedStyle;
|
||||
}
|
||||
|
||||
private static JsonObject mergeStyle(JsonObject inheritedStyle, JsonObject obj) {
|
||||
JsonObject currentStyle = inheritedStyle.deepCopy();
|
||||
for (String key : STYLE_KEYS) {
|
||||
if (obj.has(key)) {
|
||||
currentStyle.add(key, obj.get(key).deepCopy());
|
||||
}
|
||||
}
|
||||
return currentStyle;
|
||||
}
|
||||
|
||||
private static JsonObject copyComponentWithoutExtra(JsonObject obj, JsonObject currentStyle) {
|
||||
JsonObject component = currentStyle.deepCopy();
|
||||
for (Map.Entry<String, JsonElement> entry : obj.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if ("extra".equals(key) || isStyleKey(key)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
component.add(key, entry.getValue().deepCopy());
|
||||
}
|
||||
return component.size() == currentStyle.size() ? null : component;
|
||||
}
|
||||
|
||||
private static boolean isStyleKey(String key) {
|
||||
for (String styleKey : STYLE_KEYS) {
|
||||
if (styleKey.equals(key)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private static JsonObject mergeLine(List<JsonObject> lineParts) {
|
||||
if (lineParts.isEmpty()) {
|
||||
JsonObject empty = new JsonObject();
|
||||
@@ -139,11 +221,14 @@ public class ChatNewlineRewriter {
|
||||
return first;
|
||||
}
|
||||
|
||||
JsonObject merged = new JsonObject();
|
||||
merged.addProperty("text", "");
|
||||
|
||||
JsonArray extra = new JsonArray();
|
||||
for (int i = 1; i < lineParts.size(); i++) {
|
||||
extra.add(lineParts.get(i));
|
||||
for (JsonObject linePart : lineParts) {
|
||||
extra.add(linePart);
|
||||
}
|
||||
first.add("extra", extra);
|
||||
return first;
|
||||
merged.add("extra", extra);
|
||||
return merged;
|
||||
}
|
||||
}
|
||||
+5
-5
@@ -22,6 +22,7 @@ import com.viaversion.viarewind.protocol.v1_7_6_10to1_7_2_5.packet.ServerboundPa
|
||||
import com.viaversion.viarewind.protocol.v1_8to1_7_6_10.Protocol1_8To1_7_6_10;
|
||||
import com.viaversion.viarewind.protocol.v1_8to1_7_6_10.data.VirtualHologramEntity;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
|
||||
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;
|
||||
@@ -68,17 +69,15 @@ public class EntityTracker1_8 extends EntityTrackerBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addEntity(int id, EntityType type) {
|
||||
super.addEntity(id, type);
|
||||
public TrackedEntity addEntity(int id, EntityType type) {
|
||||
if (type == EntityTypes1_8.EntityType.ARMOR_STAND) {
|
||||
holograms.put(id, new VirtualHologramEntity(user(), id));
|
||||
}
|
||||
return super.addEntity(id, type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(int entityId) {
|
||||
super.removeEntity(entityId);
|
||||
|
||||
public TrackedEntity removeEntity(int entityId) {
|
||||
final VirtualHologramEntity hologram = holograms.get(entityId);
|
||||
if (hologram != null) {
|
||||
hologram.deleteEntity();
|
||||
@@ -95,6 +94,7 @@ public class EntityTracker1_8 extends EntityTrackerBase {
|
||||
entityUUIDToId.removeInt(playerId);
|
||||
user().get(PlayerSessionStorage.class).getPlayerEquipment().remove(playerId);
|
||||
}
|
||||
return super.removeEntity(entityId);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-1
@@ -334,7 +334,12 @@ public class PlayerPacketRewriter1_9 extends RewriterBase<Protocol1_9To1_8> {
|
||||
final PlayerPositionTracker storage = wrapper.user().get(PlayerPositionTracker.class);
|
||||
storage.sendAnimations();
|
||||
if (storage.getConfirmId() != -1) {
|
||||
if (storage.getPosX() == x && storage.getPosY() == y && storage.getPosZ() == z && storage.getYaw() == yaw && storage.getPitch() == pitch) {
|
||||
// 1.7 uses resynced hitbox minY for y however this can have small floating point error due to the calculations it does to get there on teleport confirm
|
||||
// This Y error gets propagated from 1.7 to 1.8 to 1.9 which causes teleport confirmation to not properly be detected
|
||||
// This fixes it similarly to how anticheats detect teleports: https://github.com/GrimAnticheat/Grim/blob/67aa3a9483a9b2a6987d594092697b4104c781f0/common/src/main/java/ac/grim/grimac/manager/SetbackTeleportUtil.java#L315
|
||||
boolean closeEnoughY = Math.abs(storage.getPosY() - y) <= 1e-7;
|
||||
|
||||
if (storage.getPosX() == x && closeEnoughY && storage.getPosZ() == z && storage.getYaw() == yaw && storage.getPitch() == pitch) {
|
||||
final PacketWrapper confirmTeleport = PacketWrapper.create(ServerboundPackets1_9.ACCEPT_TELEPORTATION, wrapper.user());
|
||||
confirmTeleport.write(Types.VAR_INT, storage.getConfirmId());
|
||||
confirmTeleport.sendToServer(Protocol1_9To1_8.class);
|
||||
|
||||
+5
-2
@@ -92,9 +92,12 @@ public class WorldPacketRewriter1_9 extends RewriterBase<Protocol1_9To1_8> {
|
||||
String name = wrapper.get(Types.STRING, 0);
|
||||
name = protocol.getMappingData().getMappedNamedSound(name);
|
||||
if (name == null) {
|
||||
wrapper.cancel();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if (!name.isEmpty()) {
|
||||
wrapper.set(Types.STRING, 0, name);
|
||||
} else {
|
||||
wrapper.cancel();
|
||||
}
|
||||
});
|
||||
read(Types.VAR_INT); // Sound category
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@
|
||||
package com.viaversion.viarewind.protocol.v1_9to1_8.storage;
|
||||
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.data.entity.TrackedEntity;
|
||||
import com.viaversion.viaversion.api.minecraft.Vector;
|
||||
import com.viaversion.viaversion.api.minecraft.entities.EntityTypes1_9;
|
||||
import com.viaversion.viaversion.data.entity.EntityTrackerBase;
|
||||
@@ -41,14 +42,14 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeEntity(int id) {
|
||||
public TrackedEntity removeEntity(int id) {
|
||||
vehicles.remove(id);
|
||||
offsets.remove(id);
|
||||
status.remove(id);
|
||||
|
||||
vehicles.forEach((vehicle, passengers) -> passengers.rem(id));
|
||||
vehicles.int2ObjectEntrySet().removeIf(entry -> entry.getValue().isEmpty());
|
||||
super.removeEntity(id);
|
||||
return super.removeEntity(id);
|
||||
}
|
||||
|
||||
public void resetEntityOffset(final int id) {
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -24,7 +24,7 @@
|
||||
},
|
||||
"depends": {
|
||||
"viafabric": ">=0.4.14",
|
||||
"viabackwards": ">=5.7.2"
|
||||
"viabackwards": ">=5.11.0"
|
||||
},
|
||||
"custom": {
|
||||
"modmenu:api": true,
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ org.gradle.configuration-cache=true
|
||||
project_jvm_version=17
|
||||
|
||||
project_group=com.viaversion
|
||||
project_version=4.1.2
|
||||
project_version=4.1.3
|
||||
project_description=ViaVersion addon to allow 1.8.x and 1.7.x clients on newer server versions.
|
||||
|
||||
publishing_dev_id=florianreuth
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionSha256Sum=bafc141b619ad6350fd975fc903156dd5c151998cc8b058e8c1044ab5f7b031f
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.5.1-bin.zip
|
||||
distributionSha256Sum=bbaeb2fef8710818cf0e261201dab964c572f92b942812df0c3620d62a529a01
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
|
||||
networkTimeout=10000
|
||||
retries=0
|
||||
retryBackOffMs=500
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
##############################################################################
|
||||
#
|
||||
# Gradle start up script for POSIX generated by Gradle.
|
||||
# gradlew start up script for POSIX generated by Gradle.
|
||||
#
|
||||
# Important for running:
|
||||
#
|
||||
@@ -29,7 +29,7 @@
|
||||
# bash, then to run this script, type that shell name before the whole
|
||||
# command line, like:
|
||||
#
|
||||
# ksh Gradle
|
||||
# ksh gradlew
|
||||
#
|
||||
# Busybox and similar reduced shells will NOT work, because this script
|
||||
# requires all of these POSIX shell features:
|
||||
|
||||
Vendored
+2
-2
@@ -19,7 +19,7 @@
|
||||
@if "%DEBUG%"=="" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem gradlew startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@@ -72,7 +72,7 @@ echo location of your Java installation. 1>&2
|
||||
|
||||
|
||||
|
||||
@rem Execute Gradle
|
||||
@rem Execute gradlew
|
||||
@rem endlocal doesn't take effect until after the line is parsed and variables are expanded
|
||||
@rem which allows us to clear the local environment before executing the java command
|
||||
endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel
|
||||
|
||||
@@ -36,11 +36,11 @@
|
||||
},
|
||||
{
|
||||
"id": "viaversion",
|
||||
"version": "[5.7.2,)"
|
||||
"version": "[5.11.0,)"
|
||||
},
|
||||
{
|
||||
"id": "viabackwards",
|
||||
"version": "[5.7.2,)"
|
||||
"version": "[5.11.0,)"
|
||||
}
|
||||
]
|
||||
},
|
||||
|
||||
Reference in new issue
Block a user