Skip to content

Commit

Permalink
Move to Java Edition 1.20.2 (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
Konicai committed Sep 29, 2023
1 parent 8869b57 commit c7fcf10
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 65 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,7 +14,6 @@
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;
Expand Down Expand Up @@ -78,7 +78,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 @@ -93,7 +93,7 @@ private boolean checkAndHandleLogin(Object packet) {
}

// we have to fake the offline player (login) cycle
if (!(networkManager.getPacketListener() instanceof ServerLoginPacketListenerImpl)) {
if (!(networkManager.getPacketListener() instanceof ServerLoginPacketListenerImpl packetListener)) {
// player is not in the login state, abort
ctx.pipeline().remove(this);
return true;
Expand All @@ -102,25 +102,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(packetListener, gameProfile);
} else {
((ServerLoginPacketListenerSetter) networkManager.getPacketListener()).setGameProfile(gameProfile);
((ServerLoginPacketListenerSetter) networkManager.getPacketListener()).setLoginState();
packetListener.startClientVerification(gameProfile);
}

ctx.pipeline().remove(this);
Expand All @@ -129,12 +113,37 @@ 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 packetListener the login packet listener for this connection
* @param gameProfile the player's initial profile. it will NOT be mutated.
*/
private void verifyLinkedPlayerAsync(ServerLoginPacketListenerImpl packetListener, 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);
}
packetListener.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.

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"
}
}
4 changes: 2 additions & 2 deletions src/main/resources/floodgate.accesswidener
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
accessWidener v1 named

# To change login state
accessible class net/minecraft/server/network/ServerLoginPacketListenerImpl$State
# For setting gameprofile and starting connection verification
accessible method net/minecraft/server/network/ServerLoginPacketListenerImpl startClientVerification (Lcom/mojang/authlib/GameProfile;)V
# For player skin refreshing
accessible class net/minecraft/server/level/ChunkMap$TrackedEntity
# To access skins
Expand Down
3 changes: 1 addition & 2 deletions src/main/resources/floodgate.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@
"ClientIntentionPacketMixinInterface",
"ClientIntentionPacketMixin",
"ConnectionMixin",
"ServerConnectionListenerMixin",
"ServerLoginPacketListenerImplMixin"
"ServerConnectionListenerMixin"
],
"plugin": "org.geysermc.floodgate.util.MixinConfigPlugin",
"injectors": {
Expand Down

0 comments on commit c7fcf10

Please sign in to comment.