File size: 1,308 Bytes
d46f4a3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package net.minecraft.util.datafix.fixes;

import com.mojang.datafixers.DSL;
import com.mojang.datafixers.DataFix;
import com.mojang.datafixers.TypeRewriteRule;
import com.mojang.datafixers.Typed;
import com.mojang.datafixers.schemas.Schema;
import com.mojang.serialization.Dynamic;
import java.util.Optional;

public class CarvingStepRemoveFix extends DataFix {
    public CarvingStepRemoveFix(Schema p_361259_) {
        super(p_361259_, false);
    }

    @Override
    protected TypeRewriteRule makeRule() {
        return this.fixTypeEverywhereTyped("CarvingStepRemoveFix", this.getInputSchema().getType(References.CHUNK), CarvingStepRemoveFix::fixChunk);
    }

    private static Typed<?> fixChunk(Typed<?> p_362518_) {
        return p_362518_.update(DSL.remainderFinder(), p_363979_ -> {
            Dynamic<?> dynamic = p_363979_;
            Optional<? extends Dynamic<?>> optional = p_363979_.get("CarvingMasks").result();
            if (optional.isPresent()) {
                Optional<? extends Dynamic<?>> optional1 = optional.get().get("AIR").result();
                if (optional1.isPresent()) {
                    dynamic = p_363979_.set("carving_mask", (Dynamic<?>)optional1.get());
                }
            }

            return dynamic.remove("CarvingMasks");
        });
    }
}