Skip to content

Commit

Permalink
Merge dev branch
Browse files Browse the repository at this point in the history
merge branch dev into main #253
  • Loading branch information
creeper123123321 authored Jun 8, 2023
2 parents fda8d39 + aa797ef commit 73bb621
Show file tree
Hide file tree
Showing 102 changed files with 2,043 additions and 127 deletions.
53 changes: 26 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@

[![ViaVersion Discord](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://viaversion.com/discord)
[![CurseForge Downloads](http://cf.way2muchnoise.eu/full_viafabric_downloads.svg)](https://viaversion.com/fabric)
[![Modrinth Downloads](https://img.shields.io/modrinth/dt/ViaFabric?label=Modrinth&logo=Modrinth&style=flat-square)](https://modrinth.com/mod/ViaFabric)
[![CurseForge Versions](http://cf.way2muchnoise.eu/versions/viafabric.svg)](https://viaversion.com/fabric)
[![Download on Modrinth](https://img.shields.io/badge/download-modrinth-green)](https://modrinth.com/mod/viafabric)
<!-- ^ GitHub seems to not like this https -->

### Client-side and server-side ViaVersion implementation for Fabric

Allows the connection to/from different Minecraft versions on your Minecraft client/server (LAN worlds too)

This mod can be installed on 1.8.9, 1.14.4, 1.15.2, 1.16.5, 1.17.1, 1.18.2 with Fabric Loader.
This mod can be installed on 1.8.9, 1.14.4, 1.15.2, 1.16.5, 1.17.1, 1.18.2, 1.19.4, 1.20 with Fabric Loader.

## Dependencies

| Dependency | Download |
|-----------------------------------------------|----------------------------------------------------------------|
| (Bundled) ViaVersion | https://viaversion.com/ |
| (Bundled) Cotton Client Commands (MC 1.14-15) | https://jitpack.io/#TinfoilMC/ClientCommands |
| Fabric API (MC 1.14+) | https://www.curseforge.com/minecraft/mc-mods/fabric-api |
| Legacy Fabric API (MC 1.8.9) | https://www.curseforge.com/minecraft/mc-mods/legacy-fabric-api |
| Fabric API (MC 1.14+) | https://modrinth.com/mod/fabric-api |
| Legacy Fabric API (MC 1.8.9) | https://modrinth.com/mod/legacy-fabric-api |

Note: ViaVersion is designed for Vanilla Minecraft servers. It probably will not work with modded registry entries or
registry synchronization (fabric-registry-sync mod).
Expand Down Expand Up @@ -47,15 +47,16 @@ registry synchronization (fabric-registry-sync mod).

- Client-side:

| | 1.8.x | 1.9.x | 1.10-1.14.4 | 1.15.x | 1.16.x | 1.17.x | 1.18.x | 1.19.x |
|---------------|-------|-------|-------------|--------|--------|--------|--------|--------|
| 1.8.9 client |||||||||
| 1.14.x client |||||||||
| 1.15.x client |||||||||
| 1.16.x client |||||||||
| 1.17.x client |||||||||
| 1.18.x client |||||||||
| 1.19.x client |||||||||
| | 1.8.x | 1.9.x | 1.10-1.14.4 | 1.15.x | 1.16.x | 1.17.x | 1.18.x | 1.19.x | 1.20.x |
|---------------|-------|-------|-------------|--------|--------|--------|--------|--------|--------|
| 1.8.9 client ||||||||||
| 1.14.x client ||||||||||
| 1.15.x client ||||||||||
| 1.16.x client ||||||||||
| 1.17.x client ||||||||||
| 1.18.x client ||||||||||
| 1.19.x client ||||||||||
| 1.20.x client ||||||||||

✓ = [ViaVersion](https://viaversion.com) ⟲ = [ViaBackwards](https://viaversion.com/backwards)
= [ViaRewind](https://viaversion.com/rewind)
Expand All @@ -71,8 +72,8 @@ registry synchronization (fabric-registry-sync mod).
- [ClientViaVersion](https://github.com/Gerrygames/ClientViaVersion): Discontinued 5zig plugin.
- [multiconnect](https://www.curseforge.com/minecraft/mc-mods/multiconnect): Fabric mod for connecting to older
versions: down to 1.11 (stable) and 1.8 (experimental).
- [ViaForge](https://www.curseforge.com/minecraft/mc-mods/viaforge): Fork of ViaFabric porting it to Forge.
- [ViaFabricPlus](https://www.curseforge.com/minecraft/mc-mods/viafabricplus): Fabric ViaVersion/ViaLegacy/ViaAprilFools implementation with clientside fixes
- [ViaForge](https://www.modrinth.com/mod/viaforge): Fork of ViaFabric porting it to Forge.
- [ViaFabricPlus](https://www.modrinth.com/mod/viafabricplus): Fabric ViaVersion/ViaLegacy/ViaAprilFools implementation with client-side fixes.

### Server-side:

Expand Down Expand Up @@ -128,22 +129,20 @@ registry synchronization (fabric-registry-sync mod).
- Examples: ``minigame.example.com._v1_8.viafabric``, ``native.example.com._v-1.viafabric``
, ``auto.example.com._v-2.viafabric``

## multiconnect
## ViaFabricPlus

### Does it work with multiconnect at same time on client?:
### Does it work with ViaFabric:

- Yes, ViaFabric can be used with multiconnect. ViaFabric will send to its version auto detector the closest non-beta
supported version. (multiconnect beta-supported versions are currently < 1.11))
- No, ViaFabric cannot be used with ViaFabricPlus.

### Differences with multiconnect:
### Differences with ViaFabricPlus:

| | ViaVersion | multiconnect |
|------------------------|-----------------------------------|-----------------------------------------------|
| Designed for | servers | clients |
| Can be installed on | multiple client/server versions | latest client version |
| Objectives | simply implement ViaVersion | version support with fixes to version changes |
| How does it work? | modifying packets at network code | modifying client code more deeply |
| Triggering anti-cheats | very likely | less likely |
| | ViaFabric | ViaFabricPlus |
|----------------------------------|-------------------------------------------------|-----------------------------------------------------------------|
| Can be installed on | Multiple client/server versions with fabric | Latest client-side version with fabric |
| Objectives | Simply implement ViaVersion | Implements ViaVersion with client-side fixes to version changes |
| How does it work? | Modifying packets at network code | Modifying client code more deeply |
| Triggering anti-cheats | Very likely | Mostly not |

## Disclaimer

Expand Down
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,18 @@ import java.util.stream.IntStream
plugins {
id "java"
id "maven-publish"
id "org.ajoberstar.grgit" version "3.1.1"
id "org.ajoberstar.grgit" version "5.2.0"
id "com.matthewprenger.cursegradle" version "1.4.0"
id "com.modrinth.minotaur" version "2.2.0"
id "fabric-loom" version "1.1-SNAPSHOT" apply false
id "com.github.ben-manes.versions" version "0.42.0"
id "com.modrinth.minotaur" version "2.7.5"
id "fabric-loom" version "1.2-SNAPSHOT" apply false
id "com.github.ben-manes.versions" version "0.46.0"
}

def ENV = System.getenv()

group = "com.viaversion.fabric"
description = "Client-side and server-side ViaVersion implementation for Fabric"
version = "0.4.9+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
version = "0.4.10+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
logger.lifecycle("Building ViaFabric: $version")

def getBranch() {
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# rip my ram
org.gradle.jvmargs=-Xms32M -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication

loader_version=0.14.14
viaver_version=4.6.3-SNAPSHOT
loader_version=0.14.21
viaver_version=4.7.0
yaml_version=2.0

publish_mc_versions=1.19.4, 1.18.2, 1.17.1, 1.16.5, 1.15.2, 1.14.4, 1.8.9
# example: 1.19.1-rc2
publish_mc_versions=1.20, 1.19.4, 1.18.2, 1.17.1, 1.16.5, 1.15.2, 1.14.4, 1.8.9
# example: 1.19.1-rc1. Can be a blank value
modrinth_mc_snapshot=
# example: 1.19-Snapshot
# example: 1.19-Snapshot. Can be a blank value
curseforge_mc_snapshot=
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
12 changes: 8 additions & 4 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# 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"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -133,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
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.
Expand Down Expand Up @@ -197,6 +197,10 @@ if "$cygwin" || "$msys" ; then
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='-Dfile.encoding=UTF-8 "-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
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set APP_HOME=%DIRNAME%
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"
set DEFAULT_JVM_OPTS=-Dfile.encoding=UTF-8 "-Xmx64m" "-Xms64m"

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
4 changes: 2 additions & 2 deletions jitpack.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
before_install:
- curl -s "https://get.sdkman.io" | bash
- source "$HOME/.sdkman/bin/sdkman-init.sh"
- sdk install java 17.0.5+8-tem
- sdk use java 17.0.5+8-tem
- sdk install java 17.0.7+7-tem
- sdk use java 17.0.7+7-tem
4 changes: 2 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ include("viafabric-mc116")
include("viafabric-mc117")
include("viafabric-mc118")
include("viafabric-mc119")

include("viafabric-mc120")

plugins {
id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0"
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@ private void reorder(ChannelHandlerContext ctx) {
int decoderIndex = ctx.pipeline().names().indexOf("decompress");
if (decoderIndex == -1) return;

if (decoderIndex > ctx.pipeline().names().indexOf("via-decoder")) {
ChannelHandler encoder = ctx.pipeline().get("via-encoder");
ChannelHandler decoder = ctx.pipeline().get("via-decoder");
if (decoderIndex > ctx.pipeline().names().indexOf(CommonTransformer.HANDLER_DECODER_NAME)) {
ChannelHandler encoder = ctx.pipeline().get(CommonTransformer.HANDLER_ENCODER_NAME);
ChannelHandler decoder = ctx.pipeline().get(CommonTransformer.HANDLER_DECODER_NAME);

ctx.pipeline().remove(encoder);
ctx.pipeline().remove(decoder);

ctx.pipeline().addAfter("compress", "via-encoder", encoder);
ctx.pipeline().addAfter("decompress", "via-decoder", decoder);
ctx.pipeline().addAfter("compress", CommonTransformer.HANDLER_ENCODER_NAME, encoder);
ctx.pipeline().addAfter("decompress", CommonTransformer.HANDLER_DECODER_NAME, decoder);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/assets/viafabric/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"gui.viafabric_config.title": "ViaFabric Configurations",
"gui.client_side.enable": "Enable client-side",
"gui.client_side.disable": "Disable client-side",
"gui.ping_version.translated": "VIA: %s",
"gui.ping_version.translated": "VIA: %s (%s)",
"gui.hide_via_button.enable": "Hide VIA button",
"gui.hide_via_button.disable": "Show VIA button",
"gui.via_button": "VIA"
Expand Down
5 changes: 4 additions & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,12 @@
},
"depends": {
"fabricloader": ">=0.10.0",
"minecraft": ["1.8.x", "1.14.4", "1.15.2", "~1.16.4", "1.17.1", "1.18.2", "~1.19.4-alpha.23.7.a"],
"minecraft": ["1.8.x", "1.14.4", "1.15.2", "~1.16.4", "1.17.1", "1.18.2", "~1.19.4", "1.20.x"],
"viaversion": ">=4.0.0"
},
"breaks": {
"viafabricplus": "*"
},
"environment": "*",
"authors": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import com.viaversion.fabric.common.platform.FabricInjector;
import com.viaversion.fabric.common.protocol.HostnameParserProtocol;
import com.viaversion.fabric.common.util.JLoggerToLog4j;
import com.viaversion.fabric.mc114.commands.VRCommandHandler;
import com.viaversion.fabric.mc114.commands.VFCommandHandler;
import com.viaversion.fabric.mc114.platform.FabricPlatform;
import com.viaversion.fabric.mc114.platform.VFLoader;
import com.viaversion.viaversion.ViaManagerImpl;
Expand Down Expand Up @@ -48,10 +48,10 @@ public static <S extends CommandSource> LiteralArgumentBuilder<S> command(String
.then(
RequiredArgumentBuilder
.<S, String>argument("args", StringArgumentType.greedyString())
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute)
.suggests(((VRCommandHandler) Via.getManager().getCommandHandler())::suggestion)
.executes(((VFCommandHandler) Via.getManager().getCommandHandler())::execute)
.suggests(((VFCommandHandler) Via.getManager().getCommandHandler())::suggestion)
)
.executes(((VRCommandHandler) Via.getManager().getCommandHandler())::execute);
.executes(((VFCommandHandler) Via.getManager().getCommandHandler())::execute);
}

@Override
Expand All @@ -61,7 +61,7 @@ public void onInitialize() {
Via.init(ViaManagerImpl.builder()
.injector(new FabricInjector())
.loader(new VFLoader())
.commandHandler(new VRCommandHandler())
.commandHandler(new VFCommandHandler())
.platform(platform).build());

platform.init();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.Text;

import java.nio.charset.StandardCharsets;
import java.util.UUID;

public class NMSCommandSender implements ViaCommandSender {
Expand Down Expand Up @@ -49,7 +50,7 @@ public UUID getUUID() {
&& source instanceof ClientCommandSource) {
return MinecraftClient.getInstance().player.getUuid();
}
return UUID.fromString(getName());
return UUID.nameUUIDFromBytes(getName().getBytes(StandardCharsets.UTF_8));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

import java.util.concurrent.CompletableFuture;

public class VRCommandHandler extends ViaCommandHandler {
public class VFCommandHandler extends ViaCommandHandler {
{
try {
registerSubCommand(new LeakDetectSubCommand());
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.viaversion.fabric.mc114.mixin.gui.client;


import com.viaversion.fabric.common.gui.ViaServerInfo;
import com.viaversion.fabric.common.handler.FabricDecodeHandler;
import com.viaversion.fabric.mc114.mixin.debug.client.MixinClientConnectionAccessor;
import net.minecraft.client.network.ServerInfo;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.listener.ClientQueryPacketListener;
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(targets = "net.minecraft.client.network.MultiplayerServerListPinger$1")
public abstract class MixinMultiplayerServerListPingerListener implements ClientQueryPacketListener {
@Accessor
abstract ClientConnection getField_3774(); // Synthetic

@Accessor
abstract ServerInfo getField_3776(); // Synthetic

@Inject(method = "onResponse", at = @At(value = "HEAD"))
private void onResponseCaptureServerInfo(QueryResponseS2CPacket packet, CallbackInfo ci) {
FabricDecodeHandler decoder = ((MixinClientConnectionAccessor) this.getField_3774()).getChannel()
.pipeline().get(FabricDecodeHandler.class);
if (decoder != null) {
((ViaServerInfo) getField_3776()).setViaTranslating(decoder.getInfo().isActive());
((ViaServerInfo) getField_3776()).setViaServerVer(decoder.getInfo().getProtocolInfo().getServerProtocolVersion());
}
}
}
Loading

0 comments on commit 73bb621

Please sign in to comment.