Spaces:
Build error
Build error
File size: 1,154 Bytes
d46f4a3 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
package net.minecraft.util.valueproviders;
import com.mojang.serialization.Codec;
import com.mojang.serialization.MapCodec;
import net.minecraft.util.RandomSource;
public class ConstantInt extends IntProvider {
public static final ConstantInt ZERO = new ConstantInt(0);
public static final MapCodec<ConstantInt> CODEC = Codec.INT.fieldOf("value").xmap(ConstantInt::of, ConstantInt::getValue);
private final int value;
public static ConstantInt of(int p_146484_) {
return p_146484_ == 0 ? ZERO : new ConstantInt(p_146484_);
}
private ConstantInt(int p_146481_) {
this.value = p_146481_;
}
public int getValue() {
return this.value;
}
@Override
public int sample(RandomSource p_216854_) {
return this.value;
}
@Override
public int getMinValue() {
return this.value;
}
@Override
public int getMaxValue() {
return this.value;
}
@Override
public IntProviderType<?> getType() {
return IntProviderType.CONSTANT;
}
@Override
public String toString() {
return Integer.toString(this.value);
}
} |