Add features to the allowed features set. Fixes features not spawning when added via the biome api. ()

This commit is contained in:
modmuss50 2021-10-31 10:41:16 +00:00 committed by GitHub
parent 0b944752fc
commit af0cec4081
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions
fabric-biome-api-v1/src/main/java/net/fabricmc/fabric
impl/biome/modification
mixin/biome/modification

View file

@ -19,10 +19,12 @@ package net.fabricmc.fabric.impl.biome.modification;
import java.util.ArrayList;
import java.util.EnumMap;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.BiPredicate;
import java.util.function.Supplier;
@ -260,6 +262,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
accessor.fabric_setFeatures(features);
accessor.fabric_setAllowedFeatures(new HashSet<>(accessor.fabric_getAllowedFeatures()));
}
private void unfreezeFlowerFeatures() {
@ -293,6 +296,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
accessor.fabric_setFeatures(ImmutableList.copyOf(featureSteps));
accessor.fabric_setAllowedFeatures(Set.copyOf(accessor.fabric_getAllowedFeatures()));
}
private void freezeFlowerFeatures() {
@ -334,6 +338,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
featureSteps.get(index).add(() -> configuredFeature);
accessor.fabric_getAllowedFeatures().add(configuredFeature);
// Ensure the list of flower features is up to date
rebuildFlowerFeatures();

View file

@ -18,6 +18,7 @@ package net.fabricmc.fabric.mixin.biome.modification;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.Supplier;
import org.spongepowered.asm.mixin.Mixin;
@ -37,6 +38,9 @@ public interface GenerationSettingsAccessor {
@Accessor("features")
List<List<Supplier<ConfiguredFeature<?, ?>>>> fabric_getFeatures();
@Accessor("allowedFeatures")
Set<ConfiguredFeature<?, ?>> fabric_getAllowedFeatures();
@Accessor("flowerFeatures")
List<ConfiguredFeature<?, ?>> fabric_getFlowerFeatures();
@ -48,6 +52,10 @@ public interface GenerationSettingsAccessor {
@Mutable
void fabric_setFeatures(List<List<Supplier<ConfiguredFeature<?, ?>>>> value);
@Accessor("allowedFeatures")
@Mutable
void fabric_setAllowedFeatures(Set<ConfiguredFeature<?, ?>> allowedFeatures);
@Accessor("flowerFeatures")
@Mutable
void fabric_setFlowerFeatures(List<ConfiguredFeature<?, ?>> value);