Skip to content

Commit

Permalink
Merge pull request #22 from Konicai/feature/1.20.4
Browse files Browse the repository at this point in the history
Target Java Edition 1.20.4
  • Loading branch information
Tim203 authored Dec 17, 2023
2 parents df13f81 + ffc05d7 commit c268066
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ protocol = "3.0.0.Beta1-20231107.190703-113"
protocol-connection = "3.0.0.Beta1-20231107.190703-112"
netty = "4.1.80.Final"
fastutil = "8.5.2"
mcprotocollib = "1.20.2-1-20231003.141424-6"
adventure-text = "4.9.3" # Match version to MCPL
mcprotocollib = "1.20.4-1"
adventure-text = "4.15.0-20231207.074016-23" # Match version to MCPL
mariadb-client = "2.7.3"
checker-qual = "3.21.1"
indra = "3.1.2"
Expand Down
3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ dependencyResolutionManagement {
maven("https://jitpack.io") {
content { includeGroupByRegex("com\\.github\\..*") }
}

// Remove when adventure snapshot is no longer used
maven("https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
}

Expand Down
13 changes: 11 additions & 2 deletions src/main/java/org/geysermc/globallinkserver/java/JavaServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@
import com.github.steveice10.mc.protocol.data.game.command.properties.IntegerProperties;
import com.github.steveice10.mc.protocol.data.game.entity.player.GameMode;
import com.github.steveice10.mc.protocol.data.game.entity.player.PlayerSpawnInfo;
import com.github.steveice10.mc.protocol.data.game.level.notify.GameEvent;
import com.github.steveice10.mc.protocol.data.status.PlayerInfo;
import com.github.steveice10.mc.protocol.data.status.ServerStatusInfo;
import com.github.steveice10.mc.protocol.data.status.VersionInfo;
import com.github.steveice10.mc.protocol.data.status.handler.ServerInfoBuilder;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundCommandsPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.ClientboundLoginPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerAbilitiesPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundPlayerPositionPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundGameEventPacket;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.level.ClientboundSetDefaultSpawnPositionPacket;
import com.github.steveice10.packetlib.Server;
import com.github.steveice10.packetlib.event.server.ServerAdapter;
Expand Down Expand Up @@ -151,12 +154,18 @@ public boolean startServer(Config config) {
// but this is the best option as we don't want to send chunk and the player is in spectator anyway
session.send(new ClientboundSetHealthPacket(0, 0, 0));

// this packet is also required to let our player spawn,
// but the location itself doesn't appear to be used
// this packet is also required to let our player spawn, but the location itself doesn't matter
session.send(new ClientboundSetDefaultSpawnPositionPacket(Vector3i.ZERO, 0));

// Manually call the connect event
session.callEvent(new ConnectedEvent(session));

// we have to listen to the teleport confirm on the PacketHandler to prevent respawn request packet spam,
// so send it after calling ConnectedEvent which adds the PacketHandler as listener
session.send(new ClientboundPlayerPositionPacket(0, 0, 0, 0, 0, 0));

// this packet is required since 1.20.3
session.send(new ClientboundGameEventPacket(GameEvent.LEVEL_CHUNKS_LOAD_START, null));
});
server.setGlobalFlag(MinecraftConstants.SERVER_COMPRESSION_THRESHOLD, 256); // default

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@

import com.github.steveice10.mc.auth.data.GameProfile;
import com.github.steveice10.mc.protocol.MinecraftConstants;
import com.github.steveice10.mc.protocol.packet.ingame.clientbound.entity.player.ClientboundSetHealthPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.ServerboundChatCommandPacket;
import com.github.steveice10.mc.protocol.packet.ingame.serverbound.level.ServerboundAcceptTeleportationPacket;
import com.github.steveice10.packetlib.Session;
import com.github.steveice10.packetlib.event.session.ConnectedEvent;
import com.github.steveice10.packetlib.event.session.DisconnectedEvent;
Expand Down Expand Up @@ -63,6 +65,11 @@ public void packetReceived(Session session, Packet packet) {
String message = "/" + ((ServerboundChatCommandPacket) packet).getCommand();
CommandUtils.handleCommand(linkManager, playerManager, player, message);
}

if (packet instanceof ServerboundAcceptTeleportationPacket) {
// if we keep the health on 0, the client will spam us respawn request packets :/
session.send(new ClientboundSetHealthPacket(1, 0, 0));
}
} catch (Exception e) {
e.printStackTrace();
}
Expand Down

0 comments on commit c268066

Please sign in to comment.