Class SaplingGrowTreeEvent

java.lang.Object
net.minecraftforge.eventbus.api.Event
net.minecraftforge.event.level.LevelEvent
net.minecraftforge.event.level.SaplingGrowTreeEvent

public class SaplingGrowTreeEvent extends LevelEvent
This event is fired whenever a sapling, fungus, mushroom or azalea grows into a tree. This event is fired during sapling growth in SaplingBlock.advanceTree(ServerLevel, BlockPos, BlockState, RandomSource).

This event is not cancellable but does have a result. ALLOW and DEFAULT will allow the sapling to grow using the features set on the event. DENY will prevent the sapling from growing.

This event is fired on the main Forge event bus only on the logical server. TODO 1.20 rename event

  • Field Details

  • Constructor Details

  • Method Details

    • getRandomSource

      public RandomSource getRandomSource()
      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)
      Parameters:
      feature - a Holder referencing a tree feature to be placed instead of the current feature.
    • setFeature

      public void setFeature(ResourceKey<ConfiguredFeature<?,?>> featureKey)
      Parameters:
      featureKey - a ResourceKey referencing a tree feature to be placed instead of the current feature.