mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-02 16:05:29 +00:00
switch to namespace based injection
This commit is contained in:
parent
1bd5cf31fa
commit
788a3c2d48
@ -14,39 +14,32 @@ public class PreLoadCompatibilityOptions implements ConfigTemplate {
|
||||
@Default
|
||||
private boolean doRegistryInjection = false;
|
||||
|
||||
@Value("features.inject-biome.enable")
|
||||
@Value("features.inject-namespaces")
|
||||
@Default
|
||||
private boolean doBiomeInjection = false;
|
||||
private Set<String> featureNamespaces = new HashSet<>();
|
||||
|
||||
@Value("structures.inject-namespaces")
|
||||
@Default
|
||||
private Set<String> structureNamespaces = new HashSet<>();
|
||||
|
||||
@Value("features.inject-registry.excluded-features")
|
||||
@Default
|
||||
private Set<Identifier> excludedRegistryFeatures = new HashSet<>();
|
||||
|
||||
@Value("features.inject-biome.excluded-features")
|
||||
@Default
|
||||
private Set<Identifier> excludedBiomeFeatures = new HashSet<>();
|
||||
|
||||
@Value("structures.inject-biome.excluded-features")
|
||||
@Default
|
||||
private Set<Identifier> excludedBiomeStructures = new HashSet<>();
|
||||
public Set<String> getFeatureNamespaces() {
|
||||
return featureNamespaces;
|
||||
}
|
||||
|
||||
public boolean doBiomeInjection() {
|
||||
return doBiomeInjection;
|
||||
public Set<String> getStructureNamespaces() {
|
||||
return structureNamespaces;
|
||||
}
|
||||
|
||||
public boolean doRegistryInjection() {
|
||||
return doRegistryInjection;
|
||||
}
|
||||
|
||||
public Set<Identifier> getExcludedBiomeFeatures() {
|
||||
return excludedBiomeFeatures;
|
||||
}
|
||||
|
||||
public Set<Identifier> getExcludedRegistryFeatures() {
|
||||
return excludedRegistryFeatures;
|
||||
}
|
||||
|
||||
public Set<Identifier> getExcludedBiomeStructures() {
|
||||
return excludedBiomeStructures;
|
||||
}
|
||||
}
|
||||
|
@ -17,11 +17,13 @@ import net.minecraft.world.gen.GenerationStep;
|
||||
import net.minecraft.world.gen.carver.ConfiguredCarver;
|
||||
import net.minecraft.world.gen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.gen.feature.ConfiguredStructureFeature;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public final class FabricUtil {
|
||||
@ -64,25 +66,24 @@ public final class FabricUtil {
|
||||
TerraFabricPlugin.getInstance().getDebugLogger().info("Injecting Vanilla structures and features into Terra biome " + biome.getTemplate().getID());
|
||||
|
||||
for(Supplier<ConfiguredStructureFeature<?, ?>> structureFeature : vanilla.getGenerationSettings().getStructureFeatures()) {
|
||||
Identifier key = BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.getId(structureFeature.get());
|
||||
if(!compatibilityOptions.getExcludedBiomeStructures().contains(key) && !postLoadCompatibilityOptions.getExcludedPerBiomeStructures().getOrDefault(biome, Collections.emptySet()).contains(key)) {
|
||||
Identifier key = Objects.requireNonNull(BuiltinRegistries.CONFIGURED_STRUCTURE_FEATURE.getId(structureFeature.get()));
|
||||
if(compatibilityOptions.getStructureNamespaces().contains(key.getNamespace()) && !postLoadCompatibilityOptions.getExcludedPerBiomeStructures().getOrDefault(biome, Collections.emptySet()).contains(key)) {
|
||||
generationSettings.structureFeature(structureFeature.get());
|
||||
TerraFabricPlugin.getInstance().getDebugLogger().info("Injected structure " + key);
|
||||
}
|
||||
}
|
||||
|
||||
if(compatibilityOptions.doBiomeInjection()) {
|
||||
for(int step = 0; step < vanilla.getGenerationSettings().getFeatures().size(); step++) {
|
||||
for(Supplier<ConfiguredFeature<?, ?>> featureSupplier : vanilla.getGenerationSettings().getFeatures().get(step)) {
|
||||
Identifier key = BuiltinRegistries.CONFIGURED_FEATURE.getId(featureSupplier.get());
|
||||
if(!compatibilityOptions.getExcludedBiomeFeatures().contains(key) && !postLoadCompatibilityOptions.getExcludedPerBiomeFeatures().getOrDefault(biome, Collections.emptySet()).contains(key)) {
|
||||
generationSettings.feature(step, featureSupplier);
|
||||
TerraFabricPlugin.getInstance().getDebugLogger().info("Injected feature " + key + " at stage " + step);
|
||||
}
|
||||
for(int step = 0; step < vanilla.getGenerationSettings().getFeatures().size(); step++) {
|
||||
for(Supplier<ConfiguredFeature<?, ?>> featureSupplier : vanilla.getGenerationSettings().getFeatures().get(step)) {
|
||||
Identifier key = Objects.requireNonNull(BuiltinRegistries.CONFIGURED_FEATURE.getId(featureSupplier.get()));
|
||||
if(compatibilityOptions.getFeatureNamespaces().contains(key.getNamespace()) && !postLoadCompatibilityOptions.getExcludedPerBiomeFeatures().getOrDefault(biome, Collections.emptySet()).contains(key)) {
|
||||
generationSettings.feature(step, featureSupplier);
|
||||
TerraFabricPlugin.getInstance().getDebugLogger().info("Injected feature " + key + " at stage " + step);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
BiomeEffectsAccessor accessor = (BiomeEffectsAccessor) vanilla.getEffects();
|
||||
BiomeEffects.Builder effects = new BiomeEffects.Builder()
|
||||
.waterColor(colors.getOrDefault("water", accessor.getWaterColor()))
|
||||
|
Loading…
x
Reference in New Issue
Block a user