Skip to content

Commit

Permalink
fix handshake, and add client init process
Browse files Browse the repository at this point in the history
  • Loading branch information
topi-banana committed Dec 3, 2024
1 parent fdb001f commit 7d0abf2
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
28 changes: 28 additions & 0 deletions src/main/java/com/vulpeus/kyoyu/Kyoyu.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,16 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

import java.util.Optional;

public class Kyoyu {
public static final String MOD_ID = "kyoyu";
public static final String MOD_VERSION = /*$ mod_version*/ "unknown";

public static final Logger LOGGER = LogManager.getLogger(MOD_ID);

private static boolean isClient = false;
private static Optional<KyoyuClient> kyoyuClient = Optional.empty();

public static void setEnv(boolean isClient) {
Kyoyu.isClient = isClient;
Expand All @@ -21,4 +24,29 @@ public static boolean isClient() {
public static boolean isServer() {
return !isClient;
}

public static Optional<KyoyuClient> getClient() {
return kyoyuClient;
}

public static void initClient(String serverVersion) {
if (kyoyuClient.isPresent()) {
LOGGER.error("Duplicate client init");
return;
}
LOGGER.info("Kyoyu client init");
kyoyuClient = Optional.of(new KyoyuClient(serverVersion));
}

public static class KyoyuClient {

private final String serverVersion;

public KyoyuClient(String serverVersion) {
this.serverVersion = serverVersion;
}
private String serverVersion() {
return serverVersion;
}
}
}
6 changes: 3 additions & 3 deletions src/main/java/com/vulpeus/kyoyu/net/KyoyuPacketPayload.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public void sendS2C(ServerPlayer player) {
*/
//?}
//?} elif NEOFORGE {
/* PacketDistributor.sendToServer(this); */
/* PacketDistributor.sendToPlayer(player, this); */
//?}
}

Expand All @@ -169,19 +169,19 @@ public void onPacketServer(
/* Object context */
//?}
) {
//? if FABRIC || NEOFORGE {
//? if FABRIC && <=1.20.4 {
/* Kyoyu.LOGGER.info("onPacketServer {} {} {} {}", server, player, handler, sender); */
//?} else {
Kyoyu.LOGGER.info("onPacketServer {}", context);
//?}

//? if FABRIC {
KyoyuPacketManager.handleC2S(
this.content,
//? if FABRIC && <=1.20.4 {
/* player */
//?} else {
context.player()
(ServerPlayer) context.player()
//?}
);
//?}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ public void onServer(ServerPlayer player) {
@Override
public void onClient() {
Kyoyu.LOGGER.info("Login to compatible server version `{}`", version);
// TODO
// initClient(version);
Kyoyu.initClient(version);
}
}

0 comments on commit 7d0abf2

Please sign in to comment.