package net.minecraft.client;

import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.OptionButton;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.network.chat.Component;
import java.util.function.BiFunction;
import java.util.function.BiConsumer;

public class CycleOption extends Option {
    private final BiConsumer<Options, Integer> setter;
    private final BiFunction<Options, CycleOption, Component> toString;
    
    public CycleOption(final String string, final BiConsumer<Options, Integer> biConsumer, final BiFunction<Options, CycleOption, Component> biFunction) {
        super(string);
        this.setter = biConsumer;
        this.toString = biFunction;
    }
    
    public void toggle(final Options dmb, final int integer) {
        this.setter.accept(dmb, integer);
        dmb.save();
    }
    
    @Override
    public AbstractWidget createButton(final Options dmb, final int integer2, final int integer3, final int integer4) {
        return new OptionButton(integer2, integer3, integer4, 20, this, this.getMessage(dmb), dni -> {
            this.toggle(dmb, 1);
            dni.setMessage(this.getMessage(dmb));
        });
    }
    
    public Component getMessage(final Options dmb) {
        return this.toString.apply(dmb, this);
    }
}
