Add support for `interval_select´ density function type and fix #78 - #81
Closed
annhilati wants to merge 2 commits into
Closed
Add support for `interval_select´ density function type and fix #78#81annhilati wants to merge 2 commits into
annhilati wants to merge 2 commits into
Conversation
Owner
|
Thanks for your work on this. I am going to close this and implement this myself, partly because this really should've been split in two PR's. I might take a look at some of your tests though to figure out #78 issue. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses two issues related to Density Functions to improve parity with Vanilla Minecraft:
Fix
mulandaddneglecting propagation of non-finite values (Fixes [Density Functions] mul and add with 0 neglect propagation of non-finite values #78)When parsing
muloraddoperations where one of the arguments is a constant (like0), Deepslate previously unconditionally evaluated this as anAp2function, which short-circuited and prevented the evaluation of the second argument. This caused discrepancies with Vanilla Minecraft when evaluating non-finite values likeInfinityandNaN.To match Vanilla's parsing optimizations, this PR introduces a
MulOrAddtransformer class. The parser (fromJson) andmapAllmethods have been updated to wrap operations involving a constant into thisMulOrAddclass, which correctly evaluates the dynamic input first before applying the constant.Add support for
interval_select(Fixes [Density Functions] Add support for interval_select #80)Added the
IntervalSelectclass mapping to theinterval_selectDensityFunction, fully porting the Vanilla Java implementation. This includes accuratecompute,mapAll, andmin/maximplementations.Changes Made
IntervalSelectclass toDensityFunction.ts.MulOrAddtransformer class toDensityFunction.ts.createAp2helper to safely instantiateMulOrAddorAp2based on whether the inputs are constants.DensityFunction.fromJsonto parseinterval_selectand utilize the newcreateAp2logic.interval_selectand the0 * Infinitypropagation edge-case inDensityFunction.test.ts.Note: AI assistance was used to help port the Java implementation and fix the parsing logic, but all changes have been verified against the existing test suite.