/* * Decompiled with CFR 0.152. * * Could not load the following classes: * com.google.common.collect.Sets * com.mojang.datafixers.util.Pair * com.mojang.serialization.MapCodec * org.jspecify.annotations.Nullable */ package net.minecraft.world.level.biome; import com.google.common.collect.Sets; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.MapCodec; import java.util.Set; import java.util.function.Predicate; import java.util.stream.Stream; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.util.Mth; import net.minecraft.util.RandomSource; import net.minecraft.world.level.LevelReader; import net.minecraft.world.level.biome.Biome; import net.minecraft.world.level.biome.BiomeManager; import net.minecraft.world.level.biome.BiomeSource; import net.minecraft.world.level.biome.Climate; import org.jspecify.annotations.Nullable; public class FixedBiomeSource extends BiomeSource implements BiomeManager.NoiseBiomeSource { public static final MapCodec CODEC = Biome.CODEC.fieldOf("biome").xmap(FixedBiomeSource::new, s -> s.biome).stable(); private final Holder biome; public FixedBiomeSource(Holder biome) { this.biome = biome; } @Override protected Stream> collectPossibleBiomes() { return Stream.of(this.biome); } @Override protected MapCodec codec() { return CODEC; } @Override public Holder getNoiseBiome(int quartX, int quartY, int quartZ, Climate.Sampler sampler) { return this.biome; } @Override public Holder getNoiseBiome(int quartX, int quartY, int quartZ) { return this.biome; } @Override public @Nullable Pair> findBiomeHorizontal(int originX, int originY, int originZ, int r, int skipStep, Predicate> allowed, RandomSource random, boolean findClosest, Climate.Sampler sampler) { if (allowed.test(this.biome)) { if (findClosest) { return Pair.of((Object)new BlockPos(originX, originY, originZ), this.biome); } return Pair.of((Object)new BlockPos(originX - r + random.nextInt(r * 2 + 1), originY, originZ - r + random.nextInt(r * 2 + 1)), this.biome); } return null; } @Override public @Nullable Pair> findClosestBiome3d(BlockPos origin, int searchRadius, int sampleResolutionHorizontal, int sampleResolutionVertical, Predicate> allowed, Climate.Sampler sampler, LevelReader level) { return allowed.test(this.biome) ? Pair.of((Object)origin.atY(Mth.clamp(origin.getY(), level.getMinY() + 1, level.getMaxY() + 1)), this.biome) : null; } @Override public Set> getBiomesWithin(int x, int y, int z, int r, Climate.Sampler sampler) { return Sets.newHashSet(Set.of(this.biome)); } }