mirror of
https://github.com/Theta-Dev/ConstructionWand.git
synced 2025-08-06 02:45:26 +02:00
39 lines
1.2 KiB
Java
39 lines
1.2 KiB
Java
package thetadev.constructionwand.network;
|
|
|
|
import net.minecraft.network.FriendlyByteBuf;
|
|
import net.minecraft.server.level.ServerPlayer;
|
|
import net.minecraftforge.network.NetworkEvent;
|
|
import thetadev.constructionwand.ConstructionWand;
|
|
|
|
import java.util.function.Supplier;
|
|
|
|
public class PacketQueryUndo
|
|
{
|
|
public boolean undoPressed;
|
|
|
|
public PacketQueryUndo(boolean undoPressed) {
|
|
this.undoPressed = undoPressed;
|
|
}
|
|
|
|
public static void encode(PacketQueryUndo msg, FriendlyByteBuf buffer) {
|
|
buffer.writeBoolean(msg.undoPressed);
|
|
}
|
|
|
|
public static PacketQueryUndo decode(FriendlyByteBuf buffer) {
|
|
return new PacketQueryUndo(buffer.readBoolean());
|
|
}
|
|
|
|
public static class Handler
|
|
{
|
|
public static void handle(final PacketQueryUndo msg, final Supplier<NetworkEvent.Context> ctx) {
|
|
if(!ctx.get().getDirection().getReceptionSide().isServer()) return;
|
|
|
|
ServerPlayer player = ctx.get().getSender();
|
|
if(player == null) return;
|
|
|
|
ConstructionWand.instance.undoHistory.updateClient(player, msg.undoPressed);
|
|
|
|
//ConstructionWand.LOGGER.debug("Undo queried");
|
|
}
|
|
}
|
|
}
|