34 lines
891 B
Java
34 lines
891 B
Java
package me.kawaiizenbo.moonlight.mixin;
|
|
|
|
import java.util.Objects;
|
|
import java.util.function.Consumer;
|
|
|
|
import org.spongepowered.asm.mixin.Final;
|
|
import org.spongepowered.asm.mixin.Mixin;
|
|
import org.spongepowered.asm.mixin.Shadow;
|
|
|
|
import me.kawaiizenbo.moonlight.util.ISimpleOption;
|
|
import net.minecraft.client.MinecraftClient;
|
|
import net.minecraft.client.option.SimpleOption;
|
|
|
|
@Mixin(SimpleOption.class)
|
|
public class SimpleOptionMixin<T> implements ISimpleOption<T>
|
|
{
|
|
@Shadow T value;
|
|
@Shadow @Final private Consumer<T> changeCallback;
|
|
|
|
@Override
|
|
public void setValueUnrestricted(T object)
|
|
{
|
|
if (!MinecraftClient.getInstance().isRunning())
|
|
{
|
|
this.value = object;
|
|
return;
|
|
}
|
|
if (!Objects.equals(this.value, object))
|
|
{
|
|
this.value = object;
|
|
this.changeCallback.accept(this.value);
|
|
}
|
|
}
|
|
}
|