1.20.4 backport

This commit is contained in:
Oth3r 2025-05-20 12:57:42 -05:00
commit f185a3870d

View file

@ -1,5 +1,8 @@
package one.oth3r.sit.utl; package one.oth3r.sit.utl;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.ParseResults;
import com.mojang.brigadier.exceptions.CommandSyntaxException;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper; import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper;
import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents;
@ -13,18 +16,21 @@ import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.client.MinecraftClient; import net.minecraft.client.MinecraftClient;
import net.minecraft.client.network.ClientPlayerEntity; import net.minecraft.client.network.ClientPlayerEntity;
import net.minecraft.client.option.KeyBinding; import net.minecraft.client.option.KeyBinding;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult; import net.minecraft.util.ActionResult;
import net.minecraft.util.Formatting; import net.minecraft.util.Formatting;
import one.oth3r.sit.SitClient;
import one.oth3r.sit.command.SitCommand; import one.oth3r.sit.command.SitCommand;
import one.oth3r.sit.file.FileData; import one.oth3r.sit.file.FileData;
import one.oth3r.sit.file.LangReader; import one.oth3r.sit.file.LangReader;
import one.oth3r.sit.file.SittingConfig; import one.oth3r.sit.file.SittingConfig;
import one.oth3r.sit.packet.PacketSender; import one.oth3r.sit.packet.PacketSender;
import one.oth3r.sit.packet.PacketType; import one.oth3r.sit.packet.PacketType;
import one.oth3r.sit.screen.ConfigScreen;
import org.lwjgl.glfw.GLFW; import org.lwjgl.glfw.GLFW;
import java.awt.*;
public class Events { public class Events {
private static class Keybindings { private static class Keybindings {
@ -74,7 +80,7 @@ public class Events {
} else { } else {
// unsupported server message if not in a Sit! server // unsupported server message if not in a Sit! server
player.sendMessage(Utl.lang("sit!.chat.unsupported") player.sendMessage(Utl.lang("sit!.chat.unsupported")
.formatted(Formatting.RED), true); .color(Color.RED).b(), true);
} }
} }
} }
@ -97,7 +103,7 @@ public class Events {
new PacketSender(PacketType.RESPONSE,PacketType.RESPONSE.getId()).sendToPlayer(player); new PacketSender(PacketType.RESPONSE,PacketType.RESPONSE.getId()).sendToPlayer(player);
// log the receiving of the packet from the player // log the receiving of the packet from the player
Data.LOGGER.info(Utl.lang("sit!.console.player_settings",player.getName().getString()).getString()); Data.LOGGER.info(Utl.lang("sit!.console.player_settings",player.getName().getString()).toString());
}); });
})); }));
} }
@ -110,7 +116,7 @@ public class Events {
client.execute(() -> { client.execute(() -> {
if (!Data.isSupportedServer()) { if (!Data.isSupportedServer()) {
Data.setSupportedServer(true); Data.setSupportedServer(true);
Data.LOGGER.info(Utl.lang("sit!.console.connected",packetData).getString()); Data.LOGGER.info(Utl.lang("sit!.console.connected",packetData).toString());
} }
}); });
})); }));
@ -182,7 +188,7 @@ public class Events {
// consume if sitting, if not pass // consume if sitting, if not pass
ActionResult result = Logic.canSit(player,hitResult.getBlockPos(),hitResult) ? ActionResult.CONSUME : ActionResult.PASS; ActionResult result = Logic.canSit(player,hitResult.getBlockPos(),hitResult) ? ActionResult.CONSUME : ActionResult.PASS;
// todo test
if (result.equals(ActionResult.CONSUME)) { if (result.equals(ActionResult.CONSUME)) {
try { try {
CommandDispatcher<ServerCommandSource> dispatcher = Data.getServer().getCommandSource().getDispatcher(); CommandDispatcher<ServerCommandSource> dispatcher = Data.getServer().getCommandSource().getDispatcher();