Skip to content

Commit

Permalink
add codec
Browse files Browse the repository at this point in the history
  • Loading branch information
Treetrain1 committed Jul 10, 2023
1 parent 308ca6c commit 843432b
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

package net.frozenblock.lib.worldgen.surface.api;

import com.mojang.serialization.Codec;
import com.mojang.serialization.codecs.RecordCodecBuilder;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.level.levelgen.SurfaceRules;

Expand All @@ -26,4 +28,11 @@
* The ResourceLocation denotes the dimension to be modified, and the RuleSource are the rules to be applied to it.
*/
public record FrozenDimensionBoundRuleSource(ResourceLocation dimension, SurfaceRules.RuleSource ruleSource) {

public static final Codec<FrozenDimensionBoundRuleSource> CODEC = RecordCodecBuilder.create(instance ->
instance.group(
ResourceLocation.CODEC.fieldOf("dimension").forGetter(FrozenDimensionBoundRuleSource::dimension),
SurfaceRules.RuleSource.CODEC.fieldOf("rule_source").forGetter(FrozenDimensionBoundRuleSource::ruleSource)
).apply(instance, FrozenDimensionBoundRuleSource::new)
);
}

0 comments on commit 843432b

Please sign in to comment.