Skip to content

Commit

Permalink
Update to 1.20.2-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Sep 18, 2023
1 parent d2f0fe9 commit f3c12e8
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 31 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions viafabric-mc120/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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;
Expand All @@ -21,12 +22,11 @@ private void registerGui() {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,13 @@ private void onHideViaButton(ButtonWidget widget) {

@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);
}

@Override
public void tick() {
super.tick();
protocolVersion.tick();
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,17 +16,14 @@
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand All @@ -14,8 +15,8 @@

@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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,17 @@
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;
Expand All @@ -28,6 +34,7 @@
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 {
Expand All @@ -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
Expand All @@ -52,10 +64,10 @@ protected void initChannel(Channel channel) {

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);
}
})
Expand All @@ -82,7 +94,7 @@ public void onResponse(QueryResponseS2CPacket packet) {
}

@Override
public void onPong(QueryPongS2CPacket packet) {
public void onPingResult(PingResultS2CPacket packet) {
clientConnection.disconnect(Text.literal("Pong not requested!"));
}

Expand All @@ -97,8 +109,12 @@ public boolean isConnectionOpen() {
}
});

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());
});
}
Expand Down
2 changes: 1 addition & 1 deletion viafabric-mc120/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"depends": {
"fabric-resource-loader-v0": "*",
"minecraft": "1.20.1",
"minecraft": ["1.20.2-rc.1"],
"viafabric": "*"
},
"recommends": {
Expand Down

0 comments on commit f3c12e8

Please sign in to comment.