Skip to content

Commit

Permalink
Port to 1.20.2-rc1
Browse files Browse the repository at this point in the history
  • Loading branch information
FlorianMichael committed Sep 16, 2023
1 parent 7ea0500 commit 50e9952
Show file tree
Hide file tree
Showing 37 changed files with 214 additions and 521 deletions.
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ org.gradle.jvmargs=-Xmx8G
org.gradle.parallel=true

# minecraft and fabric
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.10
minecraft_version=1.20.2-rc1
yarn_mappings=1.20.2-rc1+build.2
loader_version=0.14.22
fabric_api_version=0.86.1+1.20.1
fabric_api_version=0.88.5+1.20.2

# viafabricplus
mod_version=2.8.7-SNAPSHOT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
import java.io.File;

/*
* TODO | Port
* - AllayEntity, VexEntity and BoatEntity height offsets are missing?
*
* TODO | General
* - Check if relevant for protocol translation: TakeItemEntityPacket isEmpty case (1.20 -> 1.20.1 change)
* - Window interactions in <= 1.16.5 has changed and can be detected by the server
Expand All @@ -56,7 +59,7 @@
* - Blit-jump is not supported in <= 1.8.9 (https://github.com/ViaVersion/ViaFabricPlus/issues/225)
*/
public class ViaFabricPlus {
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_20tor1_20_1;
public final static VersionEnum NATIVE_VERSION = VersionEnum.r1_20_2;

public final static Gson GSON = new GsonBuilder().setPrettyPrinting().create();
public final static Logger LOGGER = LogManager.getLogger("ViaFabricPlus");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.libs.gson.JsonElement;
import de.florianmichael.viafabricplus.ViaFabricPlus;
import de.florianmichael.viafabricplus.definition.screen.netminecraft.LegacySmithingScreenHandler;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.HandledScreens;
import net.minecraft.network.PacketByteBuf;
Expand All @@ -45,17 +44,6 @@ public class CustomScreenHandler {
}
};

public final static Consumer<PacketByteBuf> LEGACY_SMITHING_HANDLER = data -> {
final var byteBuf = data.asByteBuf();

try {
CustomScreenHandler.openLegacySmithingScreen(Type.VAR_INT.readPrimitive(byteBuf), Type.COMPONENT.read(byteBuf));
} catch (Exception e) {
ViaFabricPlus.LOGGER.error("Failed to open legacy smithing table", e);
}
};

public final static ScreenHandlerType<LegacySmithingScreenHandler> LEGACY_SMITHING = new ScreenHandlerType<>(LegacySmithingScreenHandler::new, FeatureFlags.VANILLA_FEATURES);
private final static Map<Integer, ScreenHandlerType<ScreenHandler>> TRIPLE_CHEST_HANDLERS = new LinkedHashMap<>();

static {
Expand All @@ -65,10 +53,6 @@ public class CustomScreenHandler {
}
}

public static void openLegacySmithingScreen(final int windowID, final JsonElement title) {
HandledScreens.open(CustomScreenHandler.LEGACY_SMITHING, MinecraftClient.getInstance(), windowID, Text.Serializer.fromJson(title.toString()));
}

public static void handleTripleChestHandler(final short windowID, final JsonElement title, final short slots) {
int n = slots / 9;
final int modulo = slots % 9;
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -83,12 +83,12 @@ private void storeEncryptionCiphers(Cipher decryptionCipher, Cipher encryptionCi
}
}

@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lnet/minecraft/util/Lazy;get()Ljava/lang/Object;", shift = At.Shift.BEFORE), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private static void captureAddress(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir, Class class_, Lazy lazy) {
@Inject(method = "connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/network/ClientConnection;)Lio/netty/channel/ChannelFuture;", at = @At(value = "INVOKE", target = "Lio/netty/bootstrap/Bootstrap;group(Lio/netty/channel/EventLoopGroup;)Lio/netty/bootstrap/AbstractBootstrap;", shift = At.Shift.BEFORE), cancellable = true, locals = LocalCapture.CAPTURE_FAILHARD)
private static void captureAddress(InetSocketAddress address, boolean useEpoll, ClientConnection connection, CallbackInfoReturnable<ChannelFuture> cir, Class channelType, EventLoopGroup eventLoopGroup) {
((IClientConnection) connection).viafabricplus_captureAddress(address);

if (ProtocolHack.getTargetVersion(address) == VersionEnum.bedrockLatest) {
cir.setReturnValue(RakNetClientConnection.connectRakNet(connection, address, lazy, class_));
cir.setReturnValue(RakNetClientConnection.connectRakNet(connection, address, eventLoopGroup, channelType));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
@Mixin(MultiplayerServerListPinger.class)
public class MixinMultiplayerServerListPinger {

@Inject(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;Z)Lnet/minecraft/network/ClientConnection;"), locals = LocalCapture.CAPTURE_FAILHARD)
@Inject(method = "add", at = @At(value = "INVOKE", target = "Lnet/minecraft/network/ClientConnection;connect(Ljava/net/InetSocketAddress;ZLnet/minecraft/util/profiler/PerformanceLog;)Lnet/minecraft/network/ClientConnection;"), locals = LocalCapture.CAPTURE_FAILHARD)
public void trackSessions(ServerInfo entry, Runnable saver, CallbackInfo ci, ServerAddress serverAddress, Optional optional, InetSocketAddress inetSocketAddress) {
final VersionEnum version = ((IServerInfo) entry).viafabricplus_forcedVersion();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
*/
package de.florianmichael.viafabricplus.injection.mixin.fixes.minecraft;

import de.florianmichael.viafabricplus.definition.screen.netminecraft.LegacySmithingScreen;
import de.florianmichael.viafabricplus.definition.screen.netminecraft.LegacySmithingScreenHandler;
import de.florianmichael.viafabricplus.definition.screen.CustomScreenHandler;
import de.florianmichael.viafabricplus.protocolhack.ProtocolHack;
import net.minecraft.client.gui.screen.ingame.GenericContainerScreen;
Expand All @@ -38,9 +36,6 @@ public class MixinHandledScreens {

@Inject(method = "getProvider", at = @At("HEAD"), cancellable = true)
private static <T extends ScreenHandler> void returnFakeProvider(ScreenHandlerType<T> type, CallbackInfoReturnable<HandledScreens.@Nullable Provider> cir) {
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_20tor1_20_1) && type == CustomScreenHandler.LEGACY_SMITHING) {
cir.setReturnValue((handler, playerInventory, title) -> new LegacySmithingScreen((LegacySmithingScreenHandler) handler, playerInventory, title));
}
if (ProtocolHack.getTargetVersion().isOlderThanOrEqualTo(VersionEnum.r1_13_2) && CustomScreenHandler.isTripleChestHandler(type)) {
cir.setReturnValue((handler, playerInventory, title) -> new GenericContainerScreen((GenericContainerScreenHandler) handler, playerInventory, title));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ private int moveHealthDown(int originalValue) {
return originalValue;
}

@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"), slice = @Slice(
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 1,
require = 0)
Expand All @@ -78,7 +78,7 @@ private int moveArmor(int old) {
return old;
}

@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"), slice = @Slice(
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;push(Ljava/lang/String;)V"),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 0)), index = 2,
require = 0)
Expand All @@ -87,7 +87,7 @@ private int moveArmorDown(int old) {
return old;
}

@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"), slice = @Slice(
@ModifyArg(method = "renderStatusBars", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawGuiTexture(Lnet/minecraft/util/Identifier;IIII)V"), slice = @Slice(
from = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;swap(Ljava/lang/String;)V", ordinal = 2),
to = @At(value = "INVOKE", target = "Lnet/minecraft/util/profiler/Profiler;pop()V")), index = 1,
require = 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import com.mojang.authlib.yggdrasil.response.KeyPairResponse;
import de.florianmichael.viafabricplus.injection.access.IKeyPairResponse;
import de.florianmichael.viafabricplus.injection.access.IPublicKeyData;
import net.minecraft.client.util.ProfileKeysImpl;
import net.minecraft.client.session.ProfileKeysImpl;
import net.minecraft.network.encryption.PlayerPublicKey;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
Expand All @@ -32,6 +32,6 @@ public class MixinProfileKeysImpl {

@Inject(method = "decodeKeyPairResponse", at = @At("RETURN"))
private static void trackLegacyKey(KeyPairResponse keyPairResponse, CallbackInfoReturnable<PlayerPublicKey.PublicKeyData> cir) {
((IPublicKeyData) (Object) cir.getReturnValue()).viafabricplus_setV1Key(((IKeyPairResponse) keyPairResponse).viafabricplus_getLegacyPublicKeySignature());
((IPublicKeyData) (Object) cir.getReturnValue()).viafabricplus_setV1Key(((IKeyPairResponse) (Object) keyPairResponse).viafabricplus_getLegacyPublicKeySignature());
}
}
Loading

0 comments on commit 50e9952

Please sign in to comment.