Inspired by 2020's April Fools' 20w14infinite Snapshot, this mod brings endless randomly generated dimensions into Minecraft.
1package net.lerariemann.infinity.mixin.fixes;
2
3import net.minecraft.world.level.levelgen.Aquifer;
4import org.spongepowered.asm.mixin.Final;
5import org.spongepowered.asm.mixin.Mixin;
6import org.spongepowered.asm.mixin.Mutable;
7import org.spongepowered.asm.mixin.Shadow;
8import org.spongepowered.asm.mixin.injection.At;
9import org.spongepowered.asm.mixin.injection.Inject;
10import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
11
12@Mixin(Aquifer.NoiseBasedAquifer.class)
13public class AquifierSamplerImplMixin {
14 @Mutable
15 @Final
16 @Shadow
17 private long[] aquiferLocationCache;
18
19 /* for some reason minecraft's own code can fail with an array out of bounds exception if i don't clamp this */
20 @Inject(method = "getIndex(III)I", at = @At("RETURN"), cancellable = true)
21 void fixAquifers(int x, int y, int z, CallbackInfoReturnable<Integer> cir) {
22 int i = cir.getReturnValue();
23 if (i >= aquiferLocationCache.length) cir.setReturnValue(aquiferLocationCache.length - 1);
24 }
25}