mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-19 16:03:22 +02:00
fixed changing settings mid-game not sending updates to the server
This commit is contained in:
parent
13202a6ac0
commit
1d08ee6775
2 changed files with 10 additions and 6 deletions
|
@ -5,7 +5,6 @@ import com.google.gson.GsonBuilder;
|
|||
import net.fabricmc.api.ClientModInitializer;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
|
||||
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayNetworking;
|
||||
import net.minecraft.network.packet.CustomPayload;
|
||||
import one.oth3r.sit.packet.CustomPayloads;
|
||||
|
||||
public class SitClient implements ClientModInitializer {
|
||||
|
@ -16,14 +15,19 @@ public class SitClient implements ClientModInitializer {
|
|||
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
|
||||
inGame = true;
|
||||
// send a data packet whenever joining a server
|
||||
ClientPlayNetworking.send(sendPackets());
|
||||
sendSettingsPackets();
|
||||
});
|
||||
// reset inGame
|
||||
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> inGame = false);
|
||||
}
|
||||
|
||||
public static CustomPayload sendPackets() {
|
||||
/**
|
||||
* sends the settings packets to the server is the client is in game
|
||||
*/
|
||||
public static void sendSettingsPackets() {
|
||||
if (inGame) {
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
return new CustomPayloads.SettingsPayload(gson.toJson(Utl.HandSettings.getHandSettings()));
|
||||
ClientPlayNetworking.send(new CustomPayloads.SettingsPayload(gson.toJson(Utl.HandSettings.getHandSettings())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -213,7 +213,7 @@ public class Config {
|
|||
file.write("\nhand.off.whitelist="+gson.toJson(offWhitelist));
|
||||
file.write("\nhand.off.blacklist="+gson.toJson(offBlacklist));
|
||||
// send packets to update the settings on the server
|
||||
if (SitClient.inGame) SitClient.sendPackets();
|
||||
SitClient.sendSettingsPackets();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue