Restored the state of the biome api to what it was during the snapshots. Migrated from accessors to AWs. ()

This commit is contained in:
shartte 2021-11-16 19:45:37 +01:00 committed by GitHub
parent e77d3ea62f
commit 0f02669fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 228 additions and 495 deletions

View file

@ -21,6 +21,7 @@ import java.util.function.BiPredicate;
import org.jetbrains.annotations.NotNull;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.sound.BiomeAdditionsSound;
@ -35,7 +36,6 @@ import net.minecraft.world.biome.BiomeParticleConfig;
import net.minecraft.world.biome.SpawnSettings;
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 net.minecraft.world.gen.feature.StructureFeature;
@ -288,16 +288,16 @@ public interface BiomeModificationContext {
/**
* Removes a feature from one of this biomes generation steps, and returns if any features were removed.
*/
boolean removeFeature(GenerationStep.Feature step, RegistryKey<ConfiguredFeature<?, ?>> configuredFeatureKey);
boolean removeFeature(GenerationStep.Feature step, RegistryKey<PlacedFeature> placedFeatureKey);
/**
* Removes a feature from all of this biomes generation steps, and returns if any features were removed.
*/
default boolean removeFeature(RegistryKey<ConfiguredFeature<?, ?>> configuredFeatureKey) {
default boolean removeFeature(RegistryKey<PlacedFeature> placedFeatureKey) {
boolean anyFound = false;
for (GenerationStep.Feature step : GenerationStep.Feature.values()) {
if (removeFeature(step, configuredFeatureKey)) {
if (removeFeature(step, placedFeatureKey)) {
anyFound = true;
}
}
@ -306,34 +306,37 @@ public interface BiomeModificationContext {
}
/**
* {@link #removeFeature(RegistryKey)} for built-in features (see {@link #addBuiltInFeature(GenerationStep.Feature, ConfiguredFeature)}).
* {@link #removeFeature(RegistryKey)} for built-in features (see {@link #addBuiltInFeature(GenerationStep.Feature, PlacedFeature)}).
*/
default boolean removeBuiltInFeature(ConfiguredFeature<?, ?> configuredFeature) {
return removeFeature(BuiltInRegistryKeys.get(configuredFeature));
default boolean removeBuiltInFeature(PlacedFeature placedFeature) {
return removeFeature(BuiltInRegistryKeys.get(placedFeature));
}
/**
* {@link #removeFeature(GenerationStep.Feature, RegistryKey)} for built-in features (see {@link #addBuiltInFeature(GenerationStep.Feature, ConfiguredFeature)}).
* {@link #removeFeature(GenerationStep.Feature, RegistryKey)} for built-in features (see {@link #addBuiltInFeature(GenerationStep.Feature, PlacedFeature)}).
*/
default boolean removeBuiltInFeature(GenerationStep.Feature step, ConfiguredFeature<?, ?> configuredFeature) {
return removeFeature(step, BuiltInRegistryKeys.get(configuredFeature));
default boolean removeBuiltInFeature(GenerationStep.Feature step, PlacedFeature placedFeature) {
return removeFeature(step, BuiltInRegistryKeys.get(placedFeature));
}
/**
* Adds a feature to one of this biomes generation steps, identified by the configured feature's registry key.
* Adds a feature to one of this biomes generation steps, identified by the placed feature's registry key.
*
* @see BuiltinRegistries#PLACED_FEATURE
*/
void addFeature(GenerationStep.Feature step, RegistryKey<ConfiguredFeature<?, ?>> configuredFeatureKey);
void addFeature(GenerationStep.Feature step, RegistryKey<PlacedFeature> placedFeatureKey);
/**
* Adds a configured feature from {@link BuiltinRegistries#CONFIGURED_FEATURE} to this biome.
* Adds a placed feature from {@link BuiltinRegistries#PLACED_FEATURE} to this biome.
*
* <p>This method is intended for use with the configured features found in {@link net.minecraft.world.gen.feature.ConfiguredFeatures}.
* <p>This method is intended for use with the placed features found in
* classes such as {@link net.minecraft.world.gen.feature.OrePlacedFeatures}.
*
* <p><b>NOTE:</b> In case the configured feature is overridden in a datapack, the datapacks version
* <p><b>NOTE:</b> In case the placed feature is overridden in a datapack, the datapacks version
* will be used.
*/
default void addBuiltInFeature(GenerationStep.Feature step, ConfiguredFeature<?, ?> configuredFeature) {
addFeature(step, BuiltInRegistryKeys.get(configuredFeature));
default void addBuiltInFeature(GenerationStep.Feature step, PlacedFeature placedFeature) {
addFeature(step, BuiltInRegistryKeys.get(placedFeature));
}
/**
@ -401,7 +404,7 @@ public interface BiomeModificationContext {
* <p>Configured structures that have the same underlying {@link StructureFeature} as the given structure will be removed before
* adding the new structure, since only one of them could actually generate.
*
* @see net.minecraft.world.biome.GenerationSettings.Builder#structureFeature(ConfiguredStructureFeature)
* @see net.minecraft.world.biome.GenerationSettings.Builder#feature(GenerationStep.Feature, PlacedFeature)
*/
void addStructure(RegistryKey<ConfiguredStructureFeature<?, ?>> configuredStructureKey);
@ -473,7 +476,7 @@ public interface BiomeModificationContext {
/**
* Associated JSON property: <code>spawners</code>.
*
* @see SpawnSettings#getSpawnEntry(SpawnGroup)
* @see SpawnSettings#getSpawnEntries(SpawnGroup)
* @see SpawnSettings.Builder#spawn(SpawnGroup, SpawnSettings.SpawnEntry)
*/
void addSpawn(SpawnGroup spawnGroup, SpawnSettings.SpawnEntry spawnEntry);

View file

@ -20,6 +20,7 @@ import java.util.function.Predicate;
import com.google.common.base.Preconditions;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.util.Identifier;
@ -28,7 +29,6 @@ import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.SpawnSettings;
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;
/**
@ -45,7 +45,7 @@ public final class BiomeModifications {
*
* @see BiomeSelectors
*/
public static void addFeature(Predicate<BiomeSelectionContext> biomeSelector, GenerationStep.Feature step, RegistryKey<ConfiguredFeature<?, ?>> configuredFeatureKey) {
public static void addFeature(Predicate<BiomeSelectionContext> biomeSelector, GenerationStep.Feature step, RegistryKey<PlacedFeature> configuredFeatureKey) {
create(configuredFeatureKey.getValue()).add(ModificationPhase.ADDITIONS, biomeSelector, context -> {
context.getGenerationSettings().addFeature(step, configuredFeatureKey);
});

View file

@ -20,6 +20,7 @@ import java.util.List;
import java.util.Optional;
import java.util.function.Supplier;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.gen.feature.ConfiguredFeature;
@ -44,7 +45,8 @@ public interface BiomeSelectionContext {
* Returns true if this biome has the given configured feature, which must be registered
* in the {@link net.minecraft.util.registry.BuiltinRegistries}.
*
* <p>This method is intended for use with the Vanilla configured features found in {@link net.minecraft.world.gen.feature.ConfiguredFeatures}.
* <p>This method is intended for use with the Vanilla configured features found in
* classes such as {@link net.minecraft.world.gen.feature.OreConfiguredFeatures}.
*/
default boolean hasBuiltInFeature(ConfiguredFeature<?, ?> configuredFeature) {
RegistryKey<ConfiguredFeature<?, ?>> key = BuiltInRegistryKeys.get(configuredFeature);
@ -52,14 +54,42 @@ public interface BiomeSelectionContext {
}
/**
* Returns true if this biome contains a configured feature with the given key.
* Returns true if this biome has the given placed feature, which must be registered
* in the {@link net.minecraft.util.registry.BuiltinRegistries}.
*
* <p>This method is intended for use with the Vanilla placed features found in
* classes such as {@link net.minecraft.world.gen.feature.OrePlacedFeatures}.
*/
default boolean hasBuiltInPlacedFeature(PlacedFeature placedFeature) {
return hasPlacedFeature(BuiltInRegistryKeys.get(placedFeature));
}
/**
* Returns true if this biome contains a placed feature referencing a configured feature with the given key.
*/
default boolean hasFeature(RegistryKey<ConfiguredFeature<?, ?>> key) {
List<List<Supplier<ConfiguredFeature<?, ?>>>> featureSteps = getBiome().getGenerationSettings().getFeatures();
List<List<Supplier<PlacedFeature>>> featureSteps = getBiome().getGenerationSettings().getFeatures();
for (List<Supplier<ConfiguredFeature<?, ?>>> featureSuppliers : featureSteps) {
for (Supplier<ConfiguredFeature<?, ?>> featureSupplier : featureSuppliers) {
if (getFeatureKey(featureSupplier.get()).orElse(null) == key) {
for (List<Supplier<PlacedFeature>> featureSuppliers : featureSteps) {
for (Supplier<PlacedFeature> featureSupplier : featureSuppliers) {
if (featureSupplier.get().getDecoratedFeatures().anyMatch(cf -> getFeatureKey(cf).orElse(null) == key)) {
return true;
}
}
}
return false;
}
/**
* Returns true if this biome contains a placed feature with the given key.
*/
default boolean hasPlacedFeature(RegistryKey<PlacedFeature> key) {
List<List<Supplier<PlacedFeature>>> featureSteps = getBiome().getGenerationSettings().getFeatures();
for (List<Supplier<PlacedFeature>> featureSuppliers : featureSteps) {
for (Supplier<PlacedFeature> featureSupplier : featureSuppliers) {
if (getPlacedFeatureKey(featureSupplier.get()).orElse(null) == key) {
return true;
}
}
@ -75,6 +105,13 @@ public interface BiomeSelectionContext {
*/
Optional<RegistryKey<ConfiguredFeature<?, ?>>> getFeatureKey(ConfiguredFeature<?, ?> configuredFeature);
/**
* Tries to retrieve the registry key for the given placed feature, which should be from this biomes
* current feature list. May be empty if the placed feature is not registered, or does not come
* from this biomes feature list.
*/
Optional<RegistryKey<PlacedFeature>> getPlacedFeatureKey(PlacedFeature placedFeature);
/**
* Returns true if the given built-in configured structure from {@link net.minecraft.util.registry.BuiltinRegistries}
* can start in this biome.

View file

@ -33,6 +33,7 @@ import com.google.common.collect.ImmutableMap;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.NotNull;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.sound.BiomeAdditionsSound;
@ -56,30 +57,21 @@ import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.StructureFeature;
import net.fabricmc.fabric.api.biome.v1.BiomeModificationContext;
import net.fabricmc.fabric.mixin.biome.modification.BiomeAccessor;
import net.fabricmc.fabric.mixin.biome.modification.BiomeEffectsAccessor;
import net.fabricmc.fabric.mixin.biome.modification.BiomeWeatherAccessor;
import net.fabricmc.fabric.mixin.biome.modification.GenerationSettingsAccessor;
import net.fabricmc.fabric.mixin.biome.modification.SpawnDensityAccessor;
import net.fabricmc.fabric.mixin.biome.modification.SpawnSettingsAccessor;
@ApiStatus.Internal
public class BiomeModificationContextImpl implements BiomeModificationContext {
private final DynamicRegistryManager registries;
private final RegistryKey<Biome> biomeKey;
private final Biome biome;
private final BiomeAccessor biomeAccessor;
private final WeatherContext weather;
private final EffectsContext effects;
private final GenerationSettingsContextImpl generationSettings;
private final SpawnSettingsContextImpl spawnSettings;
@SuppressWarnings("ConstantConditions")
public BiomeModificationContextImpl(DynamicRegistryManager registries, RegistryKey<Biome> biomeKey, Biome biome) {
this.registries = registries;
this.biomeKey = biomeKey;
this.biome = biome;
this.biomeAccessor = (BiomeAccessor) (Object) biome;
this.weather = new WeatherContextImpl();
this.effects = new EffectsContextImpl();
this.generationSettings = new GenerationSettingsContextImpl();
@ -88,7 +80,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
@Override
public void setCategory(Biome.Category category) {
biomeAccessor.fabric_setCategory(category);
biome.category = category;
}
@Override
@ -120,109 +112,98 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
private class WeatherContextImpl implements WeatherContext {
private final BiomeWeatherAccessor accessor = (BiomeWeatherAccessor) biomeAccessor.fabric_getWeather();
private final Biome.Weather weather = biome.weather;
@Override
public void setPrecipitation(Biome.Precipitation precipitation) {
Objects.requireNonNull(precipitation);
accessor.setPrecipitation(precipitation);
weather.precipitation = Objects.requireNonNull(precipitation);
}
@Override
public void setTemperature(float temperature) {
accessor.setTemperature(temperature);
weather.temperature = temperature;
}
@Override
public void setTemperatureModifier(Biome.TemperatureModifier temperatureModifier) {
Objects.requireNonNull(temperatureModifier);
accessor.setTemperatureModifier(temperatureModifier);
weather.temperatureModifier = Objects.requireNonNull(temperatureModifier);
}
@Override
public void setDownfall(float downfall) {
accessor.setDownfall(downfall);
weather.downfall = downfall;
}
}
private class EffectsContextImpl implements EffectsContext {
private final BiomeEffectsAccessor accessor = (BiomeEffectsAccessor) biome.getEffects();
private final BiomeEffects effects = biome.getEffects();
@Override
public void setFogColor(int color) {
accessor.fabric_setFogColor(color);
effects.fogColor = color;
}
@Override
public void setWaterColor(int color) {
accessor.fabric_setWaterColor(color);
effects.waterColor = color;
}
@Override
public void setWaterFogColor(int color) {
accessor.fabric_setWaterFogColor(color);
effects.waterFogColor = color;
}
@Override
public void setSkyColor(int color) {
accessor.fabric_setSkyColor(color);
effects.skyColor = color;
}
@Override
public void setFoliageColor(Optional<Integer> color) {
Objects.requireNonNull(color);
accessor.fabric_setFoliageColor(color);
effects.foliageColor = Objects.requireNonNull(color);
}
@Override
public void setGrassColor(Optional<Integer> color) {
Objects.requireNonNull(color);
accessor.fabric_setGrassColor(color);
effects.grassColor = Objects.requireNonNull(color);
}
@Override
public void setGrassColorModifier(@NotNull BiomeEffects.GrassColorModifier colorModifier) {
Objects.requireNonNull(colorModifier);
accessor.fabric_setGrassColorModifier(colorModifier);
effects.grassColorModifier = Objects.requireNonNull(colorModifier);
}
@Override
public void setParticleConfig(Optional<BiomeParticleConfig> particleConfig) {
Objects.requireNonNull(particleConfig);
accessor.fabric_setParticleConfig(particleConfig);
effects.particleConfig = Objects.requireNonNull(particleConfig);
}
@Override
public void setAmbientSound(Optional<SoundEvent> sound) {
Objects.requireNonNull(sound);
accessor.fabric_setLoopSound(sound);
effects.loopSound = Objects.requireNonNull(sound);
}
@Override
public void setMoodSound(Optional<BiomeMoodSound> sound) {
Objects.requireNonNull(sound);
accessor.fabric_setMoodSound(sound);
effects.moodSound = Objects.requireNonNull(sound);
}
@Override
public void setAdditionsSound(Optional<BiomeAdditionsSound> sound) {
Objects.requireNonNull(sound);
accessor.fabric_setAdditionsSound(sound);
effects.additionsSound = Objects.requireNonNull(sound);
}
@Override
public void setMusic(Optional<MusicSound> sound) {
Objects.requireNonNull(sound);
accessor.fabric_setMusic(sound);
effects.music = Objects.requireNonNull(sound);
}
}
private class GenerationSettingsContextImpl implements GenerationSettingsContext {
private final Registry<ConfiguredCarver<?>> carvers = registries.get(Registry.CONFIGURED_CARVER_KEY);
private final Registry<ConfiguredFeature<?, ?>> features = registries.get(Registry.CONFIGURED_FEATURE_KEY);
private final Registry<PlacedFeature> features = registries.get(Registry.PLACED_FEATURE_KEY);
private final Registry<ConfiguredStructureFeature<?, ?>> structures = registries.get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY);
private final GenerationSettings generationSettings = biome.getGenerationSettings();
private final GenerationSettingsAccessor accessor = (GenerationSettingsAccessor) generationSettings;
/**
* Unfreeze the immutable lists found in the generation settings, and make sure they're filled up to every
@ -236,7 +217,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
private void unfreezeCarvers() {
Map<GenerationStep.Carver, List<Supplier<ConfiguredCarver<?>>>> carversByStep = new EnumMap<>(GenerationStep.Carver.class);
carversByStep.putAll(accessor.fabric_getCarvers());
carversByStep.putAll(generationSettings.carvers);
for (GenerationStep.Carver step : GenerationStep.Carver.values()) {
List<Supplier<ConfiguredCarver<?>>> carvers = carversByStep.get(step);
@ -250,23 +231,23 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
carversByStep.put(step, carvers);
}
accessor.fabric_setCarvers(carversByStep);
generationSettings.carvers = carversByStep;
}
private void unfreezeFeatures() {
List<List<Supplier<ConfiguredFeature<?, ?>>>> features = accessor.fabric_getFeatures();
List<List<Supplier<PlacedFeature>>> features = generationSettings.features;
features = new ArrayList<>(features);
for (int i = 0; i < features.size(); i++) {
features.set(i, new ArrayList<>(features.get(i)));
}
accessor.fabric_setFeatures(features);
accessor.fabric_setAllowedFeatures(new HashSet<>(accessor.fabric_getAllowedFeatures()));
generationSettings.features = features;
generationSettings.allowedFeatures = new HashSet<>(generationSettings.allowedFeatures);
}
private void unfreezeFlowerFeatures() {
accessor.fabric_setFlowerFeatures(new ArrayList<>(accessor.fabric_getFlowerFeatures()));
generationSettings.flowerFeatures = new ArrayList<>(generationSettings.flowerFeatures);
}
/**
@ -279,42 +260,42 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
private void freezeCarvers() {
Map<GenerationStep.Carver, List<Supplier<ConfiguredCarver<?>>>> carversByStep = accessor.fabric_getCarvers();
Map<GenerationStep.Carver, List<Supplier<ConfiguredCarver<?>>>> carversByStep = generationSettings.carvers;
for (GenerationStep.Carver step : GenerationStep.Carver.values()) {
carversByStep.put(step, ImmutableList.copyOf(carversByStep.get(step)));
}
accessor.fabric_setCarvers(ImmutableMap.copyOf(carversByStep));
generationSettings.carvers = ImmutableMap.copyOf(carversByStep);
}
private void freezeFeatures() {
List<List<Supplier<ConfiguredFeature<?, ?>>>> featureSteps = accessor.fabric_getFeatures();
List<List<Supplier<PlacedFeature>>> featureSteps = generationSettings.features;
for (int i = 0; i < featureSteps.size(); i++) {
featureSteps.set(i, ImmutableList.copyOf(featureSteps.get(i)));
}
accessor.fabric_setFeatures(ImmutableList.copyOf(featureSteps));
accessor.fabric_setAllowedFeatures(Set.copyOf(accessor.fabric_getAllowedFeatures()));
generationSettings.features = ImmutableList.copyOf(featureSteps);
generationSettings.allowedFeatures = (Set.copyOf(generationSettings.allowedFeatures));
}
private void freezeFlowerFeatures() {
accessor.fabric_setFlowerFeatures(ImmutableList.copyOf(accessor.fabric_getFlowerFeatures()));
generationSettings.flowerFeatures = ImmutableList.copyOf(generationSettings.flowerFeatures);
}
@Override
public boolean removeFeature(GenerationStep.Feature step, RegistryKey<ConfiguredFeature<?, ?>> configuredFeatureKey) {
ConfiguredFeature<?, ?> configuredFeature = features.getOrThrow(configuredFeatureKey);
public boolean removeFeature(GenerationStep.Feature step, RegistryKey<PlacedFeature> placedFeatureKey) {
PlacedFeature configuredFeature = features.getOrThrow(placedFeatureKey);
int stepIndex = step.ordinal();
List<List<Supplier<ConfiguredFeature<?, ?>>>> featureSteps = accessor.fabric_getFeatures();
List<List<Supplier<PlacedFeature>>> featureSteps = generationSettings.features;
if (stepIndex >= featureSteps.size()) {
return false; // The step was not populated with any features yet
}
List<Supplier<ConfiguredFeature<?, ?>>> featuresInStep = featureSteps.get(stepIndex);
List<Supplier<PlacedFeature>> featuresInStep = featureSteps.get(stepIndex);
if (featuresInStep.removeIf(supplier -> supplier.get() == configuredFeature)) {
rebuildFlowerFeatures();
@ -325,11 +306,11 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
@Override
public void addFeature(GenerationStep.Feature step, RegistryKey<ConfiguredFeature<?, ?>> configuredFeatureKey) {
public void addFeature(GenerationStep.Feature step, RegistryKey<PlacedFeature> placedFeatureKey) {
// We do not need to delay evaluation of this since the registries are already fully built
ConfiguredFeature<?, ?> configuredFeature = features.getOrThrow(configuredFeatureKey);
PlacedFeature placedFeature = features.getOrThrow(placedFeatureKey);
List<List<Supplier<ConfiguredFeature<?, ?>>>> featureSteps = accessor.fabric_getFeatures();
List<List<Supplier<PlacedFeature>>> featureSteps = generationSettings.features;
int index = step.ordinal();
// Add new empty lists for the generation steps that have no features yet
@ -337,8 +318,8 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
featureSteps.add(new ArrayList<>());
}
featureSteps.get(index).add(() -> configuredFeature);
accessor.fabric_getAllowedFeatures().add(configuredFeature);
featureSteps.get(index).add(() -> placedFeature);
generationSettings.allowedFeatures.add(placedFeature);
// Ensure the list of flower features is up to date
rebuildFlowerFeatures();
@ -348,13 +329,13 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
public void addCarver(GenerationStep.Carver step, RegistryKey<ConfiguredCarver<?>> carverKey) {
// We do not need to delay evaluation of this since the registries are already fully built
ConfiguredCarver<?> carver = carvers.getOrThrow(carverKey);
accessor.fabric_getCarvers().get(step).add(() -> carver);
generationSettings.carvers.get(step).add(() -> carver);
}
@Override
public boolean removeCarver(GenerationStep.Carver step, RegistryKey<ConfiguredCarver<?>> configuredCarverKey) {
ConfiguredCarver<?> carver = carvers.getOrThrow(configuredCarverKey);
return accessor.fabric_getCarvers().get(step).removeIf(supplier -> supplier.get() == carver);
return generationSettings.carvers.get(step).removeIf(supplier -> supplier.get() == carver);
}
@Override
@ -380,11 +361,11 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
* See the constructor of {@link GenerationSettings} for reference.
*/
private void rebuildFlowerFeatures() {
List<ConfiguredFeature<?, ?>> flowerFeatures = accessor.fabric_getFlowerFeatures();
List<ConfiguredFeature<?, ?>> flowerFeatures = generationSettings.flowerFeatures;
flowerFeatures.clear();
for (List<Supplier<ConfiguredFeature<?, ?>>> features : accessor.fabric_getFeatures()) {
for (Supplier<ConfiguredFeature<?, ?>> supplier : features) {
for (List<Supplier<PlacedFeature>> features : generationSettings.features) {
for (Supplier<PlacedFeature> supplier : features) {
supplier.get().getDecoratedFeatures()
.filter(configuredFeature -> configuredFeature.feature == Feature.FLOWER)
.forEachOrdered(flowerFeatures::add);
@ -394,7 +375,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
private class SpawnSettingsContextImpl implements SpawnSettingsContext {
private final SpawnSettingsAccessor accessor = (SpawnSettingsAccessor) biome.getSpawnSettings();
private final SpawnSettings spawnSettings = biome.getSpawnSettings();
private final EnumMap<SpawnGroup, List<SpawnSettings.SpawnEntry>> fabricSpawners = new EnumMap<>(SpawnGroup.class);
SpawnSettingsContextImpl() {
@ -406,7 +387,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
fabricSpawners.clear();
for (SpawnGroup spawnGroup : SpawnGroup.values()) {
Pool<SpawnSettings.SpawnEntry> entries = accessor.fabric_getSpawners().get(spawnGroup);
Pool<SpawnSettings.SpawnEntry> entries = spawnSettings.spawners.get(spawnGroup);
if (entries != null) {
fabricSpawners.put(spawnGroup, new ArrayList<>(entries.getEntries()));
@ -417,7 +398,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
private void unfreezeSpawnCost() {
accessor.fabric_setSpawnCosts(new HashMap<>(accessor.fabric_getSpawnCosts()));
spawnSettings.spawnCosts = new HashMap<>(spawnSettings.spawnCosts);
}
public void freeze() {
@ -426,7 +407,7 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
private void freezeSpawners() {
Map<SpawnGroup, Pool<SpawnSettings.SpawnEntry>> spawners = new HashMap<>(accessor.fabric_getSpawners());
Map<SpawnGroup, Pool<SpawnSettings.SpawnEntry>> spawners = new HashMap<>(spawnSettings.spawners);
for (Map.Entry<SpawnGroup, List<SpawnSettings.SpawnEntry>> entry : fabricSpawners.entrySet()) {
if (entry.getValue().isEmpty()) {
@ -436,21 +417,21 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
}
}
accessor.fabric_setSpawners(ImmutableMap.copyOf(spawners));
spawnSettings.spawners = ImmutableMap.copyOf(spawners);
}
private void freezeSpawnCosts() {
accessor.fabric_setSpawnCosts(ImmutableMap.copyOf(accessor.fabric_getSpawnCosts()));
spawnSettings.spawnCosts = ImmutableMap.copyOf(spawnSettings.spawnCosts);
}
@Override
public void setPlayerSpawnFriendly(boolean playerSpawnFriendly) {
accessor.fabric_setPlayerSpawnFriendly(playerSpawnFriendly);
spawnSettings.playerSpawnFriendly = playerSpawnFriendly;
}
@Override
public void setCreatureSpawnProbability(float probability) {
accessor.fabric_setCreatureSpawnProbability(probability);
spawnSettings.creatureSpawnProbability = probability;
}
@Override
@ -477,12 +458,12 @@ public class BiomeModificationContextImpl implements BiomeModificationContext {
@Override
public void setSpawnCost(EntityType<?> entityType, double mass, double gravityLimit) {
Objects.requireNonNull(entityType);
accessor.fabric_getSpawnCosts().put(entityType, SpawnDensityAccessor.create(gravityLimit, mass));
spawnSettings.spawnCosts.put(entityType, new SpawnSettings.SpawnDensity(gravityLimit, mass));
}
@Override
public void clearSpawnCost(EntityType<?> entityType) {
accessor.fabric_getSpawnCosts().remove(entityType);
spawnSettings.spawnCosts.remove(entityType);
}
}
}

View file

@ -21,6 +21,7 @@ import java.util.Optional;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.util.registry.DynamicRegistryManager;
import net.minecraft.util.registry.Registry;
import net.minecraft.util.registry.RegistryKey;
@ -60,6 +61,12 @@ public class BiomeSelectionContextImpl implements BiomeSelectionContext {
return registry.getKey(configuredFeature);
}
@Override
public Optional<RegistryKey<PlacedFeature>> getPlacedFeatureKey(PlacedFeature placedFeature) {
Registry<PlacedFeature> registry = dynamicRegistries.get(Registry.PLACED_FEATURE_KEY);
return registry.getKey(placedFeature);
}
@Override
public boolean hasStructure(RegistryKey<ConfiguredStructureFeature<?, ?>> key) {
ConfiguredStructureFeature<?, ?> instance = dynamicRegistries.get(Registry.CONFIGURED_STRUCTURE_FEATURE_KEY).get(key);

View file

@ -18,6 +18,7 @@ package net.fabricmc.fabric.impl.biome.modification;
import org.jetbrains.annotations.ApiStatus;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.util.registry.BuiltinRegistries;
import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.gen.carver.ConfiguredCarver;
@ -43,6 +44,11 @@ public final class BuiltInRegistryKeys {
.orElseThrow(() -> new IllegalArgumentException("Given configured feature is not built-in: " + configuredFeature));
}
public static RegistryKey<PlacedFeature> get(PlacedFeature placedFeature) {
return BuiltinRegistries.PLACED_FEATURE.getKey(placedFeature)
.orElseThrow(() -> new IllegalArgumentException("Given placed feature is not built-in: " + placedFeature));
}
public static RegistryKey<ConfiguredCarver<?>> get(ConfiguredCarver<?> configuredCarver) {
return BuiltinRegistries.CONFIGURED_CARVER.getKey(configuredCarver)
.orElseThrow(() -> new IllegalArgumentException("Given configured carver is not built-in: " + configuredCarver));

View file

@ -23,8 +23,8 @@ import java.util.function.Supplier;
import com.mojang.datafixers.util.Pair;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyArgs;
import org.spongepowered.asm.mixin.injection.invoke.arg.Args;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import net.minecraft.util.registry.Registry;
import net.minecraft.world.biome.Biome;
@ -39,9 +39,9 @@ import net.fabricmc.fabric.impl.biome.NetherBiomeData;
@Mixin(MultiNoiseBiomeSource.Preset.class)
public class MixinMultiNoiseBiomeSource {
// NOTE: This is a lambda-function in the NETHER preset field initializer
@ModifyArgs(method = "method_31088", at = @At(value = "INVOKE", target = "Lnet/minecraft/world/biome/source/MultiNoiseBiomeSource;<init>(Lnet/minecraft/world/biome/source/util/MultiNoiseUtil$Entries;Ljava/util/Optional;)V"))
private static void appendNetherBiomes(Args args, MultiNoiseBiomeSource.Preset preset, Registry<Biome> registry) {
MultiNoiseUtil.Entries<Biome> biomes = args.get(0);
@Inject(method = "method_31088", at = @At("RETURN"), cancellable = true)
private static void appendNetherBiomes(Registry<Biome> registry, CallbackInfoReturnable<MultiNoiseUtil.Entries<Supplier<Biome>>> cri) {
MultiNoiseUtil.Entries<Supplier<Biome>> biomes = cri.getReturnValue();
List<Pair<MultiNoiseUtil.NoiseHypercube, Supplier<Biome>>> entries = new ArrayList<>(biomes.getEntries());
// add fabric biome noise point data to list && BiomeSource biome list
@ -51,6 +51,6 @@ public class MixinMultiNoiseBiomeSource {
entries.add(Pair.of(noisePoint, () -> biome));
});
args.set(0, new MultiNoiseUtil.Entries<>(entries));
cri.setReturnValue(new MultiNoiseUtil.Entries<>(entries));
}
}

View file

@ -1,42 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.biome.modification;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.biome.SpawnSettings;
@Mixin(Biome.class)
public interface BiomeAccessor {
@Accessor("weather")
Biome.Weather fabric_getWeather();
@Accessor("generationSettings")
GenerationSettings fabric_getGenerationSettings();
@Accessor("spawnSettings")
@Mutable
SpawnSettings fabric_getSpawnSettings();
@Accessor("category")
@Mutable
void fabric_setCategory(Biome.Category category);
}

View file

@ -1,81 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.biome.modification;
import java.util.Optional;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.sound.BiomeAdditionsSound;
import net.minecraft.sound.BiomeMoodSound;
import net.minecraft.sound.MusicSound;
import net.minecraft.sound.SoundEvent;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.BiomeParticleConfig;
@Mixin(BiomeEffects.class)
public interface BiomeEffectsAccessor {
@Accessor("fogColor")
@Mutable
void fabric_setFogColor(int value);
@Accessor("waterColor")
@Mutable
void fabric_setWaterColor(int value);
@Accessor("waterFogColor")
@Mutable
void fabric_setWaterFogColor(int value);
@Accessor("skyColor")
@Mutable
void fabric_setSkyColor(int value);
@Accessor("foliageColor")
@Mutable
void fabric_setFoliageColor(Optional<Integer> value);
@Accessor("grassColor")
@Mutable
void fabric_setGrassColor(Optional<Integer> value);
@Accessor("grassColorModifier")
@Mutable
void fabric_setGrassColorModifier(BiomeEffects.GrassColorModifier value);
@Accessor("particleConfig")
@Mutable
void fabric_setParticleConfig(Optional<BiomeParticleConfig> value);
@Accessor("loopSound")
@Mutable
void fabric_setLoopSound(Optional<SoundEvent> value);
@Accessor("moodSound")
@Mutable
void fabric_setMoodSound(Optional<BiomeMoodSound> value);
@Accessor("additionsSound")
@Mutable
void fabric_setAdditionsSound(Optional<BiomeAdditionsSound> value);
@Accessor("music")
@Mutable
void fabric_setMusic(Optional<MusicSound> value);
}

View file

@ -1,54 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.biome.modification;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.biome.Biome;
@Mixin(Biome.Weather.class)
public interface BiomeWeatherAccessor {
@Accessor
Biome.Precipitation getPrecipitation();
@Accessor
@Mutable
void setPrecipitation(Biome.Precipitation precipitation);
@Accessor
float getTemperature();
@Accessor
@Mutable
void setTemperature(float temperature);
@Accessor
Biome.TemperatureModifier getTemperatureModifier();
@Accessor
@Mutable
void setTemperatureModifier(Biome.TemperatureModifier temperatureModifier);
@Accessor
float getDownfall();
@Accessor
@Mutable
void setDownfall(float downfall);
}

View file

@ -1,62 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.carver.ConfiguredCarver;
import net.minecraft.world.gen.feature.ConfiguredFeature;
@Mixin(GenerationSettings.class)
public interface GenerationSettingsAccessor {
@Accessor("carvers")
Map<GenerationStep.Carver, List<Supplier<ConfiguredCarver<?>>>> fabric_getCarvers();
@Accessor("features")
List<List<Supplier<ConfiguredFeature<?, ?>>>> fabric_getFeatures();
@Accessor("allowedFeatures")
Set<ConfiguredFeature<?, ?>> fabric_getAllowedFeatures();
@Accessor("flowerFeatures")
List<ConfiguredFeature<?, ?>> fabric_getFlowerFeatures();
@Accessor("carvers")
@Mutable
void fabric_setCarvers(Map<GenerationStep.Carver, List<Supplier<ConfiguredCarver<?>>>> value);
@Accessor("features")
@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);
}

View file

@ -1,30 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.biome.modification;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;
import net.minecraft.world.biome.SpawnSettings;
@Mixin(SpawnSettings.SpawnDensity.class)
public interface SpawnDensityAccessor {
@Invoker("<init>")
static SpawnSettings.SpawnDensity create(double gravityLimit, double mass) {
throw new AssertionError("mixin");
}
}

View file

@ -1,53 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.mixin.biome.modification;
import java.util.Map;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Mutable;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.util.collection.Pool;
import net.minecraft.entity.EntityType;
import net.minecraft.entity.SpawnGroup;
import net.minecraft.world.biome.SpawnSettings;
@Mixin(SpawnSettings.class)
public interface SpawnSettingsAccessor {
@Accessor("creatureSpawnProbability")
@Mutable
void fabric_setCreatureSpawnProbability(float probability);
@Accessor("spawners")
Map<SpawnGroup, Pool<SpawnSettings.SpawnEntry>> fabric_getSpawners();
@Accessor("spawners")
@Mutable
void fabric_setSpawners(Map<SpawnGroup, Pool<SpawnSettings.SpawnEntry>> spawners);
@Accessor("spawnCosts")
Map<EntityType<?>, SpawnSettings.SpawnDensity> fabric_getSpawnCosts();
@Accessor("spawnCosts")
@Mutable
void fabric_setSpawnCosts(Map<EntityType<?>, SpawnSettings.SpawnDensity> spawnCosts);
@Accessor("playerSpawnFriendly")
@Mutable
void fabric_setPlayerSpawnFriendly(boolean playerSpawnFriendly);
}

View file

@ -2,3 +2,68 @@ accessWidener v1 named
accessible class net/minecraft/world/biome/Biome$Weather
accessible field net/minecraft/world/gen/chunk/StructuresConfig configuredStructures Lcom/google/common/collect/ImmutableMap;
mutable field net/minecraft/world/gen/chunk/StructuresConfig configuredStructures Lcom/google/common/collect/ImmutableMap;
# Top-Level Biome Fields Access
accessible field net/minecraft/world/biome/Biome weather Lnet/minecraft/world/biome/Biome$Weather;
accessible field net/minecraft/world/biome/Biome generationSettings Lnet/minecraft/world/biome/GenerationSettings;
accessible field net/minecraft/world/biome/Biome spawnSettings Lnet/minecraft/world/biome/SpawnSettings;
accessible field net/minecraft/world/biome/Biome category Lnet/minecraft/world/biome/Biome$Category;
mutable field net/minecraft/world/biome/Biome category Lnet/minecraft/world/biome/Biome$Category;
# Biome Weather
accessible field net/minecraft/world/biome/Biome$Weather precipitation Lnet/minecraft/world/biome/Biome$Precipitation;
mutable field net/minecraft/world/biome/Biome$Weather precipitation Lnet/minecraft/world/biome/Biome$Precipitation;
accessible field net/minecraft/world/biome/Biome$Weather temperature F
mutable field net/minecraft/world/biome/Biome$Weather temperature F
accessible field net/minecraft/world/biome/Biome$Weather temperatureModifier Lnet/minecraft/world/biome/Biome$TemperatureModifier;
mutable field net/minecraft/world/biome/Biome$Weather temperatureModifier Lnet/minecraft/world/biome/Biome$TemperatureModifier;
accessible field net/minecraft/world/biome/Biome$Weather downfall F
mutable field net/minecraft/world/biome/Biome$Weather downfall F
# Biome Effects
accessible field net/minecraft/world/biome/BiomeEffects fogColor I
mutable field net/minecraft/world/biome/BiomeEffects fogColor I
accessible field net/minecraft/world/biome/BiomeEffects waterColor I
mutable field net/minecraft/world/biome/BiomeEffects waterColor I
accessible field net/minecraft/world/biome/BiomeEffects waterFogColor I
mutable field net/minecraft/world/biome/BiomeEffects waterFogColor I
accessible field net/minecraft/world/biome/BiomeEffects skyColor I
mutable field net/minecraft/world/biome/BiomeEffects skyColor I
accessible field net/minecraft/world/biome/BiomeEffects foliageColor Ljava/util/Optional;
mutable field net/minecraft/world/biome/BiomeEffects foliageColor Ljava/util/Optional;
accessible field net/minecraft/world/biome/BiomeEffects grassColor Ljava/util/Optional;
mutable field net/minecraft/world/biome/BiomeEffects grassColor Ljava/util/Optional;
accessible field net/minecraft/world/biome/BiomeEffects grassColorModifier Lnet/minecraft/world/biome/BiomeEffects$GrassColorModifier;
mutable field net/minecraft/world/biome/BiomeEffects grassColorModifier Lnet/minecraft/world/biome/BiomeEffects$GrassColorModifier;
accessible field net/minecraft/world/biome/BiomeEffects particleConfig Ljava/util/Optional;
mutable field net/minecraft/world/biome/BiomeEffects particleConfig Ljava/util/Optional;
accessible field net/minecraft/world/biome/BiomeEffects loopSound Ljava/util/Optional;
mutable field net/minecraft/world/biome/BiomeEffects loopSound Ljava/util/Optional;
accessible field net/minecraft/world/biome/BiomeEffects moodSound Ljava/util/Optional;
mutable field net/minecraft/world/biome/BiomeEffects moodSound Ljava/util/Optional;
accessible field net/minecraft/world/biome/BiomeEffects additionsSound Ljava/util/Optional;
mutable field net/minecraft/world/biome/BiomeEffects additionsSound Ljava/util/Optional;
accessible field net/minecraft/world/biome/BiomeEffects music Ljava/util/Optional;
mutable field net/minecraft/world/biome/BiomeEffects music Ljava/util/Optional;
# Spawn Settings / Density
accessible field net/minecraft/world/biome/SpawnSettings creatureSpawnProbability F
mutable field net/minecraft/world/biome/SpawnSettings creatureSpawnProbability F
accessible field net/minecraft/world/biome/SpawnSettings spawners Ljava/util/Map;
mutable field net/minecraft/world/biome/SpawnSettings spawners Ljava/util/Map;
accessible field net/minecraft/world/biome/SpawnSettings spawnCosts Ljava/util/Map;
mutable field net/minecraft/world/biome/SpawnSettings spawnCosts Ljava/util/Map;
accessible field net/minecraft/world/biome/SpawnSettings playerSpawnFriendly Z
mutable field net/minecraft/world/biome/SpawnSettings playerSpawnFriendly Z
accessible method net/minecraft/world/biome/SpawnSettings$SpawnDensity <init> (DD)V
# Generation Settings
accessible field net/minecraft/world/biome/GenerationSettings carvers Ljava/util/Map;
mutable field net/minecraft/world/biome/GenerationSettings carvers Ljava/util/Map;
accessible field net/minecraft/world/biome/GenerationSettings features Ljava/util/List;
mutable field net/minecraft/world/biome/GenerationSettings features Ljava/util/List;
accessible field net/minecraft/world/biome/GenerationSettings flowerFeatures Ljava/util/List;
mutable field net/minecraft/world/biome/GenerationSettings flowerFeatures Ljava/util/List;
accessible field net/minecraft/world/biome/GenerationSettings allowedFeatures Ljava/util/Set;
mutable field net/minecraft/world/biome/GenerationSettings allowedFeatures Ljava/util/Set;

View file

@ -3,15 +3,8 @@
"package": "net.fabricmc.fabric.mixin.biome",
"compatibilityLevel": "JAVA_17",
"mixins": [
"modification.BiomeAccessor",
"modification.BiomeEffectsAccessor",
"modification.BiomeWeatherAccessor",
"modification.BiomeWeatherAccessor",
"modification.DynamicRegistryManagerImplMixin",
"modification.GenerationSettingsAccessor",
"modification.RegistryOpsMixin",
"modification.SpawnDensityAccessor",
"modification.SpawnSettingsAccessor",
"MixinMultiNoiseBiomeSource",
"MixinTheEndBiomeSource"
],

View file

@ -24,17 +24,21 @@ import net.minecraft.util.registry.RegistryKey;
import net.minecraft.world.biome.Biome;
import net.minecraft.world.biome.BiomeEffects;
import net.minecraft.world.biome.BiomeKeys;
import net.minecraft.world.biome.OverworldBiomeCreator;
import net.minecraft.world.biome.GenerationSettings;
import net.minecraft.world.biome.OverworldBiomeCreator;
import net.minecraft.world.biome.SpawnSettings;
import net.minecraft.world.biome.TheNetherBiomeCreator;
import net.minecraft.world.biome.source.util.MultiNoiseUtil;
import net.minecraft.world.gen.GenerationStep;
import net.minecraft.world.gen.decorator.BiomePlacementModifier;
import net.minecraft.world.gen.decorator.SquarePlacementModifier;
import net.minecraft.world.gen.feature.ConfiguredFeature;
import net.minecraft.world.gen.feature.ConfiguredFeatures;
import net.minecraft.world.gen.feature.DefaultBiomeFeatures;
import net.minecraft.world.gen.feature.EndPlacedFeatures;
import net.minecraft.world.gen.feature.Feature;
import net.minecraft.world.gen.feature.FeatureConfig;
import net.minecraft.world.gen.feature.PlacedFeature;
import net.minecraft.world.gen.feature.PlacedFeatures;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.biome.v1.BiomeModifications;
@ -43,7 +47,6 @@ import net.fabricmc.fabric.api.biome.v1.ModificationPhase;
import net.fabricmc.fabric.api.biome.v1.NetherBiomes;
import net.fabricmc.fabric.api.biome.v1.TheEndBiomes;
import net.fabricmc.fabric.api.tag.TagFactory;
import net.fabricmc.fabric.test.biome.mixin.DecoratorsAccessor;
/**
* <b>NOTES FOR TESTING:</b>
@ -68,8 +71,8 @@ public class FabricBiomeTest implements ModInitializer {
public void onInitialize() {
Registry.register(BuiltinRegistries.BIOME, TEST_CRIMSON_FOREST.getValue(), TheNetherBiomeCreator.createCrimsonForest());
NetherBiomes.addNetherBiome(BiomeKeys.THE_END, MultiNoiseUtil.createNoiseValuePoint(0.0F, 0.5F, 0.0F, 0.0F, 0.0f, 0.1F));
NetherBiomes.addNetherBiome(TEST_CRIMSON_FOREST, MultiNoiseUtil.createNoiseValuePoint(0.0F, 0.5F, 0.0F, 0.0F, 0.0f, 0.275F));
NetherBiomes.addNetherBiome(BiomeKeys.PLAINS, MultiNoiseUtil.createNoiseHypercube(0.0F, 0.5F, 0.0F, 0.0F, 0.0f, 0, 0.1F));
NetherBiomes.addNetherBiome(TEST_CRIMSON_FOREST, MultiNoiseUtil.createNoiseHypercube(0.0F, 0.0F, 0.0f, 0.35F, 0.0f, 0.35F, 0.2F));
Registry.register(BuiltinRegistries.BIOME, CUSTOM_PLAINS.getValue(), OverworldBiomeCreator.createPlains(false, false, false));
@ -91,8 +94,12 @@ public class FabricBiomeTest implements ModInitializer {
TheEndBiomes.addMidlandsBiome(TEST_END_HIGHLANDS, TEST_END_MIDLANDS, 1.0);
TheEndBiomes.addBarrensBiome(TEST_END_HIGHLANDS, TEST_END_BARRRENS, 1.0);
ConfiguredFeature<?, ?> COMMON_DESERT_WELL = Feature.DESERT_WELL.configure(FeatureConfig.DEFAULT).decorate(DecoratorsAccessor.getSQUARE_HEIGHTMAP());
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(MOD_ID, "common_desert_well"), COMMON_DESERT_WELL);
ConfiguredFeature<?, ?> COMMON_DESERT_WELL = Feature.DESERT_WELL.configure(FeatureConfig.DEFAULT);
Registry.register(BuiltinRegistries.CONFIGURED_FEATURE, new Identifier(MOD_ID, "fab_desert_well"), COMMON_DESERT_WELL);
// The placement config is taken from the vanilla desert well, but no randomness
PlacedFeature PLACED_COMMON_DESERT_WELL = COMMON_DESERT_WELL.withPlacement(SquarePlacementModifier.of(), PlacedFeatures.MOTION_BLOCKING_HEIGHTMAP, BiomePlacementModifier.of());
Registry.register(BuiltinRegistries.PLACED_FEATURE, new Identifier(MOD_ID, "fab_desert_well"), PLACED_COMMON_DESERT_WELL);
BiomeModifications.create(new Identifier("fabric:test_mod"))
.add(ModificationPhase.ADDITIONS,
@ -102,7 +109,7 @@ public class FabricBiomeTest implements ModInitializer {
BiomeSelectors.categories(Biome.Category.DESERT),
context -> {
context.getGenerationSettings().addFeature(GenerationStep.Feature.TOP_LAYER_MODIFICATION,
BuiltinRegistries.CONFIGURED_FEATURE.getKey(COMMON_DESERT_WELL).get()
BuiltinRegistries.PLACED_FEATURE.getKey(PLACED_COMMON_DESERT_WELL).get()
);
})
.add(ModificationPhase.ADDITIONS,
@ -112,9 +119,9 @@ public class FabricBiomeTest implements ModInitializer {
// These are used for testing the spacing of custom end biomes.
private static Biome createEndHighlands() {
GenerationSettings.Builder builder = (new GenerationSettings.Builder())
.feature(GenerationStep.Feature.SURFACE_STRUCTURES, ConfiguredFeatures.END_GATEWAY)
.feature(GenerationStep.Feature.VEGETAL_DECORATION, ConfiguredFeatures.CHORUS_PLANT);
GenerationSettings.Builder builder = new GenerationSettings.Builder()
.feature(GenerationStep.Feature.SURFACE_STRUCTURES, EndPlacedFeatures.END_GATEWAY_RETURN)
.feature(GenerationStep.Feature.VEGETAL_DECORATION, EndPlacedFeatures.CHORUS_PLANT);
return composeEndSpawnSettings(builder);
}

View file

@ -1,30 +0,0 @@
/*
* Copyright (c) 2016, 2017, 2018, 2019 FabricMC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package net.fabricmc.fabric.test.biome.mixin;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import net.minecraft.world.gen.decorator.ConfiguredDecorator;
@Mixin(targets = "net.minecraft.world.gen.feature.ConfiguredFeatures$Decorators")
public interface DecoratorsAccessor {
@Accessor
static ConfiguredDecorator<?> getSQUARE_HEIGHTMAP() {
throw new UnsupportedOperationException("");
}
}

View file

@ -1,11 +0,0 @@
{
"required": true,
"package": "net.fabricmc.fabric.test.biome.mixin",
"compatibilityLevel": "JAVA_17",
"mixins": [
"DecoratorsAccessor"
],
"injectors": {
"defaultRequire": 1
}
}

View file

@ -12,8 +12,5 @@
"main": [
"net.fabricmc.fabric.test.biome.FabricBiomeTest"
]
},
"mixins": [
"fabric-biome-testmod-api-v1.mixins.json"
]
}
}

View file

@ -14,7 +14,7 @@ rootProject.name = "fabric-api"
include 'fabric-api-base'
include 'fabric-api-lookup-api-v1'
//include 'fabric-biome-api-v1'
include 'fabric-biome-api-v1'
include 'fabric-blockrenderlayer-v1'
include 'fabric-commands-v0'
include 'fabric-command-api-v1'