9
0
mirror of https://github.com/LeavesMC/Leaves.git synced 2025-12-19 14:59:32 +00:00

Fix servux hud data (1/3)

This commit is contained in:
violetc
2025-07-21 17:04:51 +08:00
parent 7cf5f57d5a
commit fee2e76cd0

View File

@@ -59,6 +59,11 @@ public class ServuxHudDataProtocol implements LeavesProtocol {
}
}
@ProtocolHandler.PlayerJoin
private static void onPlayerJoin(ServerPlayer player) {
sendHudMetadata(player);
}
@ProtocolHandler.PlayerLeave
private static void onPlayerLeave(ServerPlayer player) {
players.remove(player);
@@ -70,7 +75,15 @@ public class ServuxHudDataProtocol implements LeavesProtocol {
switch (payload.packetType) {
case PACKET_C2S_METADATA_REQUEST -> {
players.add(player);
sendHudMetadata(player);
}
case PACKET_C2S_SPAWN_DATA_REQUEST -> refreshSpawnMetadata(player);
case PACKET_C2S_RECIPE_MANAGER_REQUEST -> refreshRecipeManager(player);
case PACKET_C2S_DATA_LOGGER_REQUEST -> refreshLoggers(player, payload.nbt);
}
}
public static void sendHudMetadata(ServerPlayer player) {
CompoundTag metadata = new CompoundTag();
metadata.putString("name", "hud_metadata");
metadata.putString("id", HudDataPayload.CHANNEL.toString());
@@ -87,11 +100,6 @@ public class ServuxHudDataProtocol implements LeavesProtocol {
sendPacket(player, new HudDataPayload(HudDataPayloadType.PACKET_S2C_METADATA, metadata));
}
case PACKET_C2S_SPAWN_DATA_REQUEST -> refreshSpawnMetadata(player);
case PACKET_C2S_RECIPE_MANAGER_REQUEST -> refreshRecipeManager(player);
case PACKET_C2S_DATA_LOGGER_REQUEST -> refreshLoggers(player, payload.nbt);
}
}
public static void refreshSpawnMetadata(ServerPlayer player) {
CompoundTag metadata = new CompoundTag();
@@ -125,7 +133,7 @@ public class ServuxHudDataProtocol implements LeavesProtocol {
public static void refreshWeatherData(ServerPlayer player) {
ServerLevel level = MinecraftServer.getServer().overworld();
if (level.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE)) {
if (!level.getGameRules().getBoolean(GameRules.RULE_WEATHER_CYCLE)) {
return;
}