Skip to content

Commit

Permalink
Minecraft 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
james58899 committed Oct 11, 2023
1 parent 16dd2c9 commit ded9ecc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.2-SNAPSHOT'
id 'fabric-loom' version '1.3-SNAPSHOT'
id 'maven-publish'
}

Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
org.gradle.jvmargs=-Xmx1G
# Fabric Properties
# check these on https://fabricmc.net/develop/
minecraft_version=1.20.1
yarn_mappings=1.20.1+build.2
loader_version=0.14.21
minecraft_version=1.20.2
yarn_mappings=1.20.2+build.4
loader_version=0.14.23
# Mod Properties
mod_version=2.6.0
mod_version=2.7.0
maven_group=one.oktw
archives_base_name=FabricProxy-Lite
# Dependencies
# currently not on the main fabric site, check on the maven: https://maven.fabricmc.net/net/fabricmc/fabric-api/fabric-api
fabric_version=0.83.1+1.20.1
fabric_version=0.90.0+1.20.2
5 changes: 1 addition & 4 deletions src/main/java/one/oktw/PacketHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.mojang.authlib.GameProfile;
import net.fabricmc.fabric.api.networking.v1.PacketSender;
import net.fabricmc.fabric.api.networking.v1.ServerLoginNetworking;

import net.minecraft.network.ClientConnection;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.network.packet.c2s.login.LoginHelloC2SPacket;
Expand All @@ -14,8 +13,6 @@
import one.oktw.mixin.core.ServerLoginNetworkHandlerAccessor;
import org.apache.logging.log4j.LogManager;

import java.util.Optional;

class PacketHandler {
private final ModConfig config;

Expand Down Expand Up @@ -55,7 +52,7 @@ void handleVelocityPacket(MinecraftServer server, ServerLoginNetworkHandler hand
}

if (config.getHackEarlySend()) {
handler.onHello(new LoginHelloC2SPacket(profile.getName(), Optional.of(profile.getId())));
handler.onHello(new LoginHelloC2SPacket(profile.getName(), profile.getId()));
}

((ServerLoginNetworkHandlerAccessor) handler).setProfile(profile);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package one.oktw.mixin.hack;

import com.mojang.authlib.GameProfile;
import net.fabricmc.fabric.impl.networking.NetworkHandlerExtensions;
import net.fabricmc.fabric.impl.networking.server.ServerLoginNetworkAddon;
import net.minecraft.network.ClientConnection;
import net.minecraft.network.packet.c2s.login.LoginHelloC2SPacket;
import net.minecraft.network.packet.s2c.login.LoginQueryRequestS2CPacket;
import net.minecraft.server.network.ServerLoginNetworkHandler;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
Expand All @@ -13,25 +14,25 @@
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.concurrent.ThreadLocalRandom;

import static one.oktw.VelocityLib.PLAYER_INFO_CHANNEL;
import static one.oktw.VelocityLib.PLAYER_INFO_PACKET;

@SuppressWarnings("UnstableApiUsage")
@Mixin(ServerLoginNetworkHandler.class)
public class ServerLoginNetworkHandler_EarlySendPacket {
@Shadow
@Nullable GameProfile profile;

@Shadow
@Final
ClientConnection connection;
@Shadow
@Nullable
private GameProfile profile;

@Inject(method = "onHello", at = @At(value = "HEAD"), cancellable = true)
private void skipKeyPacket(LoginHelloC2SPacket packet, CallbackInfo ci) {
if (profile != null && profile.isComplete()) return; // Already receive profile form velocity.
if (profile != null) return; // Already receive profile form velocity.

connection.send(new LoginQueryRequestS2CPacket(ThreadLocalRandom.current().nextInt(), PLAYER_INFO_CHANNEL, PLAYER_INFO_PACKET));
ServerLoginNetworkAddon addon = (ServerLoginNetworkAddon) ((NetworkHandlerExtensions) this).getAddon();
connection.send(addon.createPacket(PLAYER_INFO_CHANNEL, PLAYER_INFO_PACKET));
ci.cancel();
}
}

0 comments on commit ded9ecc

Please sign in to comment.