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 ClientboundChangeDifficultyPacket implements Packet<ClientGamePacketListener> {
    private Difficulty difficulty;
    private boolean locked;
    
    public ClientboundChangeDifficultyPacket() {
    }
    
    public ClientboundChangeDifficultyPacket(final Difficulty aji, final boolean boolean2) {
        this.difficulty = aji;
        this.locked = boolean2;
    }
    
    @Override
    public void handle(final ClientGamePacketListener lw) {
        lw.handleChangeDifficulty(this);
    }
    
    @Override
    public void read(final FriendlyByteBuf kv) throws IOException {
        this.difficulty = Difficulty.byId(kv.readUnsignedByte());
        this.locked = kv.readBoolean();
    }
    
    @Override
    public void write(final FriendlyByteBuf kv) throws IOException {
        kv.writeByte(this.difficulty.getId());
        kv.writeBoolean(this.locked);
    }
    
    public boolean isLocked() {
        return this.locked;
    }
    
    public Difficulty getDifficulty() {
        return this.difficulty;
    }
}
