Implement fix for record mixins & update shadowed variable access definitions in context mixin
This commit is contained in:
parent
596159a81d
commit
52f06e8567
|
|
@ -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<Holder<Biome>> biome;
|
||||
@Shadow public Supplier<Holder<Biome>> biome;
|
||||
|
||||
@Shadow @Final private Function<BlockPos, Holder<Biome>> biomeGetter;
|
||||
|
||||
@Shadow @Final private BlockPos.MutableBlockPos pos;
|
||||
@Shadow @Final BlockPos.MutableBlockPos pos;
|
||||
|
||||
/**
|
||||
* @author embeddedt
|
||||
|
|
|
|||
|
|
@ -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<ResourceKey<Biome>> biomeNameTest;
|
||||
@Final @Shadow Predicate<ResourceKey<Biome>> 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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user