mirror of
https://github.com/FabricMC/fabric.git
synced 2024-11-14 19:25:23 -05:00
Fix inconsistency of placed feature locations (#3369)
* Fix inconsistency of placed feature locations
`BiomeSource#getBiomes` mixin applies to all biome sources, including one for Overworld.
The return value is a set; however one caller in the worldgen code iterates over it: `PlacedFeatureIndexer`.
Using a hash set here randomizes the return value, affecting feature placement.
Use a linked hash set instead.
* Improve fix to only make changes when required.
---------
Co-authored-by: modmuss50 <modmuss50@gmail.com>
(cherry picked from commit 661cc8c6dc
)
This commit is contained in:
parent
6f9f09e0c4
commit
991b3a082e
2 changed files with 11 additions and 8 deletions
|
@ -16,8 +16,6 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.biome;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -33,11 +31,10 @@ import net.minecraft.world.biome.source.BiomeSource;
|
|||
public class BiomeSourceMixin {
|
||||
@Redirect(method = "getBiomes", at = @At(value = "INVOKE", target = "Ljava/util/function/Supplier;get()Ljava/lang/Object;"))
|
||||
private Object getBiomes(Supplier<Set<RegistryEntry<Biome>>> instance) {
|
||||
var biomes = new HashSet<>(instance.get());
|
||||
fabric_modifyBiomeSet(biomes);
|
||||
return Collections.unmodifiableSet(biomes);
|
||||
return fabric_modifyBiomeSet(instance.get());
|
||||
}
|
||||
|
||||
protected void fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
|
||||
protected Set<RegistryEntry<Biome>> fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
|
||||
return biomes;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package net.fabricmc.fabric.mixin.biome;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Set;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
|
@ -108,14 +110,18 @@ public class TheEndBiomeSourceMixin extends BiomeSourceMixin {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected void fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
|
||||
protected Set<RegistryEntry<Biome>> fabric_modifyBiomeSet(Set<RegistryEntry<Biome>> biomes) {
|
||||
if (!hasCheckedForModifiedSet) {
|
||||
hasCheckedForModifiedSet = true;
|
||||
biomeSetModified = !overrides.get().customBiomes.isEmpty();
|
||||
}
|
||||
|
||||
if (biomeSetModified) {
|
||||
biomes.addAll(overrides.get().customBiomes);
|
||||
var modifiedBiomes = new LinkedHashSet<>(biomes);
|
||||
modifiedBiomes.addAll(overrides.get().customBiomes);
|
||||
return Collections.unmodifiableSet(modifiedBiomes);
|
||||
}
|
||||
|
||||
return biomes;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue