mirror of
https://github.com/Oth3r/Sit.git
synced 2025-09-20 00:13:21 +02:00
Merge branch 'refs/heads/master' into 1.20.4
# Conflicts: # gradle.properties # src/main/java/one/oth3r/sit/Sit.java # src/main/java/one/oth3r/sit/SitClient.java # src/main/java/one/oth3r/sit/packet/CustomPayloads.java # src/main/resources/fabric.mod.json
This commit is contained in:
commit
6ea4831a1c
7 changed files with 18 additions and 10 deletions
|
@ -247,7 +247,7 @@ public class Events {
|
|||
BlockState blockState = player.getWorld().getBlockState(pos);
|
||||
// check if said block is still there
|
||||
if (blockState.isAir()) {
|
||||
player.teleport(player.getX(),player.getBlockY()+1,player.getZ());
|
||||
player.teleport(player.getX(),player.getBlockY()+1,player.getZ(),false);
|
||||
entity.setRemoved(Entity.RemovalReason.DISCARDED);
|
||||
entityLoop.remove();
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ public class Sit implements ModInitializer {
|
|||
// copy to not throw errors
|
||||
PacketBuilder packet = new PacketBuilder(buf.copy());
|
||||
server.execute(() -> {
|
||||
LOGGER.info(String.format("Received custom sitting settings from %s.",player.getName().getString()));
|
||||
Type hashMapToken = new TypeToken<HashMap<String, Object>>() {}.getType();
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
playerSettings.put(player,gson.fromJson(packet.getMessage(),hashMapToken));
|
||||
|
|
|
@ -13,13 +13,19 @@ public class SitClient implements ClientModInitializer {
|
|||
ClientPlayConnectionEvents.JOIN.register((handler, sender, client) -> {
|
||||
inGame = true;
|
||||
// send a data packet whenever joining a server
|
||||
client.execute(SitClient::sendPackets);
|
||||
sendSettingsPackets();
|
||||
});
|
||||
// reset inGame
|
||||
ClientPlayConnectionEvents.DISCONNECT.register((handler, client) -> inGame = false);
|
||||
}
|
||||
public static void sendPackets() {
|
||||
Gson gson = new GsonBuilder().disableHtmlEscaping().create();
|
||||
new PacketBuilder(gson.toJson(Utl.HandSettings.getHandSettings())).send();
|
||||
|
||||
/**
|
||||
* 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();
|
||||
new PacketBuilder(gson.toJson(Utl.HandSettings.getHandSettings())).send();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
},
|
||||
"depends": {
|
||||
"fabricloader": ">=0.14.21",
|
||||
"minecraft": ">=1.20.2 <=1.20.4",
|
||||
"minecraft": "=${minecraft_version}",
|
||||
"java": ">=17",
|
||||
"fabric-api": "*"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue