From 59d28e12ec5fad96d5792c4137adc46bf9ec7947 Mon Sep 17 00:00:00 2001 From: mschae23 <46165762+mschae23@users.noreply.github.com> Date: Wed, 22 Feb 2023 18:00:42 +0100 Subject: [PATCH] ChunkNoiseSampler and DensityFunction renames and documentation (#3512) * Add some documentation for density interpolation * Density function documentation * Fixed Javadoc tags --- .../world/gen/chunk/BlendingData.mapping | 2 +- .../world/gen/chunk/ChunkNoiseSampler.mapping | 119 +++++++++++++----- .../gen/chunk/GenerationShapeConfig.mapping | 4 +- .../densityfunction/DensityFunction.mapping | 45 ++++++- 4 files changed, 132 insertions(+), 38 deletions(-) diff --git a/mappings/net/minecraft/world/gen/chunk/BlendingData.mapping b/mappings/net/minecraft/world/gen/chunk/BlendingData.mapping index 829cb61b0e..fd20b46f7b 100644 --- a/mappings/net/minecraft/world/gen/chunk/BlendingData.mapping +++ b/mappings/net/minecraft/world/gen/chunk/BlendingData.mapping @@ -104,7 +104,7 @@ CLASS net/minecraft/class_6749 net/minecraft/world/gen/chunk/BlendingData COMMENT the chunk-local biome Z coordinate METHOD method_39583 getBottomHalfSectionY ()I METHOD method_39905 getAboveCollidableBlockValue (Lnet/minecraft/class_2791;Lnet/minecraft/class_2338$class_2339;)D - COMMENT {@return {@code 1.0} if there is a collidable block below, otherwise {@code -1}.} + COMMENT {@return {@code 1.0} if there is a collidable block below, otherwise {@code -1}} ARG 0 chunk ARG 1 mutablePos COMMENT will be moved down by one block by this method diff --git a/mappings/net/minecraft/world/gen/chunk/ChunkNoiseSampler.mapping b/mappings/net/minecraft/world/gen/chunk/ChunkNoiseSampler.mapping index 53a82a0c44..6229910da2 100644 --- a/mappings/net/minecraft/world/gen/chunk/ChunkNoiseSampler.mapping +++ b/mappings/net/minecraft/world/gen/chunk/ChunkNoiseSampler.mapping @@ -1,5 +1,10 @@ CLASS net/minecraft/class_6568 net/minecraft/world/gen/chunk/ChunkNoiseSampler - FIELD field_34598 cellHeight I + COMMENT {@code ChunkNoiseSampler} is responsible for sampling the density functions for + COMMENT the cells in each chunk, managing caches and interpolators, the {@code Blender}, + COMMENT and the block state samplers. + COMMENT + COMMENT
An instance of this is created for every chunk. + FIELD field_34598 verticalCellCount I FIELD field_34599 horizontalCellCount I FIELD field_34600 minimumCellY I FIELD field_34601 startCellX I @@ -19,7 +24,12 @@ CLASS net/minecraft/class_6568 net/minecraft/world/gen/chunk/ChunkNoiseSampler FIELD field_36577 sampleUniqueIndex J FIELD field_36578 cacheOnceUniqueIndex J FIELD field_36579 index I - FIELD field_36580 eachApplier Lnet/minecraft/class_6910$class_6911; + FIELD field_36580 interpolationEachApplier Lnet/minecraft/class_6910$class_6911; + COMMENT The implementation of {@code EachApplier} that is used for filling the + COMMENT interpolators' density buffers. + COMMENT + COMMENT
It runs on a vertical column of cells, with the density being sampled at the first
+ COMMENT block in the cell (cell-local coordinate {@code 0} for X, Y and Z).
FIELD field_36581 caches Ljava/util/List;
FIELD field_36582 actualDensityFunctionCache Ljava/util/Map;
FIELD field_36583 initialDensityWithoutJaggedness Lnet/minecraft/class_6910;
@@ -29,10 +39,10 @@ CLASS net/minecraft/class_6568 net/minecraft/world/gen/chunk/ChunkNoiseSampler
FIELD field_36587 lastBlendingColumnPos J
FIELD field_36588 lastBlendingResult Lnet/minecraft/class_6748$class_6956;
FIELD field_36589 horizontalBiomeEnd I
- FIELD field_36590 horizontalCellSize I
- FIELD field_36591 verticalCellSize I
+ FIELD field_36590 horizontalCellBlockCount I
+ FIELD field_36591 verticalCellBlockCount I
FIELD field_36592 isInInterpolationLoop Z
- FIELD field_36593 isSamplingNoise Z
+ FIELD field_36593 isSamplingForCaches Z
FIELD field_36594 startBlockX I
FIELD field_37113 beardifying Lnet/minecraft/class_6916$class_7050;
METHOD This starts the interpolators and fills the cell caches.
+ COMMENT
+ COMMENT @implNote For filling the cell caches, {@code this} is used as the
+ COMMENT {@link net.minecraft.world.gen.densityfunction.DensityFunction.EachApplier EachApplier}.
ARG 1 cellY
+ COMMENT the chunk-local cell Y coordinate
ARG 2 cellZ
+ COMMENT the chunk-local cell Z coordinate
METHOD method_39543 create (Lnet/minecraft/class_2791;Lnet/minecraft/class_7138;Lnet/minecraft/class_6916$class_7050;Lnet/minecraft/class_5284;Lnet/minecraft/class_6350$class_6565;Lnet/minecraft/class_6748;)Lnet/minecraft/class_6568;
ARG 0 chunk
ARG 1 noiseConfig
@@ -83,27 +119,39 @@ CLASS net/minecraft/class_6568 net/minecraft/world/gen/chunk/ChunkNoiseSampler
ARG 1 blockX
ARG 2 blockZ
METHOD method_40529 getActualDensityFunction (Lnet/minecraft/class_6910;)Lnet/minecraft/class_6910;
- ARG 1 densityFunction
+ COMMENT {@return the actual density function for a given density function}
+ COMMENT
+ COMMENT The classes in {@link DensityFunctionTypes} for caches, interpolators,
+ COMMENT {@code blend_alpha} and {@code blend_offset} use simple stub implementations
+ COMMENT that get replaced with their actual implementation by calling this method.
+ ARG 1 function
+ COMMENT the density function to get an actual implementation for
METHOD method_40530 (Lnet/minecraft/class_6910;Lnet/minecraft/class_6910$class_6912;)Lnet/minecraft/class_2680;
ARG 2 pos
METHOD method_40531 createMultiNoiseSampler (Lnet/minecraft/class_6953;Ljava/util/List;)Lnet/minecraft/class_6544$class_6552;
ARG 1 noiseRouter
ARG 2 spawnTarget
- METHOD method_40532 sampleNoise (ZI)V
+ METHOD method_40532 sampleDensity (ZI)V
+ COMMENT Samples the density values for all cells in the chunk with the given X coordinate.
+ COMMENT This is done for every {@code interpolated} function.
ARG 1 start
- ARG 2 nextCellX
+ COMMENT whether to store the results in the start or end density buffer
+ ARG 2 cellX
+ COMMENT the current cell X coordinate
METHOD method_40533 getActualDensityFunctionImpl (Lnet/minecraft/class_6910;)Lnet/minecraft/class_6910;
- ARG 1 densityFunction
+ COMMENT {@return the actual density function for a given density function}
+ ARG 1 function
METHOD method_40535 calculateBlendResult (II)Lnet/minecraft/class_6748$class_6956;
ARG 1 blockX
ARG 2 blockZ
METHOD method_40536 sampleBlockState ()Lnet/minecraft/class_2680;
METHOD method_40537 stopInterpolation ()V
- METHOD method_42361 getHorizontalCellSize ()I
- METHOD method_42362 getVerticalCellSize ()I
- CLASS class_5917 NoiseInterpolator
- FIELD field_29227 startNoiseBuffer [[D
- FIELD field_29228 endNoiseBuffer [[D
+ COMMENT Stops the interpolation loop for this chunk.
+ METHOD method_42361 getHorizontalCellBlockCount ()I
+ METHOD method_42362 getVerticalCellBlockCount ()I
+ CLASS class_5917 DensityInterpolator
+ FIELD field_29227 startDensityBuffer [[D
+ FIELD field_29228 endDensityBuffer [[D
FIELD field_29233 x0y0z0 D
FIELD field_29234 x0y0z1 D
FIELD field_29235 x1y0z0 D
@@ -118,22 +166,29 @@ CLASS net/minecraft/class_6568 net/minecraft/world/gen/chunk/ChunkNoiseSampler
FIELD field_29244 x1z1 D
FIELD field_29245 z0 D
FIELD field_29246 z1 D
- FIELD field_34623 columnSampler Lnet/minecraft/class_6910;
+ FIELD field_34623 delegate Lnet/minecraft/class_6910;
FIELD field_34624 result D
METHOD It can be defined in code or in data packs by using pre-defined function types
+ COMMENT like constant values or {@code add}, which in turn use other density functions
+ COMMENT to define their operands.
FIELD field_37057 CODEC Lcom/mojang/serialization/Codec;
FIELD field_37058 REGISTRY_ENTRY_CODEC Lcom/mojang/serialization/Codec;
FIELD field_37059 FUNCTION_CODEC Lcom/mojang/serialization/Codec;
METHOD method_40464 sample (Lnet/minecraft/class_6910$class_6912;)D
+ COMMENT {@return the density value for the given block position}
ARG 1 pos
+ COMMENT the block position
METHOD method_40468 clamp (DD)Lnet/minecraft/class_6910;
ARG 1 min
ARG 3 max
METHOD method_40469 apply (Lnet/minecraft/class_6910$class_6915;)Lnet/minecraft/class_6910;
+ COMMENT Applies the visitor to every child density function and {@code this}.
+ COMMENT
+ COMMENT @return the resulting density function
ARG 1 visitor
- METHOD method_40470 applyEach ([DLnet/minecraft/class_6910$class_6911;)V
+ COMMENT the visitor that should be applied to this density function
+ METHOD method_40470 fill ([DLnet/minecraft/class_6910$class_6911;)V
+ COMMENT Fills an array of densities using {@code this} density function and
+ COMMENT the {@link EachApplier}.
ARG 1 densities
+ COMMENT the array of densities to fill, like a buffer or a cache
ARG 2 applier
+ COMMENT the {@code EachApplier} to use. It has a method for filling the array, as well as to get a block position for an index
METHOD method_40471 abs ()Lnet/minecraft/class_6910;
METHOD method_40472 square ()Lnet/minecraft/class_6910;
METHOD method_40473 cube ()Lnet/minecraft/class_6910;
@@ -22,14 +37,38 @@ CLASS net/minecraft/class_6910 net/minecraft/world/gen/densityfunction/DensityFu
ARG 0 function
METHOD method_41062 getCodecHolder ()Lnet/minecraft/class_7243;
CLASS class_6911 EachApplier
- METHOD method_40477 getPosAt (I)Lnet/minecraft/class_6910$class_6912;
+ COMMENT {@code EachApplier} is used to fill an array of densities, like a density buffer
+ COMMENT or cache, with values from a density function.
+ COMMENT
+ COMMENT This exists because {@link net.minecraft.world.gen.chunk.ChunkNoiseSampler ChunkNoiseSampler}
+ COMMENT uses itself as the block position passed to density functions and needs to set the
+ COMMENT position fields correctly before calling {@code sample}, as well as setting fields
+ COMMENT for the implementation of caches.
+ METHOD method_40477 at (I)Lnet/minecraft/class_6910$class_6912;
+ COMMENT {@return the block position at a specific index of the density array}
+ COMMENT
+ COMMENT If you want to manually iterate the array and call {@link DensityFunction#sample}
+ COMMENT to set the individual elements in an implementation of {@link DensityFunction#fill},
+ COMMENT this method can be used to get the block position required for that.
+ COMMENT
+ COMMENT @implNote This can have side effects.
ARG 1 index
- METHOD method_40478 applyEach ([DLnet/minecraft/class_6910;)V
+ METHOD method_40478 fill ([DLnet/minecraft/class_6910;)V
+ COMMENT Fills the density array using a density function.
+ COMMENT
+ COMMENT @implNote This can have side effects.
ARG 1 densities
ARG 2 densityFunction
CLASS class_6912 NoisePos
+ COMMENT {@code NoisePos} represents the absolute block position that is passed
+ COMMENT to density functions.
+ COMMENT
+ COMMENT It also has a way to get the currently active {@link Blender}.
METHOD method_39327 getBlender ()Lnet/minecraft/class_6748;
CLASS class_6913 Base
+ COMMENT Represents a density function that has no other density functions as an argument,
+ COMMENT and provides default implementations of {@link #fill} and
+ COMMENT {@link #apply(DensityFunctionVisitor)} for this case.
CLASS class_6914 UnblendedNoisePos
CLASS class_6915 DensityFunctionVisitor
METHOD apply (Lnet/minecraft/class_6910;)Lnet/minecraft/class_6910;