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 and) {
        this.difficulty = and;
    }
    
    @Override
    public void handle(final ServerGamePacketListener qz) {
        qz.handleChangeDifficulty(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf mg) throws IOException {
        this.difficulty = Difficulty.byId(mg.readUnsignedByte());
    }
    
    @Override
    public void write(final FriendlyByteBuf mg) throws IOException {
        mg.writeByte(this.difficulty.getId());
    }
    
    public Difficulty getDifficulty() {
        return this.difficulty;
    }
}
