Merge 1.20 into 1.21.1
This commit is contained in:
commit
422f570ddd
|
|
@ -1,2 +1,2 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
git ls-remote --heads origin | awk '{print $2}' | grep -E '^refs/heads/1\.' | sed 's:.*/::' | sort -V | grep -E '^1\.[0-9]*(\.[0-9]*)?$'
|
git ls-remote --heads origin | awk '{print $2}' | grep -E '^refs/heads/[0-9]+\.' | sed 's:.*/::' | sort -V | grep -E '^[0-9]+\.[0-9]*(\.[0-9]*)?$'
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package org.embeddedt.modernfix.world.gen;
|
package org.embeddedt.modernfix.world.gen;
|
||||||
|
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps;
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps;
|
||||||
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
|
|
@ -58,32 +57,49 @@ public class SurfaceRuleOptimizer {
|
||||||
noMatchSources.add(innerSource);
|
noMatchSources.add(innerSource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return new OptimizedBiomeLookupSequenceRule(perBiomeSources, List.copyOf(noMatchSources));
|
@SuppressWarnings("unchecked")
|
||||||
|
ResourceKey<Biome>[] biomeKeys = new ResourceKey[perBiomeSources.size()];
|
||||||
|
SurfaceRules.RuleSource[][] sourcesPerBiome = new SurfaceRules.RuleSource[perBiomeSources.size()][];
|
||||||
|
int i = 0;
|
||||||
|
for (var entry : Reference2ObjectMaps.fastIterable(perBiomeSources)) {
|
||||||
|
biomeKeys[i] = entry.getKey();
|
||||||
|
sourcesPerBiome[i] = entry.getValue().toArray(new SurfaceRules.RuleSource[0]);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return new OptimizedBiomeLookupSequenceRule(biomeKeys, sourcesPerBiome, noMatchSources.toArray(new SurfaceRules.RuleSource[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public record OptimizedBiomeLookupSequenceRule(
|
public record OptimizedBiomeLookupSequenceRule(
|
||||||
Reference2ObjectMap<ResourceKey<Biome>, List<SurfaceRules.RuleSource>> sourcesForBiomeMatch,
|
ResourceKey<Biome>[] biomeKeys,
|
||||||
List<SurfaceRules.RuleSource> sourcesForNoBiomeMatch
|
SurfaceRules.RuleSource[][] sourcesPerBiome,
|
||||||
|
SurfaceRules.RuleSource[] sourcesForNoBiomeMatch
|
||||||
) implements SurfaceRules.RuleSource {
|
) implements SurfaceRules.RuleSource {
|
||||||
@Override
|
@Override
|
||||||
public SurfaceRules.SurfaceRule apply(SurfaceRules.Context context) {
|
public SurfaceRules.SurfaceRule apply(SurfaceRules.Context context) {
|
||||||
var sourcesForBiomeMatch = this.sourcesForBiomeMatch;
|
var biomeKeys = this.biomeKeys;
|
||||||
|
var sourcesPerBiome = this.sourcesPerBiome;
|
||||||
Reference2ObjectOpenHashMap<ResourceKey<Biome>, List<SurfaceRules.SurfaceRule>> compiledBiomeMatch =
|
Reference2ObjectOpenHashMap<ResourceKey<Biome>, List<SurfaceRules.SurfaceRule>> compiledBiomeMatch =
|
||||||
new Reference2ObjectOpenHashMap<>(sourcesForBiomeMatch.size());
|
new Reference2ObjectOpenHashMap<>(biomeKeys.length);
|
||||||
Reference2ObjectMaps.fastForEach(sourcesForBiomeMatch, entry -> {
|
for (int i = 0; i < biomeKeys.length; i++) {
|
||||||
SurfaceRules.SurfaceRule[] compiled = new SurfaceRules.SurfaceRule[entry.getValue().size()];
|
var uncompiled = sourcesPerBiome[i];
|
||||||
var uncompiled = entry.getValue();
|
SurfaceRules.SurfaceRule[] compiled = new SurfaceRules.SurfaceRule[uncompiled.length];
|
||||||
for (int i = 0; i < uncompiled.size(); i++) {
|
for (int j = 0; j < uncompiled.length; j++) {
|
||||||
compiled[i] = uncompiled.get(i).apply(context);
|
compiled[j] = uncompiled[j].apply(context);
|
||||||
}
|
}
|
||||||
compiledBiomeMatch.put(entry.getKey(), List.of(compiled));
|
compiledBiomeMatch.put(biomeKeys[i], List.of(compiled));
|
||||||
});
|
|
||||||
var sourcesForNoBiomeMatch = this.sourcesForNoBiomeMatch;
|
|
||||||
SurfaceRules.SurfaceRule[] compiledNoMatch = new SurfaceRules.SurfaceRule[sourcesForNoBiomeMatch.size()];
|
|
||||||
for (int i = 0; i < sourcesForNoBiomeMatch.size(); i++) {
|
|
||||||
compiledNoMatch[i] = sourcesForNoBiomeMatch.get(i).apply(context);
|
|
||||||
}
|
}
|
||||||
return new CompiledOptimizedBiomeLookupRule(compiledBiomeMatch, List.of(compiledNoMatch), context);
|
var sourcesForNoBiomeMatch = this.sourcesForNoBiomeMatch;
|
||||||
|
List<SurfaceRules.SurfaceRule> compiledNoMatchList;
|
||||||
|
if (sourcesForNoBiomeMatch.length > 0) {
|
||||||
|
SurfaceRules.SurfaceRule[] compiledNoMatch = new SurfaceRules.SurfaceRule[sourcesForNoBiomeMatch.length];
|
||||||
|
for (int i = 0; i < sourcesForNoBiomeMatch.length; i++) {
|
||||||
|
compiledNoMatch[i] = sourcesForNoBiomeMatch[i].apply(context);
|
||||||
|
}
|
||||||
|
compiledNoMatchList = List.of(compiledNoMatch);
|
||||||
|
} else {
|
||||||
|
compiledNoMatchList = List.of();
|
||||||
|
}
|
||||||
|
return new CompiledOptimizedBiomeLookupRule(compiledBiomeMatch, compiledNoMatchList, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user