类 BlockGrowFeatureEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.level.LevelEvent
net.neoforged.neoforge.event.level.BlockGrowFeatureEvent
所有已实现的接口:
net.neoforged.bus.api.ICancellableEvent

public class BlockGrowFeatureEvent extends LevelEvent implements net.neoforged.bus.api.ICancellableEvent
This event is fired whenever a block (like a sapling) grows into a feature (like a tree).

In vanilla, this fires for saplings, fungi, mushrooms and azaleas. Mods may fire it for similar blocks.

This event is only fired on the logical server.

  • 字段详细资料

  • 构造器详细资料

  • 方法详细资料

    • getRandom

      public RandomSource getRandom()
      返回 the random source which initiated the sapling growth。
      返回:
      the random source which initiated the sapling growth
    • getPos

      public BlockPos getPos()
      返回 the coordinates of the sapling attempting to grow。
      返回:
      the coordinates of the sapling attempting to grow
    • getFeature

      @Nullable public @Nullable Holder<ConfiguredFeature<?,?>> getFeature()
      返回 the holder of the feature which will be placed, possibly null。
      返回:
      the holder of the feature which will be placed, possibly null
    • setFeature

      public void setFeature(@Nullable @Nullable Holder<ConfiguredFeature<?,?>> feature)
      Changes the feature that will be grown. If a null feature is set, the original block will remain in place.
      参数:
      feature - a Holder referencing a new feature to be placed instead of the current feature.
    • setFeature

      public void setFeature(ResourceKey<ConfiguredFeature<?,?>> featureKey)
      Changes the feature that will be grown. If the holder cannot be resolved, a null feature will be set.
      参数:
      featureKey - a ResourceKey referencing a new feature to be placed instead of the current feature.
    • setCanceled

      public void setCanceled(boolean canceled)
      Canceling this event will prevent the feature from growing. The original block will remain in place.
      指定者:
      setCanceled 在接口中 net.neoforged.bus.api.ICancellableEvent