54 lines
2.0 KiB
Java
54 lines
2.0 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*
|
|
* Could not load the following classes:
|
|
* com.mojang.datafixers.kinds.App
|
|
* com.mojang.datafixers.kinds.Applicative
|
|
* com.mojang.serialization.Codec
|
|
* com.mojang.serialization.MapCodec
|
|
* com.mojang.serialization.codecs.RecordCodecBuilder
|
|
*/
|
|
package net.minecraft.world.level.biome;
|
|
|
|
import com.mojang.datafixers.kinds.App;
|
|
import com.mojang.datafixers.kinds.Applicative;
|
|
import com.mojang.serialization.Codec;
|
|
import com.mojang.serialization.MapCodec;
|
|
import com.mojang.serialization.codecs.RecordCodecBuilder;
|
|
import java.util.stream.Stream;
|
|
import net.minecraft.core.Holder;
|
|
import net.minecraft.core.HolderSet;
|
|
import net.minecraft.world.level.biome.Biome;
|
|
import net.minecraft.world.level.biome.BiomeSource;
|
|
import net.minecraft.world.level.biome.Climate;
|
|
|
|
public class CheckerboardColumnBiomeSource
|
|
extends BiomeSource {
|
|
public static final MapCodec<CheckerboardColumnBiomeSource> CODEC = RecordCodecBuilder.mapCodec(i -> i.group((App)Biome.LIST_CODEC.fieldOf("biomes").forGetter(s -> s.allowedBiomes), (App)Codec.intRange((int)0, (int)62).fieldOf("scale").orElse((Object)2).forGetter(s -> s.size)).apply((Applicative)i, CheckerboardColumnBiomeSource::new));
|
|
private final HolderSet<Biome> allowedBiomes;
|
|
private final int bitShift;
|
|
private final int size;
|
|
|
|
public CheckerboardColumnBiomeSource(HolderSet<Biome> allowedBiomes, int size) {
|
|
this.allowedBiomes = allowedBiomes;
|
|
this.bitShift = size + 2;
|
|
this.size = size;
|
|
}
|
|
|
|
@Override
|
|
protected Stream<Holder<Biome>> collectPossibleBiomes() {
|
|
return this.allowedBiomes.stream();
|
|
}
|
|
|
|
@Override
|
|
protected MapCodec<? extends BiomeSource> codec() {
|
|
return CODEC;
|
|
}
|
|
|
|
@Override
|
|
public Holder<Biome> getNoiseBiome(int quartX, int quartY, int quartZ, Climate.Sampler sampler) {
|
|
return this.allowedBiomes.get(Math.floorMod((quartX >> this.bitShift) + (quartZ >> this.bitShift), this.allowedBiomes.size()));
|
|
}
|
|
}
|
|
|