minecraft-src/net/minecraft/world/level/levelgen/feature/stateproviders/BlockStateProvider.java
2025-07-04 01:41:11 +03:00

26 lines
931 B
Java

package net.minecraft.world.level.levelgen.feature.stateproviders;
import com.mojang.serialization.Codec;
import net.minecraft.core.BlockPos;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.util.RandomSource;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
public abstract class BlockStateProvider {
public static final Codec<BlockStateProvider> CODEC = BuiltInRegistries.BLOCKSTATE_PROVIDER_TYPE
.byNameCodec()
.dispatch(BlockStateProvider::type, BlockStateProviderType::codec);
public static SimpleStateProvider simple(BlockState state) {
return new SimpleStateProvider(state);
}
public static SimpleStateProvider simple(Block block) {
return new SimpleStateProvider(block.defaultBlockState());
}
protected abstract BlockStateProviderType<?> type();
public abstract BlockState getState(RandomSource random, BlockPos pos);
}