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