package net.minecraft.network.protocol.game;

import net.minecraft.network.PacketListener;
import java.io.IOException;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.Difficulty;
import net.minecraft.network.protocol.Packet;

public class ServerboundChangeDifficultyPacket implements Packet<ServerGamePacketListener> {
    private Difficulty difficulty;
    
    public ServerboundChangeDifficultyPacket() {
    }
    
    public ServerboundChangeDifficultyPacket(final Difficulty aji) {
        this.difficulty = aji;
    }
    
    @Override
    public void handle(final ServerGamePacketListener pl) {
        pl.handleChangeDifficulty(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.difficulty = Difficulty.byId(kv.readUnsignedByte());
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeByte(this.difficulty.getId());
    }
    
    public Difficulty getDifficulty() {
        return this.difficulty;
    }
}
