Class BlockGrowFeatureEvent

java.lang.Object
net.neoforged.bus.api.Event
net.neoforged.neoforge.event.level.LevelEvent
net.neoforged.neoforge.event.level.BlockGrowFeatureEvent
All Implemented Interfaces:
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.

  • Field Details

  • Constructor Details

  • Method Details

    • getRandom

      public RandomSource getRandom()
      Returns the random source which initiated the sapling growth.
      Returns:
      the random source which initiated the sapling growth
    • getPos

      public BlockPos getPos()
      Returns the coordinates of the sapling attempting to grow.
      Returns:
      the coordinates of the sapling attempting to grow
    • getFeature

      @Nullable public @Nullable Holder<ConfiguredFeature<?,?>> getFeature()
      Returns the holder of the feature which will be placed, possibly null.
      Returns:
      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.
      Parameters:
      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.
      Parameters:
      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.
      Specified by:
      setCanceled in interface net.neoforged.bus.api.ICancellableEvent