Skip to content

Commit

Permalink
Initial update for 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Konicai committed Sep 29, 2023
1 parent 8869b57 commit 04fd2c1
Show file tree
Hide file tree
Showing 9 changed files with 52 additions and 63 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ dependencies {
exclude group: "org.ow2.asm", module: "*" // From Events lib
}

include(modImplementation('cloud.commandframework:cloud-fabric:1.8.3') {
include(modImplementation('cloud.commandframework:cloud-fabric:1.8.4') {
because "Commands library implementation for Fabric"
})

include(modImplementation('net.kyori:adventure-platform-fabric:5.8.0-SNAPSHOT') {
include(modImplementation('net.kyori:adventure-platform-fabric:5.10.0') {
because "Chat library implementation for Fabric that includes methods for communicating with the server"
// Thanks to zml for this fix
// The package modifies Brigadier which causes a LinkageError at runtime if included
Expand Down Expand Up @@ -159,7 +159,7 @@ modrinth {
syncBodyFrom = rootProject.file("README.md").text

uploadFile = tasks.getByPath("remappedShadowJar")
gameVersions.addAll("1.19.4", "1.20")
gameVersions.addAll("1.20.2")

loaders = ["fabric"]

Expand Down
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
org.gradle.jvmargs=-Xmx2G
# Fabric Properties
# check these on https://modmuss50.me/fabric.html
minecraft_version=1.19.4
loader_version=0.14.17
minecraft_version=1.20.2
loader_version=0.14.22
# Mod Properties
mod_version=2.2.0-SNAPSHOT
maven_group=org.geysermc.floodgate
archives_base_name=floodgate-fabric
# Dependencies
# check this on https://modmuss50.me/fabric.html
fabric_version=0.76.0+1.19.4
fabric_version=0.89.2+1.20.2
# Our stuff
lombok_version=1.18.20
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.geysermc.floodgate.addon.data;

import com.mojang.authlib.minecraft.MinecraftSessionService;
import com.mojang.logging.LogUtils;
import io.netty.channel.Channel;
import io.netty.util.AttributeKey;
Expand All @@ -13,11 +14,11 @@
import org.geysermc.floodgate.api.logger.FloodgateLogger;
import org.geysermc.floodgate.mixin.ConnectionMixin;
import org.geysermc.floodgate.mixin.ClientIntentionPacketMixinInterface;
import org.geysermc.floodgate.mixin_interface.ServerLoginPacketListenerSetter;
import com.mojang.authlib.GameProfile;
import io.netty.channel.ChannelHandlerContext;
import org.geysermc.floodgate.api.player.FloodgatePlayer;
import org.geysermc.floodgate.config.FloodgateConfig;
import org.geysermc.floodgate.mixin.ServerLoginPacketListenerMixin;
import org.geysermc.floodgate.player.FloodgateHandshakeHandler;
import org.geysermc.floodgate.player.FloodgateHandshakeHandler.HandshakeResult;
import org.slf4j.Logger;
Expand Down Expand Up @@ -78,7 +79,7 @@ protected boolean channelRead(Object packet) {
if (packet instanceof ClientIntentionPacket intentionPacket) {
ctx.pipeline().addAfter("splitter", "floodgate_packet_blocker", blocker);
networkManager = (Connection) ctx.channel().pipeline().get("packet_handler");
handle(packet, intentionPacket.getHostName());
handle(packet, intentionPacket.hostName());
return false;
}
return !checkAndHandleLogin(packet);
Expand All @@ -102,25 +103,9 @@ private boolean checkAndHandleLogin(Object packet) {
GameProfile gameProfile = new GameProfile(player.getCorrectUniqueId(), player.getCorrectUsername());

if (player.isLinked() && player.getCorrectUniqueId().version() == 4) {
Thread texturesThread = new Thread("Bedrock Linked Player Texture Download") {
@Override
public void run() {
try {
MinecraftServerHolder.get().getSessionService()
.fillProfileProperties(gameProfile, true);
} catch (Exception e) {
LOGGER.error("Unable to get Bedrock linked player textures for " + gameProfile.getName(), e);
}
((ServerLoginPacketListenerSetter) networkManager.getPacketListener())
.setGameProfile(gameProfile);
((ServerLoginPacketListenerSetter) networkManager.getPacketListener()).setLoginState();
}
};
texturesThread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER));
texturesThread.start();
verifyLinkedPlayerAsync(gameProfile);
} else {
((ServerLoginPacketListenerSetter) networkManager.getPacketListener()).setGameProfile(gameProfile);
((ServerLoginPacketListenerSetter) networkManager.getPacketListener()).setLoginState();
((ServerLoginPacketListenerMixin) networkManager.getPacketListener()).startClientVerification(gameProfile);
}

ctx.pipeline().remove(this);
Expand All @@ -129,12 +114,36 @@ public void run() {
return false;
}

/**
* Starts a new thread that fetches the linked player's textures,
* and then starts client verification with the more accurate game profile.
*
* @param gameProfile the player's initial profile. it will NOT be mutated.
*/
private void verifyLinkedPlayerAsync(GameProfile gameProfile) {
Thread texturesThread = new Thread("Bedrock Linked Player Texture Download") {
@Override
public void run() {
GameProfile effectiveProfile = gameProfile;
try {
MinecraftSessionService service = MinecraftServerHolder.get().getSessionService();
effectiveProfile = service.fetchProfile(effectiveProfile.getId(), true).profile();
} catch (Exception e) {
LOGGER.error("Unable to get Bedrock linked player textures for " + effectiveProfile.getName(), e);
}
((ServerLoginPacketListenerMixin) networkManager.getPacketListener()).startClientVerification(effectiveProfile);
}
};
texturesThread.setUncaughtExceptionHandler(new DefaultUncaughtExceptionHandler(LOGGER));
texturesThread.start();
}


@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception {
super.exceptionCaught(ctx, cause);
if (config.isDebug()) {
cause.printStackTrace();
LOGGER.error("Exception caught in FabricDataHandler", cause);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.geysermc.floodgate.mixin;

import com.mojang.authlib.GameProfile;
import net.minecraft.server.network.ServerLoginPacketListenerImpl;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(ServerLoginPacketListenerImpl.class)
public interface ServerLoginPacketListenerMixin {

@Invoker("startClientVerification")
void startClientVerification(GameProfile profile);
}

This file was deleted.

4 changes: 2 additions & 2 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
"floodgate.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.6",
"fabricloader": ">=0.14.22",
"fabric": "*",
"minecraft": ">=1.19.4"
"minecraft": ">=1.20.2"
}
}
2 changes: 0 additions & 2 deletions src/main/resources/floodgate.accesswidener
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
accessWidener v1 named

# To change login state
accessible class net/minecraft/server/network/ServerLoginPacketListenerImpl$State
# For player skin refreshing
accessible class net/minecraft/server/level/ChunkMap$TrackedEntity
# To access skins
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/floodgate.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"ClientIntentionPacketMixin",
"ConnectionMixin",
"ServerConnectionListenerMixin",
"ServerLoginPacketListenerImplMixin"
"ServerLoginPacketListenerMixin"
],
"plugin": "org.geysermc.floodgate.util.MixinConfigPlugin",
"injectors": {
Expand Down

0 comments on commit 04fd2c1

Please sign in to comment.