Class IcebergFeature

java.lang.Object
net.minecraft.world.level.levelgen.feature.Feature<BlockStateConfiguration>
net.minecraft.world.level.levelgen.feature.IcebergFeature

public class IcebergFeature extends Feature<BlockStateConfiguration>
This feature generates part of the icebergs found in frozen oceans. Specifically, it generates tall, triangular prism icebergs, and "donut" or torus shaped icebergs. Other icebergs are generated by the frozen ocean surface builder instead.
  • Constructor Details

  • Method Details

    • place

      public boolean place(FeaturePlaceContext<BlockStateConfiguration> pContext)
      Places the given feature at the given location. During world generation, features are provided with a 3x3 region of chunks, centered on the chunk being generated, that they can safely generate into.
      Specified by:
      place in class Feature<BlockStateConfiguration>
      Parameters:
      pContext - A context object with a reference to the level and the position the feature is being placed at
    • generateCutOut

      private void generateCutOut(RandomSource pRandom, LevelAccessor pLevel, int pMajorAxis, int pHeight, BlockPos pPos, boolean pElliptical, int pEllipseRadius, double pAngle, int pMinorAxis)
    • carve

      private void carve(int pRadius, int pLocalY, BlockPos pPos, LevelAccessor pLevel, boolean pPlaceWater, double pPerpendicularAngle, BlockPos pEllipseOrigin, int pMajorRadius, int pMinorRadius)
    • removeFloatingSnowLayer

      private void removeFloatingSnowLayer(LevelAccessor pLevel, BlockPos pPos)
    • generateIcebergBlock

      private void generateIcebergBlock(LevelAccessor pLevel, RandomSource pRandom, BlockPos pPos, int pHeight, int pLocalX, int pLocalY, int pLocalZ, int pRadius, int pMajorRadius, boolean pElliptical, int pMinorRadius, double pAngle, boolean pPlaceSnow, BlockState pState)
    • setIcebergBlock

      private void setIcebergBlock(BlockPos pPos, LevelAccessor pLevel, RandomSource pRandom, int pHeightRemaining, int pHeight, boolean pElliptical, boolean pPlaceSnow, BlockState pState)
    • getEllipseC

      private int getEllipseC(int pY, int pHeight, int pMinorAxis)
    • signedDistanceCircle

      private double signedDistanceCircle(int pX, int pZ, BlockPos pCenter, int pRadius, RandomSource pRandom)
    • signedDistanceEllipse

      private double signedDistanceEllipse(int pX, int pZ, BlockPos pCenter, int pMajorRadius, int pMinorRadius, double pAngle)
      Given an ellipse defined by the equation (x/a)^2 + (y/b)^2 = 1, where a and b are the semi-major and semi-minor axes respectively, this computes the distance between an arbitrary point and the ellipse. The point (x, y) is within the ellipse if the return value is invalid input: '<' 0, outside the ellipse if the return value is > 0 and exactly on the edge of the ellipse if the return value is 0.
      Parameters:
      pX - The x position of the point to measure the distance to.
      pZ - The z position of the point to measure distance to.
      pCenter - The center point of the ellipse.
      pMajorRadius - The semi-major axis (a) of the ellipse.
      pMinorRadius - The semi-minor axis (b) of the ellipse
      pAngle - The rotation angle of the ellipse (the angle from the positive horizontal axis to the ellipse's major axis).
    • heightDependentRadiusRound

      private int heightDependentRadiusRound(RandomSource pRandom, int pY, int pHeight, int pMajorAxis)
    • heightDependentRadiusEllipse

      private int heightDependentRadiusEllipse(int pY, int pHeight, int pMaxRadius)
      Given a horizontal projection of an iceberg, defines the three-dimensional extrusion by defining a radius at any given y value. The radius curve is a parabolic function, resulting in more rounded iceberg peaks.
      Parameters:
      pY - The y value to calculate a radius at.
      pHeight - The maximum height of the iceberg.
      pMaxRadius - The maximum radius of the iceberg, at the horizontal.
    • heightDependentRadiusSteep

      private int heightDependentRadiusSteep(RandomSource pRandom, int pY, int pHeight, int pMaxRadius)
      Given a horizontal projection of an iceberg, defines the three-dimensional extrusion by defining a radius at any given y value. The radius curve is a linear function, with a slope that is both dependent on the majorAxis and randomly varies, which results in steep conical icebergs.
      Parameters:
      pRandom - A random to use to vary the slope of the falloff curve.
      pY - The y value to calculate a radius at.
      pHeight - The maximum height of the iceberg.
      pMaxRadius - The maximum radius radius of the iceberg, at the horizontal.
    • isIcebergState

      private static boolean isIcebergState(BlockState pState)
    • belowIsAir

      private boolean belowIsAir(BlockGetter pLevel, BlockPos pPos)
    • smooth

      private void smooth(LevelAccessor pLevel, BlockPos pPos, int pMajorRadius, int pHeight, boolean pElliptical, int pMinorRadius)
      Smooths out an iceberg by removing blocks which either have air below, or non-iceberg blocks on three or more horizontal sides, with air.