Skip to content

Commit

Permalink
Fix WrappingRuleSource
Browse files Browse the repository at this point in the history
  • Loading branch information
lukebemish committed Jun 9, 2024
1 parent a22db6f commit 2c78a20
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@

@Extend(targetClass = SurfaceRules.RuleSource.class, unsafe = false)
@Expose
interface WrappingRuleSource {
KeyDispatchDataCodec<? extends SurfaceRules.RuleSource> CODEC = KeyDispatchDataCodec.of(new MapCodec<>() {
static final MapCodec<SurfaceRules.RuleSource> DELEGATE = RecordCodecBuilder.mapCodec(i -> i.group(
SurfaceRules.RuleSource.CODEC.fieldOf("delegate").forGetter(r -> ((WrappingRuleSource) r).delegate())
).apply(i, d -> (SurfaceRules.RuleSource) create(d)));
interface WrappingRuleSource extends SurfaceRules.RuleSource {
KeyDispatchDataCodec<WrappingRuleSource> CODEC = KeyDispatchDataCodec.of(new MapCodec<>() {
static final MapCodec<WrappingRuleSource> DELEGATE = RecordCodecBuilder.mapCodec(i -> i.group(
SurfaceRules.RuleSource.CODEC.fieldOf("delegate").forGetter(WrappingRuleSource::delegate)
).apply(i, WrappingRuleSource::create));

@Override
public <T> Stream<T> keys(DynamicOps<T> ops) {
Expand All @@ -36,15 +36,15 @@ public <T> Stream<T> keys(DynamicOps<T> ops) {
}

@Override
public <T> DataResult<SurfaceRules.RuleSource> decode(DynamicOps<T> ops, MapLike<T> input) {
public <T> DataResult<WrappingRuleSource> decode(DynamicOps<T> ops, MapLike<T> input) {
if (ops instanceof NotifyingOps notifying) {
notifying.wrapped();
}
return DELEGATE.decode(ops, input);
}

@Override
public <T> RecordBuilder<T> encode(SurfaceRules.RuleSource input, DynamicOps<T> ops, RecordBuilder<T> prefix) {
public <T> RecordBuilder<T> encode(WrappingRuleSource input, DynamicOps<T> ops, RecordBuilder<T> prefix) {
if (ops instanceof NotifyingOps notifying) {
notifying.wrapped();
}
Expand Down Expand Up @@ -87,13 +87,14 @@ static WrappingRuleSource create(@Field("delegate") SurfaceRules.RuleSource dele
SurfaceRules.RuleSource delegate();

@Overrides("codec")
default KeyDispatchDataCodec<? extends SurfaceRules.RuleSource> codec() {
@SuppressWarnings("unused")
default KeyDispatchDataCodec<? extends SurfaceRules.RuleSource> codecImpl() {
return CODEC;
}

@Overrides("apply")
@SuppressWarnings("unused")
default @Coerce(targetName = "net.minecraft.world.level.levelgen.SurfaceRules$SurfaceRule") Object apply(@Coerce(targetName = "net.minecraft.world.level.levelgen.SurfaceRules$Context") Object context) {
default @Coerce(targetName = "net.minecraft.world.level.levelgen.SurfaceRules$SurfaceRule") Object applyImpl(@Coerce(targetName = "net.minecraft.world.level.levelgen.SurfaceRules$Context") Object context) {
return accessApply(delegate(), context);
}

Expand Down

0 comments on commit 2c78a20

Please sign in to comment.