use of org.spongepowered.common.accessor.world.level.chunk.ChunkBiomeContainerAccessor in project SpongeCommon by SpongePowered.
the class LevelAccessorMixin_API method setBiome.
// @formatter:on
// MutableBiomeVolume
@SuppressWarnings({ "ConstantConditions" })
default boolean setBiome(final int x, final int y, final int z, final org.spongepowered.api.world.biome.Biome biome) {
Objects.requireNonNull(biome, "biome");
final ChunkAccess iChunk = ((LevelReader) this).getChunk(new BlockPos(x, y, z));
if (iChunk == null) {
return false;
}
return VolumeStreamUtils.setBiomeOnNativeChunk(x, y, z, biome, () -> ((ChunkBiomeContainerAccessor) iChunk.getBiomes()), () -> iChunk.setUnsaved(true));
}
use of org.spongepowered.common.accessor.world.level.chunk.ChunkBiomeContainerAccessor in project SpongeCommon by SpongePowered.
the class VolumeStreamUtils method setBiomeOnNativeChunk.
public static boolean setBiomeOnNativeChunk(final int x, final int y, final int z, final org.spongepowered.api.world.biome.Biome biome, final Supplier<@Nullable ChunkBiomeContainerAccessor> accessor, final Runnable finalizer) {
@Nullable final ChunkBiomeContainerAccessor chunkBiomeContainerAccessor = accessor.get();
if (chunkBiomeContainerAccessor == null) {
return false;
}
final int maskedX = x & ChunkBiomeContainer.HORIZONTAL_MASK;
final int maskedY = Mth.clamp(y, 0, ChunkBiomeContainer.VERTICAL_MASK);
final int maskedZ = z & ChunkBiomeContainer.HORIZONTAL_MASK;
final int WIDTH_BITS = ChunkBiomeContainerAccessor.accessor$WIDTH_BITS();
final int posKey = maskedY << WIDTH_BITS + WIDTH_BITS | maskedZ << WIDTH_BITS | maskedX;
final Biome[] biomes = chunkBiomeContainerAccessor.accessor$biomes();
biomes[posKey] = (net.minecraft.world.level.biome.Biome) (Object) biome;
finalizer.run();
return true;
}
Aggregations