Skip to content

Commit

Permalink
Port previous changes to 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
Juuxel committed Jul 15, 2023
1 parent a58c8d6 commit 211222c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -275,10 +275,10 @@ private Biome pinyGrove() {
.build();
}

private GenerationSettings generationSettings(Consumer<GenerationSettings.LookupBackedBuilder> configurator) {
private GenerationSettings generationSettings(Consumer<WamGenerationSettingsBuilder> configurator) {
RegistryEntryLookup<PlacedFeature> placedFeatures = registerable.getRegistryLookup(RegistryKeys.PLACED_FEATURE);
RegistryEntryLookup<ConfiguredCarver<?>> configuredCarvers = registerable.getRegistryLookup(RegistryKeys.CONFIGURED_CARVER);
GenerationSettings.LookupBackedBuilder builder = new GenerationSettings.LookupBackedBuilder(placedFeatures, configuredCarvers);
WamGenerationSettingsBuilder builder = new WamGenerationSettingsBuilder(placedFeatures, configuredCarvers);
configurator.accept(builder);
return builder.build();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package juuxel.woodsandmires.data.builtin;

import juuxel.woodsandmires.data.mixin.GenerationSettingsBuilderAccessor;
import net.minecraft.registry.RegistryEntryLookup;
import net.minecraft.registry.RegistryKey;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.util.TopologicalSorts;
import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.carver.ConfiguredCarver;
Expand All @@ -16,33 +18,21 @@
import java.util.Set;
import java.util.function.Consumer;

public class WamGenerationSettingsBuilder extends GenerationSettings.Builder {
public class WamGenerationSettingsBuilder extends GenerationSettings.LookupBackedBuilder {
// step -> before -> [after]
private final Map<GenerationStep.Feature, Map<RegistryEntry<PlacedFeature>, Set<RegistryEntry<PlacedFeature>>>> orderingsByStep =
new EnumMap<>(GenerationStep.Feature.class);
private final RegistryEntryLookup<PlacedFeature> placedFeatureLookup;

@Override
public WamGenerationSettingsBuilder feature(GenerationStep.Feature featureStep, RegistryEntry<PlacedFeature> feature) {
super.feature(featureStep, feature);
return this;
}

@Override
public WamGenerationSettingsBuilder feature(int stepIndex, RegistryEntry<PlacedFeature> featureEntry) {
super.feature(stepIndex, featureEntry);
return this;
}

@Override
public WamGenerationSettingsBuilder carver(GenerationStep.Carver carverStep, RegistryEntry<? extends ConfiguredCarver<?>> carver) {
super.carver(carverStep, carver);
return this;
public WamGenerationSettingsBuilder(RegistryEntryLookup<PlacedFeature> placedFeatureLookup, RegistryEntryLookup<ConfiguredCarver<?>> configuredCarverLookup) {
super(placedFeatureLookup, configuredCarverLookup);
this.placedFeatureLookup = placedFeatureLookup;
}

public WamGenerationSettingsBuilder addOrdering(GenerationStep.Feature step, RegistryEntry<PlacedFeature> before, RegistryEntry<PlacedFeature> after) {
public WamGenerationSettingsBuilder addOrdering(GenerationStep.Feature step, RegistryKey<PlacedFeature> before, RegistryKey<PlacedFeature> after) {
orderingsByStep.computeIfAbsent(step, s -> new HashMap<>())
.computeIfAbsent(before, entry -> new HashSet<>())
.add(after);
.computeIfAbsent(placedFeatureLookup.getOrThrow(before), entry -> new HashSet<>())
.add(placedFeatureLookup.getOrThrow(after));
return this;
}

Expand All @@ -55,7 +45,7 @@ public GenerationSettings build() {
private void order() {
orderingsByStep.forEach((step, orderings) -> {
List<RegistryEntry<PlacedFeature>> features = ((GenerationSettingsBuilderAccessor) this)
.getFeatures()
.getIndexedFeaturesList()
.get(step.ordinal());

Set<RegistryEntry<PlacedFeature>> visited = new HashSet<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package juuxel.woodsandmires.data.mixin;

import net.minecraft.util.registry.RegistryEntry;
import net.minecraft.registry.entry.RegistryEntry;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.feature.PlacedFeature;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -11,5 +11,5 @@
@Mixin(GenerationSettings.Builder.class)
public interface GenerationSettingsBuilderAccessor {
@Accessor
List<List<RegistryEntry<PlacedFeature>>> getFeatures();
List<List<RegistryEntry<PlacedFeature>>> getIndexedFeaturesList();
}

0 comments on commit 211222c

Please sign in to comment.