/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.mojang.serialization.Codec * com.mojang.serialization.MapCodec */ package net.minecraft.util.valueproviders; import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import net.minecraft.util.RandomSource; import net.minecraft.util.valueproviders.IntProvider; import net.minecraft.util.valueproviders.IntProviderType; public class ConstantInt extends IntProvider { public static final ConstantInt ZERO = new ConstantInt(0); public static final MapCodec CODEC = Codec.INT.fieldOf("value").xmap(ConstantInt::of, ConstantInt::getValue); private final int value; public static ConstantInt of(int value) { if (value == 0) { return ZERO; } return new ConstantInt(value); } private ConstantInt(int value) { this.value = value; } public int getValue() { return this.value; } @Override public int sample(RandomSource random) { return this.value; } @Override public int getMinValue() { return this.value; } @Override public int getMaxValue() { return this.value; } @Override public IntProviderType getType() { return IntProviderType.CONSTANT; } public String toString() { return Integer.toString(this.value); } }