Skip to content

Commit

Permalink
fix: fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Zepalesque committed Jun 2, 2024
1 parent 41dcfe4 commit e0c64ec
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,10 @@
import net.minecraft.world.level.levelgen.feature.configurations.SimpleBlockConfiguration;
import net.minecraft.world.level.levelgen.feature.configurations.TreeConfiguration;
import net.minecraft.world.level.levelgen.feature.featuresize.TwoLayersFeatureSize;
import net.minecraft.world.level.levelgen.feature.foliageplacers.BlobFoliagePlacer;
import net.minecraft.world.level.levelgen.feature.stateproviders.BlockStateProvider;
import net.minecraft.world.level.levelgen.feature.stateproviders.WeightedStateProvider;
import net.minecraft.world.level.levelgen.feature.trunkplacers.StraightTrunkPlacer;
import net.neoforged.neoforge.registries.DeferredHolder;
import net.zepalesque.redux.Redux;
import net.zepalesque.redux.block.ReduxBlocks;
Expand All @@ -35,18 +37,22 @@
import net.zepalesque.redux.data.resource.builders.ReduxFeatureBuilders;
import net.zepalesque.redux.world.feature.gen.CloudbedFeature;
import net.zepalesque.redux.world.feature.gen.ReduxFeatures;
import net.zepalesque.redux.world.tree.foliage.SkyrootFoliagePlacer;

import java.util.function.Supplier;

public class ReduxFeatureConfig extends ReduxFeatureBuilders {

public static final ResourceKey<ConfiguredFeature<?, ?>> CRYSTAL_TREE = AetherConfiguredFeatures.CRYSTAL_TREE_CONFIGURATION;
public static final ResourceKey<ConfiguredFeature<?, ?>> CLOUDBED = createKey("cloudbed");

// Overrides
public static final ResourceKey<ConfiguredFeature<?, ?>> GRASS_BONEMEAL = createKey("aether_grass_bonemeal");
public static final ResourceKey<ConfiguredFeature<?, ?>> GRASS_PATCH = AetherConfiguredFeatures.GRASS_PATCH_CONFIGURATION;
public static final ResourceKey<ConfiguredFeature<?, ?>> TALL_GRASS_PATCH = AetherConfiguredFeatures.TALL_GRASS_PATCH_CONFIGURATION;

public static final ResourceKey<ConfiguredFeature<?, ?>> GRASS_BONEMEAL = createKey("aether_grass_bonemeal");
public static final ResourceKey<ConfiguredFeature<?, ?>> CRYSTAL_TREE = AetherConfiguredFeatures.CRYSTAL_TREE_CONFIGURATION;
public static final ResourceKey<ConfiguredFeature<?, ?>> SKYROOT_TREE = AetherConfiguredFeatures.SKYROOT_TREE_CONFIGURATION;

public static final ResourceKey<ConfiguredFeature<?, ?>> CLOUDBED = createKey("cloudbed");



Expand Down Expand Up @@ -79,6 +85,15 @@ public static void bootstrap(BootstapContext<ConfiguredFeature<?, ?>> context) {
new CrystalFoliagePlacer(ConstantInt.of(0), ConstantInt.of(0), ConstantInt.of(6)),
new TwoLayersFeatureSize(1, 0, 1)).ignoreVines().build());

register(context, SKYROOT_TREE, Feature.TREE,
new TreeConfiguration.TreeConfigurationBuilder(
BlockStateProvider.simple(AetherFeatureStates.SKYROOT_LOG),
new StraightTrunkPlacer(4, 2, 0),
BlockStateProvider.simple(AetherFeatureStates.SKYROOT_LEAVES),
new SkyrootFoliagePlacer(ConstantInt.of(2), ConstantInt.of(0)),
new TwoLayersFeatureSize(1, 0, 1)
).ignoreVines().build());


}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,13 @@ protected void createFoliage(LevelSimulatedReader level, FoliageSetter setter, R
placeLeavesRow(level, setter, rand, config, origin, radius, -3, false);
}

// Override vanilla behavior of using the 'large' boolean value to actually affect the size, this is unwanted behavior in this case
protected void placeLeavesRow(LevelSimulatedReader level, FoliageSetter setter, RandomSource rand, TreeConfiguration config, BlockPos pos, int radius, int y, boolean large) {
BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos();
for(int j = -radius; j <= radius; ++j) {
for(int k = -radius; k <= radius; ++k) {
if (!this.shouldSkipLocationSigned(rand, j, y, k, radius, large)) {
blockpos$mutableblockpos.setWithOffset(pos, j, y, k);
tryPlaceLeaf(level, setter, rand, config, blockpos$mutableblockpos);
}
}
}
}

@Override
public int foliageHeight(RandomSource rand, int pHeight, TreeConfiguration config) {
return 0;
}



@Override
protected boolean shouldSkipLocation(RandomSource rand, int x, int y, int z, int radius, boolean remove) {
protected boolean shouldSkipLocation(RandomSource rand, int x, int y, int z, int radius, boolean large) {
if (y == 0) {
// If the y offset is 0, only skip the location if it is on the corners, AND a boolean check succeeds
return x + z >= radius * 2 && rand.nextBoolean();
Expand Down

0 comments on commit e0c64ec

Please sign in to comment.