[Change] SurfaceRules for the Nether will get injected after all biome independent rules
This commit is contained in:
parent
a49ada07d4
commit
00ef6fcfa1
3 changed files with 28 additions and 5 deletions
|
@ -15,7 +15,7 @@ public interface InjectableSurfaceRules<G extends ChunkGenerator> {
|
||||||
*/
|
*/
|
||||||
default void injectSurfaceRules(ResourceKey<LevelStem> dimensionKey) {
|
default void injectSurfaceRules(ResourceKey<LevelStem> dimensionKey) {
|
||||||
if (this instanceof NoiseBasedChunkGenerator nbc) {
|
if (this instanceof NoiseBasedChunkGenerator nbc) {
|
||||||
SurfaceRuleUtil.injectSurfaceRules(nbc.generatorSettings().value(), nbc.getBiomeSource());
|
SurfaceRuleUtil.injectSurfaceRules(dimensionKey, nbc.generatorSettings().value(), nbc.getBiomeSource());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ import net.minecraft.world.level.dimension.LevelStem;
|
||||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -50,6 +51,7 @@ public class SurfaceRuleUtil {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SurfaceRules.RuleSource mergeSurfaceRules(
|
private static SurfaceRules.RuleSource mergeSurfaceRules(
|
||||||
|
ResourceKey<LevelStem> dimensionKey,
|
||||||
SurfaceRules.RuleSource org,
|
SurfaceRules.RuleSource org,
|
||||||
BiomeSource source,
|
BiomeSource source,
|
||||||
List<SurfaceRules.RuleSource> additionalRules
|
List<SurfaceRules.RuleSource> additionalRules
|
||||||
|
@ -62,8 +64,23 @@ public class SurfaceRuleUtil {
|
||||||
.stream()
|
.stream()
|
||||||
.filter(r -> existingSequence.indexOf(r) < 0)
|
.filter(r -> existingSequence.indexOf(r) < 0)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (additionalRules.size() == 0) return null;
|
if (additionalRules.isEmpty()) return null;
|
||||||
additionalRules.addAll(existingSequence);
|
|
||||||
|
// when we are in the nether, we want to keep the nether roof and floor rules in the beginning of the sequence
|
||||||
|
// we will add our rules whne the first biome test sequence is found
|
||||||
|
if (dimensionKey.equals(LevelStem.NETHER)) {
|
||||||
|
final List<SurfaceRules.RuleSource> combined = new ArrayList<>(existingSequence.size() + additionalRules.size());
|
||||||
|
for (SurfaceRules.RuleSource rule : existingSequence) {
|
||||||
|
if (rule instanceof SurfaceRules.TestRuleSource testRule
|
||||||
|
&& testRule.ifTrue() instanceof SurfaceRules.BiomeConditionSource) {
|
||||||
|
combined.addAll(additionalRules);
|
||||||
|
}
|
||||||
|
combined.add(rule);
|
||||||
|
}
|
||||||
|
additionalRules = combined;
|
||||||
|
} else {
|
||||||
|
additionalRules.addAll(existingSequence);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (!additionalRules.contains(org))
|
if (!additionalRules.contains(org))
|
||||||
additionalRules.add(org);
|
additionalRules.add(org);
|
||||||
|
@ -75,10 +92,15 @@ public class SurfaceRuleUtil {
|
||||||
return new SurfaceRules.SequenceRuleSource(additionalRules);
|
return new SurfaceRules.SequenceRuleSource(additionalRules);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void injectSurfaceRules(NoiseGeneratorSettings noiseSettings, BiomeSource loadedBiomeSource) {
|
public static void injectSurfaceRules(
|
||||||
|
ResourceKey<LevelStem> dimensionKey,
|
||||||
|
NoiseGeneratorSettings noiseSettings,
|
||||||
|
BiomeSource loadedBiomeSource
|
||||||
|
) {
|
||||||
if (((Object) noiseSettings) instanceof SurfaceRuleProvider srp) {
|
if (((Object) noiseSettings) instanceof SurfaceRuleProvider srp) {
|
||||||
SurfaceRules.RuleSource originalRules = srp.bclib_getOriginalSurfaceRules();
|
SurfaceRules.RuleSource originalRules = srp.bclib_getOriginalSurfaceRules();
|
||||||
srp.bclib_overwriteSurfaceRules(mergeSurfaceRules(
|
srp.bclib_overwriteSurfaceRules(mergeSurfaceRules(
|
||||||
|
dimensionKey,
|
||||||
originalRules,
|
originalRules,
|
||||||
loadedBiomeSource,
|
loadedBiomeSource,
|
||||||
getRulesForBiomes(loadedBiomeSource.possibleBiomes().stream().map(h -> h.value()).toList())
|
getRulesForBiomes(loadedBiomeSource.possibleBiomes().stream().map(h -> h.value()).toList())
|
||||||
|
|
|
@ -15,7 +15,8 @@ accessible class net/minecraft/world/level/levelgen/SurfaceRules$SequenceRul
|
||||||
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
|
accessible class net/minecraft/server/dedicated/DedicatedServerProperties$WorldDimensionData
|
||||||
accessible class net/minecraft/client/resources/model/AtlasSet$AtlasEntry
|
accessible class net/minecraft/client/resources/model/AtlasSet$AtlasEntry
|
||||||
extendable class net/minecraft/world/level/block/state/properties/WoodType
|
extendable class net/minecraft/world/level/block/state/properties/WoodType
|
||||||
|
accessible class net/minecraft/world/level/levelgen/SurfaceRules$BiomeConditionSource
|
||||||
|
accessible class net/minecraft/world/level/levelgen/SurfaceRules$TestRuleSource
|
||||||
|
|
||||||
#Methods
|
#Methods
|
||||||
accessible method net/minecraft/world/level/storage/loot/LootPool <init> ([Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer;[Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition;[Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)V
|
accessible method net/minecraft/world/level/storage/loot/LootPool <init> ([Lnet/minecraft/world/level/storage/loot/entries/LootPoolEntryContainer;[Lnet/minecraft/world/level/storage/loot/predicates/LootItemCondition;[Lnet/minecraft/world/level/storage/loot/functions/LootItemFunction;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;Lnet/minecraft/world/level/storage/loot/providers/number/NumberProvider;)V
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue