PlacementUtils.java

net.minecraft.data.worldgen.placement.PlacementUtils

信息

  • 全限定名:net.minecraft.data.worldgen.placement.PlacementUtils
  • 类型:public class
  • 包:net.minecraft.data.worldgen.placement
  • 源码路径:src/main/java/net/minecraft/data/worldgen/placement/PlacementUtils.java
  • 起始行号:L29
  • 职责:

    TODO

字段/常量

  • HEIGHTMAP

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L30
    • 说明:

      TODO

  • HEIGHTMAP_NO_LEAVES

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L31
    • 说明:

      TODO

  • HEIGHTMAP_TOP_SOLID

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L32
    • 说明:

      TODO

  • HEIGHTMAP_WORLD_SURFACE

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L33
    • 说明:

      TODO

  • HEIGHTMAP_OCEAN_FLOOR

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L34
    • 说明:

      TODO

  • FULL_RANGE

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L35
    • 说明:

      TODO

  • RANGE_10_10

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L36
    • 说明:

      TODO

  • RANGE_8_8

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L37
    • 说明:

      TODO

  • RANGE_4_4

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L38
    • 说明:

      TODO

  • RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT

    • 类型: PlacementModifier
    • 修饰符: public static final
    • 源码定位: L39
    • 说明:

      TODO

内部类/嵌套类型

构造器

方法

下面的方法块按源码顺序生成。

public static void bootstrap(BootstrapContext<PlacedFeature> context) @ L43

  • 方法名:bootstrap
  • 源码定位:L43
  • 返回类型:void
  • 修饰符:public static

参数:

  • context: BootstrapContext

说明:

TODO

public static ResourceKey<PlacedFeature> createKey(String name) @ L55

  • 方法名:createKey
  • 源码定位:L55
  • 返回类型:ResourceKey
  • 修饰符:public static

参数:

  • name: String

说明:

TODO

public static void register(BootstrapContext<PlacedFeature> context, ResourceKey<PlacedFeature> id, Holder<ConfiguredFeature<?,?>> feature, List<PlacementModifier> placementModifiers) @ L59

  • 方法名:register
  • 源码定位:L59
  • 返回类型:void
  • 修饰符:public static

参数:

  • context: BootstrapContext
  • id: ResourceKey
  • feature: Holder<ConfiguredFeature>
  • placementModifiers: List

说明:

TODO

public static void register(BootstrapContext<PlacedFeature> context, ResourceKey<PlacedFeature> id, Holder<ConfiguredFeature<?,?>> feature, PlacementModifier... placementModifiers) @ L68

  • 方法名:register
  • 源码定位:L68
  • 返回类型:void
  • 修饰符:public static

参数:

  • context: BootstrapContext
  • id: ResourceKey
  • feature: Holder<ConfiguredFeature>
  • placementModifiers: PlacementModifier…

说明:

TODO

public static PlacementModifier countExtra(int count, float chance, int extra) @ L77

  • 方法名:countExtra
  • 源码定位:L77
  • 返回类型:PlacementModifier
  • 修饰符:public static

参数:

  • count: int
  • chance: float
  • extra: int

说明:

TODO

public static PlacementFilter isEmpty() @ L90

  • 方法名:isEmpty
  • 源码定位:L90
  • 返回类型:PlacementFilter
  • 修饰符:public static

参数:

说明:

TODO

public static BlockPredicateFilter filteredByBlockSurvival(Block block) @ L94

  • 方法名:filteredByBlockSurvival
  • 源码定位:L94
  • 返回类型:BlockPredicateFilter
  • 修饰符:public static

参数:

  • block: Block

说明:

TODO

public static Holder<PlacedFeature> inlinePlaced(Holder<ConfiguredFeature<?,?>> configuredFeature, PlacementModifier... placedFeatures) @ L98

  • 方法名:inlinePlaced
  • 源码定位:L98
  • 返回类型:Holder
  • 修饰符:public static

参数:

  • configuredFeature: Holder<ConfiguredFeature>
  • placedFeatures: PlacementModifier…

说明:

TODO

public static <FC extends FeatureConfiguration,F extends Feature<FC>> Holder<PlacedFeature> inlinePlaced(F feature, FC config, PlacementModifier... placedFeatures) @ L102

  • 方法名:inlinePlaced
  • 源码定位:L102
  • 返回类型:<FC extends FeatureConfiguration,F extends Feature> Holder
  • 修饰符:public static

参数:

  • feature: F
  • config: FC
  • placedFeatures: PlacementModifier…

说明:

TODO

public static <FC extends FeatureConfiguration,F extends Feature<FC>> Holder<PlacedFeature> onlyWhenEmpty(F feature, FC config) @ L108

  • 方法名:onlyWhenEmpty
  • 源码定位:L108
  • 返回类型:<FC extends FeatureConfiguration,F extends Feature> Holder
  • 修饰符:public static

参数:

  • feature: F
  • config: FC

说明:

TODO

public static <FC extends FeatureConfiguration,F extends Feature<FC>> Holder<PlacedFeature> filtered(F feature, FC config, BlockPredicate predicate) @ L112

  • 方法名:filtered
  • 源码定位:L112
  • 返回类型:<FC extends FeatureConfiguration,F extends Feature> Holder
  • 修饰符:public static

参数:

  • feature: F
  • config: FC
  • predicate: BlockPredicate

说明:

TODO

代码

public class PlacementUtils {
    public static final PlacementModifier HEIGHTMAP = HeightmapPlacement.onHeightmap(Heightmap.Types.MOTION_BLOCKING);
    public static final PlacementModifier HEIGHTMAP_NO_LEAVES = HeightmapPlacement.onHeightmap(Heightmap.Types.MOTION_BLOCKING_NO_LEAVES);
    public static final PlacementModifier HEIGHTMAP_TOP_SOLID = HeightmapPlacement.onHeightmap(Heightmap.Types.OCEAN_FLOOR_WG);
    public static final PlacementModifier HEIGHTMAP_WORLD_SURFACE = HeightmapPlacement.onHeightmap(Heightmap.Types.WORLD_SURFACE_WG);
    public static final PlacementModifier HEIGHTMAP_OCEAN_FLOOR = HeightmapPlacement.onHeightmap(Heightmap.Types.OCEAN_FLOOR);
    public static final PlacementModifier FULL_RANGE = HeightRangePlacement.uniform(VerticalAnchor.bottom(), VerticalAnchor.top());
    public static final PlacementModifier RANGE_10_10 = HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(10), VerticalAnchor.belowTop(10));
    public static final PlacementModifier RANGE_8_8 = HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(8), VerticalAnchor.belowTop(8));
    public static final PlacementModifier RANGE_4_4 = HeightRangePlacement.uniform(VerticalAnchor.aboveBottom(4), VerticalAnchor.belowTop(4));
    public static final PlacementModifier RANGE_BOTTOM_TO_MAX_TERRAIN_HEIGHT = HeightRangePlacement.uniform(
        VerticalAnchor.bottom(), VerticalAnchor.absolute(256)
    );
 
    public static void bootstrap(BootstrapContext<PlacedFeature> context) {
        AquaticPlacements.bootstrap(context);
        CavePlacements.bootstrap(context);
        EndPlacements.bootstrap(context);
        MiscOverworldPlacements.bootstrap(context);
        NetherPlacements.bootstrap(context);
        OrePlacements.bootstrap(context);
        TreePlacements.bootstrap(context);
        VegetationPlacements.bootstrap(context);
        VillagePlacements.bootstrap(context);
    }
 
    public static ResourceKey<PlacedFeature> createKey(String name) {
        return ResourceKey.create(Registries.PLACED_FEATURE, Identifier.withDefaultNamespace(name));
    }
 
    public static void register(
        BootstrapContext<PlacedFeature> context,
        ResourceKey<PlacedFeature> id,
        Holder<ConfiguredFeature<?, ?>> feature,
        List<PlacementModifier> placementModifiers
    ) {
        context.register(id, new PlacedFeature(feature, List.copyOf(placementModifiers)));
    }
 
    public static void register(
        BootstrapContext<PlacedFeature> context,
        ResourceKey<PlacedFeature> id,
        Holder<ConfiguredFeature<?, ?>> feature,
        PlacementModifier... placementModifiers
    ) {
        register(context, id, feature, List.of(placementModifiers));
    }
 
    public static PlacementModifier countExtra(int count, float chance, int extra) {
        float weight = 1.0F / chance;
        if (Math.abs(weight - (int)weight) > 1.0E-5F) {
            throw new IllegalStateException("Chance data cannot be represented as list weight");
        } else {
            WeightedList<IntProvider> distribution = WeightedList.<IntProvider>builder()
                .add(ConstantInt.of(count), (int)weight - 1)
                .add(ConstantInt.of(count + extra), 1)
                .build();
            return CountPlacement.of(new WeightedListInt(distribution));
        }
    }
 
    public static PlacementFilter isEmpty() {
        return BlockPredicateFilter.forPredicate(BlockPredicate.ONLY_IN_AIR_PREDICATE);
    }
 
    public static BlockPredicateFilter filteredByBlockSurvival(Block block) {
        return BlockPredicateFilter.forPredicate(BlockPredicate.wouldSurvive(block.defaultBlockState(), BlockPos.ZERO));
    }
 
    public static Holder<PlacedFeature> inlinePlaced(Holder<ConfiguredFeature<?, ?>> configuredFeature, PlacementModifier... placedFeatures) {
        return Holder.direct(new PlacedFeature(configuredFeature, List.of(placedFeatures)));
    }
 
    public static <FC extends FeatureConfiguration, F extends Feature<FC>> Holder<PlacedFeature> inlinePlaced(
        F feature, FC config, PlacementModifier... placedFeatures
    ) {
        return inlinePlaced(Holder.direct(new ConfiguredFeature(feature, config)), placedFeatures);
    }
 
    public static <FC extends FeatureConfiguration, F extends Feature<FC>> Holder<PlacedFeature> onlyWhenEmpty(F feature, FC config) {
        return filtered(feature, config, BlockPredicate.ONLY_IN_AIR_PREDICATE);
    }
 
    public static <FC extends FeatureConfiguration, F extends Feature<FC>> Holder<PlacedFeature> filtered(F feature, FC config, BlockPredicate predicate) {
        return inlinePlaced(feature, config, BlockPredicateFilter.forPredicate(predicate));
    }
}

引用的其他类

  • Holder

    • 引用位置: 参数/方法调用/返回值
    • 关联成员: Holder.direct()
  • BootstrapContext

    • 引用位置: 参数
  • AquaticPlacements

    • 引用位置: 方法调用
    • 关联成员: AquaticPlacements.bootstrap()
  • CavePlacements

    • 引用位置: 方法调用
    • 关联成员: CavePlacements.bootstrap()
  • EndPlacements

    • 引用位置: 方法调用
    • 关联成员: EndPlacements.bootstrap()
  • MiscOverworldPlacements

    • 引用位置: 方法调用
    • 关联成员: MiscOverworldPlacements.bootstrap()
  • NetherPlacements

    • 引用位置: 方法调用
    • 关联成员: NetherPlacements.bootstrap()
  • OrePlacements

    • 引用位置: 方法调用
    • 关联成员: OrePlacements.bootstrap()
  • TreePlacements

    • 引用位置: 方法调用
    • 关联成员: TreePlacements.bootstrap()
  • VegetationPlacements

    • 引用位置: 方法调用
    • 关联成员: VegetationPlacements.bootstrap()
  • VillagePlacements

    • 引用位置: 方法调用
    • 关联成员: VillagePlacements.bootstrap()
  • Identifier

    • 引用位置: 方法调用
    • 关联成员: Identifier.withDefaultNamespace()
  • ResourceKey

    • 引用位置: 参数/方法调用/返回值
    • 关联成员: ResourceKey.create()
  • ConstantInt

    • 引用位置: 方法调用
    • 关联成员: ConstantInt.of()
  • WeightedListInt

    • 引用位置: 构造调用
    • 关联成员: WeightedListInt()
  • Block

    • 引用位置: 参数
  • VerticalAnchor

    • 引用位置: 方法调用
    • 关联成员: VerticalAnchor.aboveBottom(), VerticalAnchor.absolute(), VerticalAnchor.belowTop(), VerticalAnchor.bottom(), VerticalAnchor.top()
  • BlockPredicate

    • 引用位置: 参数/方法调用
    • 关联成员: BlockPredicate.wouldSurvive()
  • ConfiguredFeature

    • 引用位置: 参数/构造调用
    • 关联成员: ConfiguredFeature()
  • Feature

    • 引用位置: 返回值
  • FeatureConfiguration

    • 引用位置: 返回值
  • BlockPredicateFilter

    • 引用位置: 方法调用/返回值
    • 关联成员: BlockPredicateFilter.forPredicate()
  • CountPlacement

    • 引用位置: 方法调用
    • 关联成员: CountPlacement.of()
  • HeightRangePlacement

    • 引用位置: 方法调用
    • 关联成员: HeightRangePlacement.uniform()
  • HeightmapPlacement

    • 引用位置: 方法调用
    • 关联成员: HeightmapPlacement.onHeightmap()
  • PlacedFeature

    • 引用位置: 参数/构造调用/返回值
    • 关联成员: PlacedFeature()
  • PlacementFilter

    • 引用位置: 返回值
  • PlacementModifier

    • 引用位置: 参数/字段/返回值