Update to 1.20.2-rc1

This commit is contained in:
Nassim Jahnke 2023-09-18 20:23:07 +10:00
parent d2f0fe9d46
commit 613a1c8b3e
10 changed files with 47 additions and 33 deletions

View File

@ -20,7 +20,7 @@ def ENV = System.getenv()
group = "com.viaversion.fabric"
description = "Client-side and server-side ViaVersion implementation for Fabric"
version = "0.4.10+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
version = "0.4.11+" + ENV.GITHUB_RUN_NUMBER + "-" + getBranch()
logger.lifecycle("Building ViaFabric: $version")
def getBranch() {
@ -176,7 +176,7 @@ curseforge {
project {
id = "391298"
changelog = changelogMsg
releaseType = "beta"
releaseType = "alpha"
mcReleases.forEach { ver -> addGameVersion(ver) }
if (!rootProject.curseforge_mc_snapshot.isEmpty()) addGameVersion(rootProject.curseforge_mc_snapshot)
@ -205,7 +205,7 @@ curseforge {
modrinth {
token.set(ENV.MODRINTH_TOKEN)
projectId.set("YlKdE5VK")
versionType.set("beta")
versionType.set("alpha")
versionNumber.set(rootProject.version)
versionName.set(versionNameMsg)
changelog.set(changelogMsg)

View File

@ -3,11 +3,11 @@
org.gradle.jvmargs=-Xms32M -Xmx4G -XX:+UseG1GC -XX:+UseStringDeduplication
loader_version=0.14.21
viaver_version=4.7.1-SNAPSHOT
viaver_version=4.8.0-1.20.2-rc1-SNAPSHOT
yaml_version=2.0
publish_mc_versions=1.20.1, 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=
modrinth_mc_snapshot=1.20.2-rc1
# example: 1.19-Snapshot. Can be a blank value
curseforge_mc_snapshot=
curseforge_mc_snapshot=1.20.2-Snapshot

View File

@ -13,7 +13,7 @@
},
"depends": {
"fabricloader": ">=0.14.0",
"minecraft": ["1.8.9", "1.14.4", "1.15.2", "1.16.5", "1.17.1", "1.18.2", "1.19.4", "1.20.1"],
"minecraft": ["1.8.9", "1.14.4", "1.15.2", "1.16.5", "1.17.1", "1.18.2", "1.19.4", "1.20.2-rc.1"],
"viaversion": ">=4.6.0"
},
"breaks": {

View File

@ -1,6 +1,6 @@
dependencies {
minecraft("com.mojang:minecraft:1.20.1")
mappings("net.fabricmc:yarn:1.20.1+build.10:v2")
minecraft("com.mojang:minecraft:1.20.2-rc1")
mappings("net.fabricmc:yarn:1.20.2-rc1+build.3:v2")
modImplementation("net.fabricmc.fabric-api:fabric-api:0.86.1+1.20.1")
modImplementation("com.terraformersmc:modmenu:7.2.1")

View File

@ -5,6 +5,7 @@ import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.screen.v1.ScreenEvents;
import net.fabricmc.fabric.api.client.screen.v1.Screens;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ButtonTextures;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.TexturedButtonWidget;
@ -21,12 +22,11 @@ public class ViaFabricClient implements ClientModInitializer {
try {
ScreenEvents.AFTER_INIT.register((client, screen, scaledWidth, scaledHeight) -> {
if (!(screen instanceof MultiplayerScreen)) return;
// TODO This is broken
Identifier widgetIdentifier = new Identifier("viafabric:textures/gui/widgets.png");
ButtonWidget enableClientSideViaVersion = new TexturedButtonWidget(scaledWidth / 2 + 113, 10,
40, 20, // Size
0, 0, // Start pos of texture
20, // v Hover offset
new Identifier("viafabric:textures/gui/widgets.png"),
256, 256, // Texture size
new ButtonTextures(widgetIdentifier, widgetIdentifier),
it -> MinecraftClient.getInstance().setScreen(new ViaConfigScreen(screen)),
Text.translatable("gui.via_button"));
if (ViaFabric.config.isHideButton()) enableClientSideViaVersion.visible = false;

View File

@ -143,7 +143,7 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
@Override
public void render(DrawContext drawContext, int mouseX, int mouseY, float delta) {
this.renderBackground(drawContext);
this.renderBackground(drawContext, mouseX, mouseY, delta);
drawContext.drawCenteredTextWithShadow(this.textRenderer, this.title, this.width / 2, 20, 16777215);
super.render(drawContext, mouseX, mouseY, delta);
}
@ -151,6 +151,5 @@ public class ViaConfigScreen extends Screen implements AbstractViaConfigScreen {
@Override
public void tick() {
super.tick();
protocolVersion.tick();
}
}

View File

@ -1,8 +1,9 @@
package com.viaversion.fabric.mc120.mixin.gui.client;
import com.mojang.blaze3d.systems.RenderSystem;
import com.viaversion.fabric.common.gui.ViaServerInfo;
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerScreen;
import net.minecraft.client.gui.screen.multiplayer.MultiplayerServerListWidget;
@ -15,17 +16,14 @@ import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;
import java.util.ArrayList;
import java.util.List;
@Mixin(MultiplayerServerListWidget.ServerEntry.class)
public class MixinServerEntry {
@Shadow
@Final
private ServerInfo server;
@Redirect(method = "render", at = @At(value = "INVOKE", ordinal = 0,
target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIFFIIII)V"))
@Redirect(method = "draw", at = @At(value = "INVOKE", ordinal = 0,
target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIFFIIII)V"))
private void redirectPingIcon(DrawContext instance, Identifier texture, int x, int y, float u, float v, int width, int height, int textureWidth, int textureHeight) {
if (texture.equals(GUI_ICONS_TEXTURES) && ((ViaServerInfo) this.server).isViaTranslating()) {
instance.drawTexture(new Identifier("viafabric:textures/gui/icons.png"), x, y, u, v, width, height, textureWidth, textureHeight);

View File

@ -2,6 +2,7 @@ package com.viaversion.fabric.mc120.mixin.pipeline.client;
import com.viaversion.fabric.mc120.ViaFabric;
import com.viaversion.fabric.mc120.service.ProtocolAutoDetector;
import io.netty.channel.ChannelFuture;
import net.minecraft.network.ClientConnection;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
@ -14,8 +15,8 @@ import java.util.logging.Level;
@Mixin(ClientConnection.class)
public class MixinClientConnection {
@Inject(method = "connect", at = @At("HEAD"))
private static void onConnect(InetSocketAddress address, boolean useEpoll, CallbackInfoReturnable<ClientConnection> cir) {
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At("HEAD"))
private static void onConnect(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir) {
try {
if (!ViaFabric.config.isClientSideEnabled()) return;
ProtocolAutoDetector.detectVersion(address).get(10, TimeUnit.SECONDS);

View File

@ -11,11 +11,17 @@ import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.timeout.ReadTimeoutHandler;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.SharedConstants;
import net.minecraft.network.*;
import net.minecraft.network.handler.DecoderHandler;
import net.minecraft.network.handler.PacketEncoder;
import net.minecraft.network.handler.SizePrepender;
import net.minecraft.network.handler.SplitterHandler;
import net.minecraft.network.listener.ClientQueryPacketListener;
import net.minecraft.network.packet.c2s.handshake.ConnectionIntent;
import net.minecraft.network.packet.c2s.handshake.HandshakeC2SPacket;
import net.minecraft.network.packet.c2s.query.QueryRequestC2SPacket;
import net.minecraft.network.packet.s2c.query.QueryPongS2CPacket;
import net.minecraft.network.packet.s2c.query.PingResultS2CPacket;
import net.minecraft.network.packet.s2c.query.QueryResponseS2CPacket;
import net.minecraft.server.ServerMetadata;
import net.minecraft.text.Text;
@ -28,6 +34,7 @@ import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import org.jetbrains.annotations.NotNull;
@Environment(EnvType.CLIENT)
public class ProtocolAutoDetector {
@ -42,8 +49,13 @@ public class ProtocolAutoDetector {
ChannelFuture ch = new Bootstrap()
.group(ClientConnection.CLIENT_IO_GROUP.get())
.channel(NioSocketChannel.class)
.handler(new ChannelInitializer<Channel>() {
protected void initChannel(Channel channel) {
.handler(new ChannelInitializer<>() {
@Override
protected void initChannel(@NotNull Channel channel) {
channel.attr(ClientConnection.CLIENTBOUND_PROTOCOL_KEY)
.set(NetworkState.STATUS.getHandler(NetworkSide.CLIENTBOUND));
channel.attr(ClientConnection.SERVERBOUND_PROTOCOL_KEY)
.set(NetworkState.STATUS.getHandler(NetworkSide.SERVERBOUND));
try {
channel.config().setOption(ChannelOption.TCP_NODELAY, true);
channel.config().setOption(ChannelOption.IP_TOS, 0x18); // Stolen from Velocity, low delay, high reliability
@ -52,10 +64,10 @@ public class ProtocolAutoDetector {
channel.pipeline()
.addLast("timeout", new ReadTimeoutHandler(30))
.addLast("splitter", new SplitterHandler())
.addLast("decoder", new DecoderHandler(NetworkSide.CLIENTBOUND))
.addLast("splitter", new SplitterHandler(null))
.addLast("decoder", new DecoderHandler(ClientConnection.CLIENTBOUND_PROTOCOL_KEY))
.addLast("prepender", new SizePrepender())
.addLast("encoder", new PacketEncoder(NetworkSide.SERVERBOUND))
.addLast("encoder", new PacketEncoder(ClientConnection.SERVERBOUND_PROTOCOL_KEY))
.addLast("packet_handler", clientConnection);
}
})
@ -82,7 +94,7 @@ public class ProtocolAutoDetector {
}
@Override
public void onPong(QueryPongS2CPacket packet) {
public void onPingResult(PingResultS2CPacket packet) {
clientConnection.disconnect(Text.literal("Pong not requested!"));
}
@ -97,8 +109,12 @@ public class ProtocolAutoDetector {
}
});
clientConnection.send(new HandshakeC2SPacket(address.getHostString(),
address.getPort(), NetworkState.STATUS));
clientConnection.send(new HandshakeC2SPacket(
SharedConstants.getGameVersion().getProtocolVersion(),
address.getHostString(),
address.getPort(),
ConnectionIntent.STATUS
));
clientConnection.send(new QueryRequestC2SPacket());
});
}

View File

@ -40,7 +40,7 @@
},
"depends": {
"fabric-resource-loader-v0": "*",
"minecraft": "1.20.1",
"minecraft": ["1.20.2-rc.1"],
"viafabric": "*"
},
"recommends": {