diff --git a/c2me-opts-worldgen-vanilla/src/main/java/com/ishland/c2me/opts/worldgen/vanilla/mixin/aquifer/MixinAquiferSamplerImpl.java b/c2me-opts-worldgen-vanilla/src/main/java/com/ishland/c2me/opts/worldgen/vanilla/mixin/aquifer/MixinAquiferSamplerImpl.java index 37b5b7e00..6c7fdf7ce 100644 --- a/c2me-opts-worldgen-vanilla/src/main/java/com/ishland/c2me/opts/worldgen/vanilla/mixin/aquifer/MixinAquiferSamplerImpl.java +++ b/c2me-opts-worldgen-vanilla/src/main/java/com/ishland/c2me/opts/worldgen/vanilla/mixin/aquifer/MixinAquiferSamplerImpl.java @@ -7,11 +7,13 @@ import net.minecraft.util.math.MathHelper; import net.minecraft.util.math.random.Random; import net.minecraft.util.math.random.RandomSplitter; +import net.minecraft.world.biome.source.util.VanillaBiomeParameters; import net.minecraft.world.dimension.DimensionType; import net.minecraft.world.gen.chunk.AquiferSampler; import net.minecraft.world.gen.chunk.ChunkNoiseSampler; import net.minecraft.world.gen.densityfunction.DensityFunction; -import org.jetbrains.annotations.Nullable; +import org.apache.commons.lang3.mutable.MutableDouble; +import org.jetbrains.annotations.NotNull; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Overwrite; @@ -21,24 +23,8 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import static net.minecraft.util.math.BlockPos.SIZE_BITS_X; - @Mixin(AquiferSampler.Impl.class) -public class MixinAquiferSamplerImpl { - - @Unique - private static final int WATER_LEVEL_MAGIC_1 = 64 - BlockPos.BIT_SHIFT_X - SIZE_BITS_X; - @Unique - private static final int WATER_LEVEL_MAGIC_2 = 64 - SIZE_BITS_X; - @Unique - private static final int WATER_LEVEL_MAGIC_3 = 64 - BlockPos.SIZE_BITS_Y; - @Unique - private static final int WATER_LEVEL_MAGIC_4 = 64 - BlockPos.SIZE_BITS_Y; - @Unique - private static final int WATER_LEVEL_MAGIC_5 = 64 - BlockPos.BIT_SHIFT_Z - BlockPos.SIZE_BITS_Z; - @Unique - private static final int WATER_LEVEL_MAGIC_6 = 64 - BlockPos.SIZE_BITS_Z; - +public abstract class MixinAquiferSamplerImpl { @Shadow @Final @@ -101,262 +87,184 @@ public class MixinAquiferSamplerImpl { @Final private AquiferSampler.FluidLevelSampler fluidLevelSampler; - @Unique - private Random randomInstance; + @Shadow protected abstract int index(int x, int y, int z); + + @Shadow + protected static double maxDistance(int i, int a) { + throw new AbstractMethodError(); + } + + @Shadow protected abstract int getNoiseBasedFluidLevel(int blockX, int blockY, int blockZ, int surfaceHeightEstimate); + + @Shadow protected abstract AquiferSampler.FluidLevel getFluidLevel(int blockX, int blockY, int blockZ); + + @Shadow @Final private DensityFunction erosionDensityFunction; + + @Shadow @Final private DensityFunction depthDensityFunction; @Inject(method = "", at = @At("RETURN")) private void onInit(CallbackInfo info) { - this.randomInstance = RandomUtils.getRandom(this.randomDeriver); + // preload position cache + if (this.blockPositions.length % (this.sizeX * this.sizeZ) != 0) { + throw new AssertionError("Array length"); + } + int sizeY = this.blockPositions.length / (this.sizeX * this.sizeZ); + final Random random = RandomUtils.getRandom(this.randomDeriver); + // index: z, x, y + for (int z = 0; z < this.sizeZ; z++) { + for (int x = 0; x < this.sizeX; x++) { + for (int y = 0; y < sizeY; y++) { + final int x1 = x + this.startX; + final int y1 = y + this.startY; + final int z1 = z + this.startZ; + RandomUtils.derive(this.randomDeriver, random, x1, y1, z1); + this.blockPositions[this.index(x1, y1, z1)] = BlockPos.asLong(x1 * 16 + random.nextInt(10), y1 * 12 + random.nextInt(9), z1 * 16 + random.nextInt(10)); + } + } + } + for (long blockPosition : this.blockPositions) { + if (blockPosition == Long.MAX_VALUE) { + throw new AssertionError("Array initialization"); + } + } } /** * @author ishland - * @reason optimize + * @reason make C2 happier by splitting method into three */ @Overwrite - @Nullable - public BlockState apply(DensityFunction.NoisePos arg, double d) { - final int blockX = arg.blockX(); - final int blockY = arg.blockY(); - final int blockZ = arg.blockZ(); - if (d > 0.0) { + public BlockState apply(DensityFunction.NoisePos pos, double density) { + int i = pos.blockX(); + int j = pos.blockY(); + int k = pos.blockZ(); + if (density > 0.0) { this.needsFluidTick = false; return null; } else { - AquiferSampler.FluidLevel fluidLevel = this.fluidLevelSampler.getFluidLevel(blockX, blockY, blockZ); - if (fluidLevel.getBlockState(blockY).isOf(Blocks.LAVA)) { + AquiferSampler.FluidLevel fluidLevel = this.fluidLevelSampler.getFluidLevel(i, j, k); + if (fluidLevel.getBlockState(j).isOf(Blocks.LAVA)) { this.needsFluidTick = false; return Blocks.LAVA.getDefaultState(); } else { - int l = Math.floorDiv(blockX - 5, 16); - int m = Math.floorDiv(blockY + 1, 12); - int n = Math.floorDiv(blockZ - 5, 16); - int o = Integer.MAX_VALUE; - int p = Integer.MAX_VALUE; - int q = Integer.MAX_VALUE; - long r = 0L; - long s = 0L; - long t = 0L; - - for (int u = 0; u <= 1; ++u) { - for (int v = -1; v <= 1; ++v) { - for (int w = 0; w <= 1; ++w) { - int x = l + u; - int y = m + v; - int z = n + w; - int aa = ((y - this.startY) * this.sizeZ + z - this.startZ) * this.sizeX + x - this.startX; - long ab = this.blockPositions[aa]; - long ac; - if (ab != Long.MAX_VALUE) { - ac = ab; - } else { - // C2ME - reuse random instance - RandomUtils.derive(this.randomDeriver, this.randomInstance, x, y, z); - final int i1 = randomInstance.nextInt(10); - final int i2 = randomInstance.nextInt(9); - final int i3 = randomInstance.nextInt(10); - ac = BlockPos.asLong(x * 16 + i1, y * 12 + i2, z * 16 + i3); - this.blockPositions[aa] = ac; - } - - int ad = (int) ((ac << WATER_LEVEL_MAGIC_1) >> WATER_LEVEL_MAGIC_2) - blockX; // C2ME - inline - int ae = (int) ((ac << WATER_LEVEL_MAGIC_3) >> WATER_LEVEL_MAGIC_4) - blockY; // C2ME - inline - int af = (int) ((ac << WATER_LEVEL_MAGIC_5) >> WATER_LEVEL_MAGIC_6) - blockZ; // C2ME - inline - int ag = ad * ad + ae * ae + af * af; - if (o >= ag) { - t = s; - s = r; - r = ac; - q = p; - p = o; - o = ag; - } else if (p >= ag) { - t = s; - s = ac; - q = p; - p = ag; - } else if (q >= ag) { - t = ac; - q = ag; - } - } + final Result1 result = aquiferExtracted$getResult1(i, j, k); + + AquiferSampler.FluidLevel fluidLevel2 = this.getWaterLevel(result.r()); + double d = maxDistance(result.o(), result.p()); + BlockState blockState = fluidLevel2.getBlockState(j); + if (d <= 0.0) { + this.needsFluidTick = d >= NEEDS_FLUID_TICK_DISTANCE_THRESHOLD; + return blockState; + } else if (blockState.isOf(Blocks.WATER) && this.fluidLevelSampler.getFluidLevel(i, j - 1, k).getBlockState(j - 1).isOf(Blocks.LAVA)) { + this.needsFluidTick = true; + return blockState; + } else { + MutableDouble mutableDouble = new MutableDouble(Double.NaN); + AquiferSampler.FluidLevel fluidLevel3 = this.getWaterLevel(result.s()); + double e = d * this.calculateDensity(pos, mutableDouble, fluidLevel2, fluidLevel3); + if (density + e > 0.0) { + this.needsFluidTick = false; + return null; + } else { + return aquiferExtracted$getFinalBlockState(pos, density, result, d, mutableDouble, fluidLevel2, fluidLevel3, blockState); } } + } + } + } - AquiferSampler.FluidLevel fluidLevel2 = this.getWaterLevel(r); - double e = 1.0 - Math.abs(p - o) / 25.0; // C2ME - inline - final BlockState fluidLevel2BlockState = fluidLevel2.getBlockState(blockY); - if (e <= 0.0) { - this.needsFluidTick = e >= NEEDS_FLUID_TICK_DISTANCE_THRESHOLD; - return fluidLevel2BlockState; - } else { - final boolean fluidLevel2BlockStateOfWater = fluidLevel2BlockState.isOf(Blocks.WATER); - if (fluidLevel2BlockStateOfWater && this.fluidLevelSampler.getFluidLevel(blockX, blockY - 1, blockZ).getBlockState(blockY - 1).isOf(Blocks.LAVA)) { - this.needsFluidTick = true; - return fluidLevel2BlockState; - } else { - double mutableDouble = Double.NaN; - AquiferSampler.FluidLevel fluidLevel3 = this.getWaterLevel(s); - double result1; - final BlockState fluidLevel3BlockState = fluidLevel3.getBlockState(blockY); - final boolean fluidLevel2BlockStateOfLava = fluidLevel2BlockState.isOf(Blocks.LAVA); - final boolean fluidLevel3BlockStateOfLava = fluidLevel3BlockState.isOf(Blocks.LAVA); - final boolean fluidLevel3BlockStateOfWater = fluidLevel3BlockState.isOf(Blocks.WATER); - if ((!fluidLevel2BlockStateOfLava || !fluidLevel3BlockStateOfWater) && (!fluidLevel2BlockStateOfWater || !fluidLevel3BlockStateOfLava)) { - int j2 = Math.abs(fluidLevel2.y - fluidLevel3.y); - if (j2 == 0) { - result1 = 0.0; - } else { - double d2 = 0.5 * (fluidLevel2.y + fluidLevel3.y); - double e2 = blockY + 0.5 - d2; - double f2 = j2 / 2.0; - double o2 = f2 - Math.abs(e2); - double q2; - if (e2 > 0.0) { - double p2 = 0.0 + o2; - q2 = p2 > 0.0 ? p2 / 1.5 : p2 / 2.5; - } else { - double p2 = 3.0 + o2; - q2 = p2 > 0.0 ? p2 / 3.0 : p2 / 10.0; - } - - double r2; - if (!(q2 < -2.0) && !(q2 > 2.0)) { - double t2 = this.barrierNoise.sample(arg); - mutableDouble = t2; - r2 = t2; - } else { - r2 = 0.0; - } - - result1 = 2.0 * (r2 + q2); - } - } else { - result1 = 2.0; - } - double f = e * result1; - if (d + f > 0.0) { - this.needsFluidTick = false; - return null; - } else { - AquiferSampler.FluidLevel fluidLevel4 = this.getWaterLevel(t); - double g = 1.0 - (double) Math.abs(q - o) / 25.0; - final BlockState fluidLevel4BlockState = fluidLevel4.getBlockState(blockY); - final boolean fluidLevel4BlockStateOfWater = fluidLevel4BlockState.isOf(Blocks.WATER); - final boolean fluidLevel4BlockStateOfLava = fluidLevel4BlockState.isOf(Blocks.LAVA); - if (g > 0.0) { - double result; - if ((!fluidLevel2BlockStateOfLava || !fluidLevel4BlockStateOfWater) && (!fluidLevel2BlockStateOfWater || !fluidLevel4BlockStateOfLava)) { - int j1 = Math.abs(fluidLevel2.y - fluidLevel4.y); - if (j1 == 0) { - result = 0.0; - } else { - double d1 = 0.5 * (fluidLevel2.y + fluidLevel4.y); - double e1 = blockY + 0.5 - d1; - double f1 = j1 / 2.0; - double o1 = f1 - Math.abs(e1); - double q1; - if (e1 > 0.0) { - double p1 = 0.0 + o1; - q1 = p1 > 0.0 ? p1 / 1.5 : p1 / 2.5; - } else { - double p1 = 3.0 + o1; - q1 = p1 > 0.0 ? p1 / 3.0 : p1 / 10.0; - } - - double r1; - if (!(q1 < -2.0) && !(q1 > 2.0)) { - if (Double.isNaN(mutableDouble)) { - double t1 = this.barrierNoise.sample(arg); - mutableDouble = t1; - r1 = t1; - } else { - r1 = mutableDouble; - } - } else { - r1 = 0.0; - } - - result = 2.0 * (r1 + q1); - } - } else { - result = 2.0; - } - double h = e * g * result; - if (d + h > 0.0) { - this.needsFluidTick = false; - return null; - } - } - - double h = 1.0 - (double) Math.abs(q - p) / 25.0; - if (h > 0.0) { - double result; - if ((!fluidLevel3BlockStateOfLava || !fluidLevel4BlockStateOfWater) && (!fluidLevel3BlockStateOfWater || !fluidLevel4BlockStateOfLava)) { - int j1 = Math.abs(fluidLevel3.y - fluidLevel4.y); - if (j1 == 0) { - result = 0.0; - } else { - double d1 = 0.5 * (fluidLevel3.y + fluidLevel4.y); - double e1 = blockY + 0.5 - d1; - double f1 = j1 / 2.0; - double o1 = f1 - Math.abs(e1); - double q1; - if (e1 > 0.0) { - double p1 = 0.0 + o1; - q1 = p1 > 0.0 ? p1 / 1.5 : p1 / 2.5; - } else { - double p1 = 3.0 + o1; - q1 = p1 > 0.0 ? p1 / 3.0 : p1 / 10.0; - } - - double r1; - if (!(q1 < -2.0) && !(q1 > 2.0)) { - if (Double.isNaN(mutableDouble)) { - double t1 = this.barrierNoise.sample(arg); - mutableDouble = t1; - r1 = t1; - } else { - r1 = mutableDouble; - } - } else { - r1 = 0.0; - } - - result = 2.0 * (r1 + q1); - } - } else { - result = 2.0; - } - double ah = e * h * result; - if (d + ah > 0.0) { - this.needsFluidTick = false; - return null; - } - } - - this.needsFluidTick = true; - return fluidLevel2BlockState; - } + @Unique + private BlockState aquiferExtracted$getFinalBlockState(DensityFunction.NoisePos pos, double density, Result1 result, double d, MutableDouble mutableDouble, AquiferSampler.FluidLevel fluidLevel2, AquiferSampler.FluidLevel fluidLevel3, BlockState blockState) { + AquiferSampler.FluidLevel fluidLevel4 = this.getWaterLevel(result.t()); + double f = maxDistance(result.o(), result.q()); + if (f > 0.0) { + double g = d * f * this.calculateDensity(pos, mutableDouble, fluidLevel2, fluidLevel4); + if (density + g > 0.0) { + this.needsFluidTick = false; + return null; + } + } + + double g = maxDistance(result.p(), result.q()); + if (g > 0.0) { + double h = d * g * this.calculateDensity(pos, mutableDouble, fluidLevel3, fluidLevel4); + if (density + h > 0.0) { + this.needsFluidTick = false; + return null; + } + } + + this.needsFluidTick = true; + return blockState; + } + + @Unique + @NotNull + private Result1 aquiferExtracted$getResult1(int i, int j, int k) { + int l = (i - 5) >> 4; + int m = Math.floorDiv(j + 1, 12); + int n = (k - 5) >> 4; + int o = Integer.MAX_VALUE; + int p = Integer.MAX_VALUE; + int q = Integer.MAX_VALUE; + long r = 0L; + long s = 0L; + long t = 0L; + + for(int u = 0; u <= 1; ++u) { + for(int v = -1; v <= 1; ++v) { + for(int w = 0; w <= 1; ++w) { + int x = l + u; + int y = m + v; + int z = n + w; + int aa = this.index(x, y, z); + long ab = this.blockPositions[aa]; + long ac = ab; // cache preloaded + + int ad = BlockPos.unpackLongX(ac) - i; + int ae = BlockPos.unpackLongY(ac) - j; + int af = BlockPos.unpackLongZ(ac) - k; + int ag = ad * ad + ae * ae + af * af; + if (o >= ag) { + t = s; + s = r; + r = ac; + q = p; + p = o; + o = ag; + } else if (p >= ag) { + t = s; + s = ac; + q = p; + p = ag; + } else if (q >= ag) { + t = ac; + q = ag; } } } } + return new Result1(o, p, q, r, s, t); + } + + @SuppressWarnings("MixinInnerClass") + private record Result1(int o, int p, int q, long r, long s, long t) { } + /** * @author ishland * @reason optimize */ @Overwrite private AquiferSampler.FluidLevel getWaterLevel(long pos) { - int i = (int) ((pos << WATER_LEVEL_MAGIC_1) >> WATER_LEVEL_MAGIC_2); // C2ME - inline - int j = (int) ((pos << WATER_LEVEL_MAGIC_3) >> WATER_LEVEL_MAGIC_4); // C2ME - inline - int k = (int) ((pos << WATER_LEVEL_MAGIC_5) >> WATER_LEVEL_MAGIC_6); // C2ME - inline - int l = Math.floorDiv(i, 16); // C2ME - inline + int i = BlockPos.unpackLongX(pos); + int j = BlockPos.unpackLongY(pos); + int k = BlockPos.unpackLongZ(pos); + int l = i >> 4; // C2ME - inline: floorDiv(i, 16) int m = Math.floorDiv(j, 12); // C2ME - inline - int n = Math.floorDiv(k, 16); // C2ME - inline - int o = ((m - this.startY) * this.sizeZ + n - this.startZ) * this.sizeX + l - this.startX; + int n = k >> 4; // C2ME - inline: floorDiv(k, 16) + int o = this.index(l, m, n); AquiferSampler.FluidLevel fluidLevel = this.waterLevels[o]; if (fluidLevel != null) { return fluidLevel; @@ -372,87 +280,114 @@ private AquiferSampler.FluidLevel getWaterLevel(long pos) { * @reason optimize */ @Overwrite - private AquiferSampler.FluidLevel getFluidLevel(int i, int j, int k) { - AquiferSampler.FluidLevel fluidLevel = this.fluidLevelSampler.getFluidLevel(i, j, k); - int l = Integer.MAX_VALUE; - int m = j + 12; - int n = j - 12; - boolean bl = false; - - for (int[] is : CHUNK_POS_OFFSETS) { - int o = i + (is[0] << 4); // C2ME - inline - int p = k + (is[1] << 4); // C2ME - inline - int q = this.chunkNoiseSampler.estimateSurfaceHeight(o, p); - int r = q + 8; - boolean bl2 = is[0] == 0 && is[1] == 0; - if (bl2 && n > r) { - return fluidLevel; - } - - boolean bl3 = m > r; - if (bl2 || bl3) { - AquiferSampler.FluidLevel fluidLevel2 = this.fluidLevelSampler.getFluidLevel(o, r, p); - if (!fluidLevel2.getBlockState(r).isAir()) { - if (bl2) { - bl = true; - } - - if (bl3) { - return fluidLevel2; - } - } - } - - l = Math.min(l, q); + private int getFluidBlockY(int blockX, int blockY, int blockZ, AquiferSampler.FluidLevel defaultFluidLevel, int surfaceHeightEstimate, boolean bl) { + DensityFunction.UnblendedNoisePos unblendedNoisePos = new DensityFunction.UnblendedNoisePos(blockX, blockY, blockZ); + double d; + double e; + if (VanillaBiomeParameters.inDeepDarkParameters(this.erosionDensityFunction, this.depthDensityFunction, unblendedNoisePos)) { + d = -1.0; + e = -1.0; + } else { + int i = surfaceHeightEstimate + 8 - blockY; + double f = bl ? MathHelper.clampedLerp(1.0, 0.0, ((double) i) / 64.0) : 0.0; // inline + double g = MathHelper.clamp(this.fluidLevelFloodednessNoise.sample(unblendedNoisePos), -1.0, 1.0); + d = g + 0.8 + (f - 1.0) * 1.2; // inline + e = g + 0.3 + (f - 1.0) * 1.1; // inline } - int s = l + 8 - j; - double d = bl ? clampedLerpFromProgressInlined(s) : 0.0; - double e = MathHelper.clamp(this.fluidLevelFloodednessNoise.sample(new DensityFunction.UnblendedNoisePos(i, j, k)), -1.0, 1.0); - double f = lerpFromProgressInlined(d, -0.3, 0.8); - if (e > f) { - return fluidLevel; + int i; + if (e > 0.0) { + i = defaultFluidLevel.y; + } else if (d > 0.0) { + i = this.getNoiseBasedFluidLevel(blockX, blockY, blockZ, surfaceHeightEstimate); } else { - double g = lerpFromProgressInlined(d, -0.8, 0.4); - if (e <= g) { - return new AquiferSampler.FluidLevel(DimensionType.field_35479, fluidLevel.state); + i = DimensionType.field_35479; + } + + return i; + } + + /** + * @author ishland + * @reason optimize, split method into two + */ + @Overwrite + private double calculateDensity( + DensityFunction.NoisePos pos, MutableDouble mutableDouble, AquiferSampler.FluidLevel fluidLevel, AquiferSampler.FluidLevel fluidLevel2 + ) { + int i = pos.blockY(); + BlockState blockState = fluidLevel.getBlockState(i); + BlockState blockState2 = fluidLevel2.getBlockState(i); + if ((!blockState.isOf(Blocks.LAVA) || !blockState2.isOf(Blocks.WATER)) && (!blockState.isOf(Blocks.WATER) || !blockState2.isOf(Blocks.LAVA))) { + int j = Math.abs(fluidLevel.y - fluidLevel2.y); + if (j == 0) { + return 0.0; } else { - int w = Math.floorDiv(i, 16); - int x = Math.floorDiv(j, 40); - int y = Math.floorDiv(k, 16); - int z = x * 40 + 20; - double h = this.fluidLevelSpreadNoise.sample(new DensityFunction.UnblendedNoisePos(w, x, y)) * 10.0; - int ab = MathHelper.roundDownToMultiple(h, 3); - int ac = z + ab; - int ad = Math.min(l, ac); - if (ac <= -10) { - int ag = Math.floorDiv(i, 64); - int ah = Math.floorDiv(j, 40); - int ai = Math.floorDiv(k, 64); - double aj = this.fluidTypeNoise.sample(new DensityFunction.UnblendedNoisePos(ag, ah, ai)); - if (Math.abs(aj) > 0.3) { - return new AquiferSampler.FluidLevel(ad, Blocks.LAVA.getDefaultState()); + double d = 0.5 * (double)(fluidLevel.y + fluidLevel2.y); + final double q = aquiferExtracted$getQ(i, d, j); + + double r; + if (!(q < -2.0) && !(q > 2.0)) { + double s = mutableDouble.getValue(); + if (Double.isNaN(s)) { + double t = this.barrierNoise.sample(pos); + mutableDouble.setValue(t); + r = t; + } else { + r = s; } + } else { + r = 0.0; } - return new AquiferSampler.FluidLevel(ad, fluidLevel.state); + return 2.0 * (r + q); } + } else { + return 2.0; } } @Unique - private static double clampedLerpFromProgressInlined(double lerpValue) { - final double delta = lerpValue / 64.0; - if (delta < 0.0) { - return 1.0; + private static double aquiferExtracted$getQ(double i, double d, double j) { + double e = i + 0.5 - d; + double f = j / 2.0; + double o = f - Math.abs(e); + double q; + if (e > 0.0) { + if (o > 0.0) { + q = o / 1.5; + } else { + q = o / 2.5; + } } else { - return delta > 1.0 ? 0.0 : 1.0 - delta; + double p = 3.0 + o; + if (p > 0.0) { + q = p / 3.0; + } else { + q = p / 10.0; + } } + return q; } - @Unique - private static double lerpFromProgressInlined(double lerpValue, double start, double end) { - return start - (lerpValue - 1.0) * (end - start); + /** + * @author ishland + * @reason optimize + */ + @Overwrite + private BlockState getFluidBlockState(int blockX, int blockY, int blockZ, AquiferSampler.FluidLevel defaultFluidLevel, int fluidLevel) { + BlockState blockState = defaultFluidLevel.state; + if (fluidLevel <= -10 && fluidLevel != DimensionType.field_35479 && defaultFluidLevel.state != Blocks.LAVA.getDefaultState()) { + int k = blockX >> 6; // floorDiv(blockX, 64) + int l = Math.floorDiv(blockY, 40); + int m = blockZ >> 6; // floorDiv(blockZ, 64) + double d = this.fluidTypeNoise.sample(new DensityFunction.UnblendedNoisePos(k, l, m)); + if (Math.abs(d) > 0.3) { + blockState = Blocks.LAVA.getDefaultState(); + } + } + + return blockState; } } diff --git a/c2me-threading-lighting/src/main/java/com/ishland/c2me/threading/lighting/mixin/scalablelux/MixinSchedulingUtil.java b/c2me-threading-lighting/src/main/java/com/ishland/c2me/threading/lighting/mixin/scalablelux/MixinSchedulingUtil.java index 3218955fa..d4d67e95e 100644 --- a/c2me-threading-lighting/src/main/java/com/ishland/c2me/threading/lighting/mixin/scalablelux/MixinSchedulingUtil.java +++ b/c2me-threading-lighting/src/main/java/com/ishland/c2me/threading/lighting/mixin/scalablelux/MixinSchedulingUtil.java @@ -27,7 +27,7 @@ public static void scheduleTask(int ownerTag, Runnable task, int x, int z, int r lockTokens.add(new LockTokenImpl(ownerTag, ChunkPos.toLong(x + i, z + j), LockTokenImpl.Usage.LIGHTING)); } } - final SimplePrioritizedTask simpleTask = new SimplePrioritizedTask(task, lockTokens.toArray(LockToken[]::new), 240); + final SimplePrioritizedTask simpleTask = new SimplePrioritizedTask(task, lockTokens.toArray(LockToken[]::new), 17); GlobalExecutors.prioritizedScheduler.schedule(simpleTask); }