diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/worldgen_allocation/SurfaceRulesContextMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/worldgen_allocation/SurfaceRulesContextMixin.java index c2be9c3d..71e7dfd5 100644 --- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/worldgen_allocation/SurfaceRulesContextMixin.java +++ b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/worldgen_allocation/SurfaceRulesContextMixin.java @@ -3,6 +3,7 @@ package org.embeddedt.modernfix.common.mixin.perf.worldgen_allocation; import net.minecraft.core.BlockPos; import net.minecraft.core.Holder; import net.minecraft.world.level.biome.Biome; +import net.minecraft.world.level.levelgen.SurfaceRules; import org.embeddedt.modernfix.world.gen.PositionalBiomeGetter; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; @@ -12,23 +13,23 @@ import org.spongepowered.asm.mixin.Shadow; import java.util.function.Function; import java.util.function.Supplier; -@Mixin(targets = {"net/minecraft/world/level/levelgen/SurfaceRules$Context"}, priority = 100) +@Mixin(value = SurfaceRules.Context.class, priority = 100) public class SurfaceRulesContextMixin { - @Shadow private long lastUpdateY; + @Shadow long lastUpdateY; - @Shadow private int blockY; + @Shadow public int blockY; - @Shadow private int waterHeight; + @Shadow public int waterHeight; - @Shadow private int stoneDepthBelow; + @Shadow public int stoneDepthBelow; - @Shadow private int stoneDepthAbove; + @Shadow public int stoneDepthAbove; - @Shadow private Supplier> biome; + @Shadow public Supplier> biome; @Shadow @Final private Function> biomeGetter; - @Shadow @Final private BlockPos.MutableBlockPos pos; + @Shadow @Final BlockPos.MutableBlockPos pos; /** * @author embeddedt diff --git a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/worldgen_allocation/SurfaceRulesMixin.java b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/worldgen_allocation/SurfaceRulesMixin.java index 6bb9d16d..c265d2db 100644 --- a/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/worldgen_allocation/SurfaceRulesMixin.java +++ b/common/src/main/java/org/embeddedt/modernfix/common/mixin/perf/worldgen_allocation/SurfaceRulesMixin.java @@ -20,12 +20,11 @@ import java.util.function.Predicate; public class SurfaceRulesMixin { @Mixin(value = SurfaceRules.BiomeConditionSource.class, priority = 100) public static final class BiomeConditionSource { - @Final - @Shadow - Predicate> biomeNameTest; + @Final @Shadow Predicate> biomeNameTest; /** * @author VoidsongDragonfly - * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior + * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior. + * This is an exact reimplementation of the surface rule, without the caching; check code and effect are identical. */ @Overwrite public SurfaceRules.Condition apply(final SurfaceRules.Context pContext) { @@ -41,10 +40,16 @@ public class SurfaceRulesMixin { } @Mixin(value = SurfaceRules.StoneDepthCheck.class, priority = 100) - public record StoneDepthCheck(int offset, boolean addSurfaceDepth, int secondaryDepthRange, CaveSurface surfaceType) { + public static final class StoneDepthCheck { + @Final @Shadow int offset; + @Final @Shadow boolean addSurfaceDepth; + @Final @Shadow int secondaryDepthRange; + @Final @Shadow private CaveSurface surfaceType; + /** * @author VoidsongDragonfly - * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior + * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior. + * This is an exact reimplementation of the surface rule, without the caching; check code and effect are identical. */ @Overwrite public SurfaceRules.Condition apply(final SurfaceRules.Context pContext) { @@ -68,17 +73,22 @@ public class SurfaceRulesMixin { } @Mixin(value = SurfaceRules.VerticalGradientConditionSource.class, priority = 100) - public record VerticalGradientConditionSource(ResourceLocation randomName, VerticalAnchor trueAtAndBelow, VerticalAnchor falseAtAndAbove) { + public static final class VerticalGradientConditionSource { + @Final @Shadow private ResourceLocation randomName; + @Final @Shadow private VerticalAnchor trueAtAndBelow; + @Final @Shadow private VerticalAnchor falseAtAndAbove; + /** * @author VoidsongDragonfly - * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior + * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior. + * This is an exact reimplementation of the surface rule, without the caching; check code and effect are identical. */ @Overwrite public SurfaceRules.Condition apply(final SurfaceRules.Context pContext) { // Copied Vanilla variables - final int i = this.trueAtAndBelow().resolveY(pContext.context); - final int j = this.falseAtAndAbove().resolveY(pContext.context); - final PositionalRandomFactory positionalrandomfactory = pContext.randomState.getOrCreateRandomFactory(this.randomName()); + final int i = trueAtAndBelow.resolveY(pContext.context); + final int j = falseAtAndAbove.resolveY(pContext.context); + final PositionalRandomFactory positionalrandomfactory = pContext.randomState.getOrCreateRandomFactory(randomName); class VerticalGradientCondition implements SurfaceRules.Condition { @Override @@ -101,10 +111,15 @@ public class SurfaceRulesMixin { } @Mixin(value = SurfaceRules.WaterConditionSource.class, priority = 100) - public record WaterConditionSource(int offset, int surfaceDepthMultiplier, boolean addStoneDepth) { + public static final class WaterConditionSource { + @Final @Shadow int offset; + @Final @Shadow int surfaceDepthMultiplier; + @Final @Shadow boolean addStoneDepth; + /** * @author VoidsongDragonfly - * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior + * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior. + * This is an exact reimplementation of the surface rule, without the caching; check code and effect are identical. */ @Overwrite public SurfaceRules.Condition apply(final SurfaceRules.Context pContext) { @@ -125,10 +140,14 @@ public class SurfaceRulesMixin { } @Mixin(value = SurfaceRules.YConditionSource.class, priority = 100) - public record YConditionSource(VerticalAnchor anchor, int surfaceDepthMultiplier, boolean addStoneDepth) { + public static final class YConditionSource { + @Final @Shadow VerticalAnchor anchor; + @Final @Shadow int surfaceDepthMultiplier; + @Final @Shadow boolean addStoneDepth; /** * @author VoidsongDragonfly - * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior + * @reason Replacing Vanilla's use of {@link SurfaceRules.LazyYCondition LazyYCondition} that causes performance detriments due to unused caching behavior. + * This is an exact reimplementation of the surface rule, without the caching; check code and effect are identical. */ @Overwrite public SurfaceRules.Condition apply(final SurfaceRules.Context pContext) { diff --git a/common/src/main/resources/modernfix.accesswidener b/common/src/main/resources/modernfix.accesswidener index 4e2d26e2..61255b2b 100644 --- a/common/src/main/resources/modernfix.accesswidener +++ b/common/src/main/resources/modernfix.accesswidener @@ -23,7 +23,7 @@ accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRule accessible class net/minecraft/world/level/levelgen/SurfaceRules$SurfaceRule # Access to allow working with Context accessible class net/minecraft/world/level/levelgen/SurfaceRules$Context -accessible field net/minecraft/world/level/levelgen/SurfaceRules$Context context Lnet/minecraft/world/level/levelgen/SurfaceRules$Context; +accessible field net/minecraft/world/level/levelgen/SurfaceRules$Context context Lnet/minecraft/world/level/levelgen/WorldGenerationContext; accessible field net/minecraft/world/level/levelgen/SurfaceRules$Context biome Ljava/util/function/Supplier; accessible field net/minecraft/world/level/levelgen/SurfaceRules$Context blockX I accessible field net/minecraft/world/level/levelgen/SurfaceRules$Context blockY I