More Codecs
This commit is contained in:
parent
7b789ba57a
commit
44517e0749
2 changed files with 14 additions and 0 deletions
|
@ -1,12 +1,19 @@
|
|||
package ru.bclib.api.surface.rules;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import ru.bclib.interfaces.NumericProvider;
|
||||
import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
|
||||
import ru.bclib.util.MHelper;
|
||||
|
||||
public record RandomIntProvider(int range) implements NumericProvider {
|
||||
public static final Codec<RandomIntProvider> CODEC = Codec.INT.fieldOf("nethrangeer_noise").xmap(RandomIntProvider::new, obj -> obj.range).codec();
|
||||
@Override
|
||||
public int getNumber(SurfaceRulesContextAccessor context) {
|
||||
return MHelper.RANDOM.nextInt(range);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Codec<? extends NumericProvider> pcodec() {
|
||||
return CODEC;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,14 @@
|
|||
package ru.bclib.interfaces;
|
||||
|
||||
import com.mojang.serialization.Codec;
|
||||
import net.minecraft.core.Registry;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
import ru.bclib.mixin.common.SurfaceRulesContextAccessor;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface NumericProvider {
|
||||
int getNumber(SurfaceRulesContextAccessor context);
|
||||
|
||||
Codec<? extends NumericProvider> pcodec();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue