Skip to content

Commit

Permalink
fix: Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Mar 21, 2024
1 parent 1a91ca6 commit a19719e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.aetherteam.aether.Aether;
import com.aetherteam.aether.block.AetherBlocks;
import com.aetherteam.aether.data.resources.registries.AetherPlacedFeatures;
import com.aetherteam.aether.world.placementmodifier.DungeonBlacklistFilter;
import net.minecraft.data.BuiltinRegistries;
import net.minecraft.resources.ResourceKey;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import net.minecraft.world.level.levelgen.feature.FeaturePlaceContext;
import net.minecraft.world.level.levelgen.synth.PerlinSimplexNoise;
import net.zepalesque.redux.config.ReduxConfig;
import net.zepalesque.redux.util.compat.AncientCompatUtil;
import net.zepalesque.redux.util.math.MathUtil;
import net.zepalesque.redux.world.feature.config.CloudLayerConfig;

Expand All @@ -25,32 +24,28 @@ public CloudLayerFeature(Codec<CloudLayerConfig> codec) {

@Override
public boolean place(FeaturePlaceContext<CloudLayerConfig> context) {
if (AncientCompatUtil.before090) {
int chunkX = context.origin().getX() - (context.origin().getX() % 16);
int chunkZ = context.origin().getZ() - (context.origin().getZ() % 16);
float min = ReduxConfig.COMMON.cloud_layer_threshold_min.get().floatValue() / 2F;
float max = ReduxConfig.COMMON.cloud_layer_threshold_max.get().floatValue() / 2F;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {

double scale = context.config().scaleXZ() * 0.00375;
int xCoord = chunkX + x;
int zCoord = chunkZ + z;
double base = base_noise.getValue(xCoord * scale, zCoord * scale, false);
double main = Mth.inverseLerp(base, min, max);
double yOffset = y_offset.getValue(xCoord * scale * 0.75D, zCoord * scale * 0.75D, false);
float offs = (float) Mth.lerp(Mth.inverseLerp(yOffset, -0.5, 0.5), 0D, 10D);
if (main >= 0) {
float delta = MathUtil.costrp((float) Mth.clamp(main, 0, 1), 0, 1);
float blocksUp = Mth.lerp(delta, 0F, 5F) + offs;
float blocksDown = Mth.lerp(delta, 0F, 4F) - offs;

for (int i = Mth.floor(-blocksDown); i <= Mth.floor(blocksUp); i++) {
int y = Mth.clamp(context.config().yLevel() + i, context.level().getMinBuildHeight(), context.level().getMaxBuildHeight());
BlockPos pos = new BlockPos(xCoord, y, zCoord);
if (context.config().predicate().test(context.level(), pos)) {
this.setBlock(context.level(), pos, context.config().block().getState(context.random(), pos));
}
int chunkX = context.origin().getX() - (context.origin().getX() % 16);
int chunkZ = context.origin().getZ() - (context.origin().getZ() % 16);
float min = ReduxConfig.COMMON.cloud_layer_threshold_min.get().floatValue() / 2F;
float max = ReduxConfig.COMMON.cloud_layer_threshold_max.get().floatValue() / 2F;
for (int x = 0; x < 16; x++) {
for (int z = 0; z < 16; z++) {
double scale = context.config().scaleXZ() * 0.00375;
int xCoord = chunkX + x;
int zCoord = chunkZ + z;
double base = base_noise.getValue(xCoord * scale, zCoord * scale, false);
double main = Mth.inverseLerp(base, min, max);
double yOffset = y_offset.getValue(xCoord * scale * 0.75D, zCoord * scale * 0.75D, false);
float offs = (float) Mth.lerp(Mth.inverseLerp(yOffset, -0.5, 0.5), 0D, 10D);
if (main >= 0) {
float delta = MathUtil.costrp((float) Mth.clamp(main, 0, 1), 0, 1);
float blocksUp = Mth.lerp(delta, 0F, 5F) + offs;
float blocksDown = Mth.lerp(delta, 0F, 4F) - offs;
for (int i = Mth.floor(-blocksDown); i <= Mth.floor(blocksUp); i++) {
int y = Mth.clamp(context.config().yLevel() + i, context.level().getMinBuildHeight(), context.level().getMaxBuildHeight());
BlockPos pos = new BlockPos(xCoord, y, zCoord);
if (context.config().predicate().test(context.level(), pos)) {
this.setBlock(context.level(), pos, context.config().block().getState(context.random(), pos));
}
}
}
Expand Down

0 comments on commit a19719e

Please sign in to comment.