Record Class TreeFeature

java.lang.Object
java.lang.Record
net.minecraft.world.level.levelgen.feature.TreeFeature
All Implemented Interfaces:
Feature

public record TreeFeature(Holder<BlockStateProvider> trunkProvider, TrunkPlacer trunkPlacer, Holder<BlockStateProvider> foliageProvider, FoliagePlacer foliagePlacer, Optional<RootPlacer> rootPlacer, FeatureSize minimumSize, List<TreeDecorator> decorators, boolean ignoreVines, Holder<BlockStateProvider> belowTrunkProvider) extends Record implements Feature
  • Field Details

    • trunkProvider

      private final Holder<BlockStateProvider> trunkProvider
      The field for the trunkProvider record component.
    • trunkPlacer

      private final TrunkPlacer trunkPlacer
      The field for the trunkPlacer record component.
    • foliageProvider

      private final Holder<BlockStateProvider> foliageProvider
      The field for the foliageProvider record component.
    • foliagePlacer

      private final FoliagePlacer foliagePlacer
      The field for the foliagePlacer record component.
    • rootPlacer

      private final Optional<RootPlacer> rootPlacer
      The field for the rootPlacer record component.
    • minimumSize

      private final FeatureSize minimumSize
      The field for the minimumSize record component.
    • decorators

      private final List<TreeDecorator> decorators
      The field for the decorators record component.
    • ignoreVines

      private final boolean ignoreVines
      The field for the ignoreVines record component.
    • belowTrunkProvider

      private final Holder<BlockStateProvider> belowTrunkProvider
      The field for the belowTrunkProvider record component.
    • CODEC

      public static final com.mojang.serialization.MapCodec<TreeFeature> CODEC
    • BLOCK_UPDATE_FLAGS

      private static final int BLOCK_UPDATE_FLAGS
      See Also:
  • Constructor Details

    • TreeFeature

      public TreeFeature(Holder<BlockStateProvider> trunkProvider, TrunkPlacer trunkPlacer, Holder<BlockStateProvider> foliageProvider, FoliagePlacer foliagePlacer, Optional<RootPlacer> rootPlacer, FeatureSize minimumSize, List<TreeDecorator> decorators, boolean ignoreVines, Holder<BlockStateProvider> belowTrunkProvider)
      Creates an instance of a TreeFeature record class.
      Parameters:
      trunkProvider - the value for the trunkProvider record component
      trunkPlacer - the value for the trunkPlacer record component
      foliageProvider - the value for the foliageProvider record component
      foliagePlacer - the value for the foliagePlacer record component
      rootPlacer - the value for the rootPlacer record component
      minimumSize - the value for the minimumSize record component
      decorators - the value for the decorators record component
      ignoreVines - the value for the ignoreVines record component
      belowTrunkProvider - the value for the belowTrunkProvider record component
  • Method Details

    • codec

      public com.mojang.serialization.MapCodec<TreeFeature> codec()
      Specified by:
      codec in interface Feature
    • isVine

      public static boolean isVine(LevelSimulatedReader level, BlockPos pos)
    • isAirOrLeaves

      public static boolean isAirOrLeaves(LevelSimulatedReader level, BlockPos pos)
    • setBlockKnownShape

      private static void setBlockKnownShape(LevelWriter level, BlockPos pos, BlockState blockState)
    • validTreePos

      public static boolean validTreePos(LevelSimulatedReader level, BlockPos pos)
    • doPlace

      private boolean doPlace(WorldGenLevel level, RandomSource random, BlockPos origin, BiConsumer<BlockPos, BlockState> rootSetter, BiConsumer<BlockPos, BlockState> trunkSetter, FoliagePlacer.FoliageSetter foliageSetter)
    • getMaxFreeTreeHeight

      private int getMaxFreeTreeHeight(WorldGenLevel level, int maxTreeHeight, BlockPos treePos)
    • setBlock

      public void setBlock(LevelWriter level, BlockPos pos, BlockState blockState)
      Specified by:
      setBlock in interface Feature
    • place

      public boolean place(WorldGenLevel level, ChunkGenerator chunkGenerator, RandomSource random, BlockPos origin)
      Specified by:
      place in interface Feature
    • updateLeaves

      private static DiscreteVoxelShape updateLeaves(LevelAccessor level, BoundingBox bounds, Set<BlockPos> logs, Set<BlockPos> decorationSet, Set<BlockPos> rootPositions)
    • getLowestTrunkOrRootOfTree

      public static List<BlockPos> getLowestTrunkOrRootOfTree(TreeDecorator.Context context)
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • trunkProvider

      public Holder<BlockStateProvider> trunkProvider()
      Returns the value of the trunkProvider record component.
      Returns:
      the value of the trunkProvider record component
    • trunkPlacer

      public TrunkPlacer trunkPlacer()
      Returns the value of the trunkPlacer record component.
      Returns:
      the value of the trunkPlacer record component
    • foliageProvider

      public Holder<BlockStateProvider> foliageProvider()
      Returns the value of the foliageProvider record component.
      Returns:
      the value of the foliageProvider record component
    • foliagePlacer

      public FoliagePlacer foliagePlacer()
      Returns the value of the foliagePlacer record component.
      Returns:
      the value of the foliagePlacer record component
    • rootPlacer

      public Optional<RootPlacer> rootPlacer()
      Returns the value of the rootPlacer record component.
      Returns:
      the value of the rootPlacer record component
    • minimumSize

      public FeatureSize minimumSize()
      Returns the value of the minimumSize record component.
      Returns:
      the value of the minimumSize record component
    • decorators

      public List<TreeDecorator> decorators()
      Returns the value of the decorators record component.
      Returns:
      the value of the decorators record component
    • ignoreVines

      public boolean ignoreVines()
      Returns the value of the ignoreVines record component.
      Returns:
      the value of the ignoreVines record component
    • belowTrunkProvider

      public Holder<BlockStateProvider> belowTrunkProvider()
      Returns the value of the belowTrunkProvider record component.
      Returns:
      the value of the belowTrunkProvider record component