Crash fix
This commit is contained in:
parent
8e3147f176
commit
d3273f609a
3 changed files with 30 additions and 23 deletions
|
@ -33,6 +33,7 @@ import net.minecraft.world.level.levelgen.GenerationStep.Carving;
|
|||
import net.minecraft.world.level.levelgen.GenerationStep.Decoration;
|
||||
import net.minecraft.world.level.levelgen.NoiseGeneratorSettings;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules;
|
||||
import net.minecraft.world.level.levelgen.SurfaceRules.RuleSource;
|
||||
import net.minecraft.world.level.levelgen.carver.ConfiguredWorldCarver;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredFeature;
|
||||
import net.minecraft.world.level.levelgen.feature.ConfiguredStructureFeature;
|
||||
|
@ -442,24 +443,14 @@ public class BiomeAPI {
|
|||
Set<Biome> biomes = source.possibleBiomes();
|
||||
|
||||
if (level.dimension() == Level.NETHER) {
|
||||
Set<ResourceLocation> biomeIDs = biomes.stream().map(biome -> getBiomeID(biome)).collect(Collectors.toSet());
|
||||
List<SurfaceRules.RuleSource> rules = Lists.newArrayList();
|
||||
SURFACE_RULES.forEach((biomeID, rule) -> {
|
||||
if (biomeIDs.contains(biomeID)) {
|
||||
rules.add(rule);
|
||||
}
|
||||
});
|
||||
netherRuleSource = SurfaceRules.sequence(rules.toArray(new SurfaceRules.RuleSource[rules.size()]));
|
||||
RuleSource[] rules = getRuleSources(biomes);
|
||||
netherRuleSource = rules.length > 0 ? SurfaceRules.sequence(rules) : null;
|
||||
System.out.println("Adding nether sources! " + rules.length);
|
||||
}
|
||||
else if (level.dimension() == Level.END) {
|
||||
Set<ResourceLocation> biomeIDs = biomes.stream().map(biome -> getBiomeID(biome)).collect(Collectors.toSet());
|
||||
List<SurfaceRules.RuleSource> rules = Lists.newArrayList();
|
||||
SURFACE_RULES.forEach((biomeID, rule) -> {
|
||||
if (biomeIDs.contains(biomeID)) {
|
||||
rules.add(rule);
|
||||
}
|
||||
});
|
||||
endRuleSource = SurfaceRules.sequence(rules.toArray(new SurfaceRules.RuleSource[rules.size()]));
|
||||
RuleSource[] rules = getRuleSources(biomes);
|
||||
endRuleSource = rules.length > 0 ? SurfaceRules.sequence(rules) : null;
|
||||
System.out.println("Adding end sources! " + rules.length);
|
||||
}
|
||||
|
||||
List<BiConsumer<ResourceLocation, Biome>> modifications = MODIFICATIONS.get(level.dimension());
|
||||
|
@ -485,6 +476,17 @@ public class BiomeAPI {
|
|||
});
|
||||
}
|
||||
|
||||
private static SurfaceRules.RuleSource[] getRuleSources(Set<Biome> biomes) {
|
||||
Set<ResourceLocation> biomeIDs = biomes.stream().map(biome -> getBiomeID(biome)).collect(Collectors.toSet());
|
||||
List<SurfaceRules.RuleSource> rules = Lists.newArrayList();
|
||||
SURFACE_RULES.forEach((biomeID, rule) -> {
|
||||
if (biomeIDs.contains(biomeID)) {
|
||||
rules.add(rule);
|
||||
}
|
||||
});
|
||||
return rules.toArray(new SurfaceRules.RuleSource[rules.size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds new features to existing biome.
|
||||
* @param biome {@link Biome} to add features in.
|
||||
|
|
|
@ -13,15 +13,19 @@ import ru.bclib.api.biomes.BiomeAPI;
|
|||
public class SurfaceRuleDataMixin {
|
||||
@Inject(method = "nether", at = @At("RETURN"), cancellable = true)
|
||||
private static void bclib_addNetherRuleSource(CallbackInfoReturnable<SurfaceRules.RuleSource> info) {
|
||||
RuleSource source = info.getReturnValue();
|
||||
source = SurfaceRules.sequence(source, BiomeAPI.getNetherRuleSource());
|
||||
info.setReturnValue(source);
|
||||
if (BiomeAPI.getNetherRuleSource() != null) {
|
||||
RuleSource source = info.getReturnValue();
|
||||
source = SurfaceRules.sequence(source, BiomeAPI.getNetherRuleSource());
|
||||
info.setReturnValue(source);
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "end", at = @At("RETURN"), cancellable = true)
|
||||
private static void bclib_addEndRuleSource(CallbackInfoReturnable<SurfaceRules.RuleSource> info) {
|
||||
RuleSource source = info.getReturnValue();
|
||||
source = SurfaceRules.sequence(source, BiomeAPI.getEndRuleSource());
|
||||
info.setReturnValue(source);
|
||||
if (BiomeAPI.getEndRuleSource() != null) {
|
||||
RuleSource source = info.getReturnValue();
|
||||
source = SurfaceRules.sequence(source, BiomeAPI.getEndRuleSource());
|
||||
info.setReturnValue(source);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@
|
|||
"MainMixin",
|
||||
"BiomeGenerationSettingsAccessor",
|
||||
"MobSpawnSettingsAccessor",
|
||||
"StructureSettingsAccessor"
|
||||
"StructureSettingsAccessor",
|
||||
"SurfaceRuleDataMixin"
|
||||
],
|
||||
"injectors": {
|
||||
"defaultRequire": 1
|
||||
|
|
Loading…
Reference in a new issue