Skip to content

Commit 422f570

Browse files
committed
Merge 1.20 into 1.21.1
2 parents 51f273f + 4ec8ef7 commit 422f570

2 files changed

Lines changed: 34 additions & 18 deletions

File tree

scripts/branchlist.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
#!/bin/bash
2-
git ls-remote --heads origin | awk '{print $2}' | grep -E '^refs/heads/1\.' | sed 's:.*/::' | sort -V | grep -E '^1\.[0-9]*(\.[0-9]*)?$'
2+
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]*)?$'

src/main/java/org/embeddedt/modernfix/world/gen/SurfaceRuleOptimizer.java

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package org.embeddedt.modernfix.world.gen;
22

3-
import it.unimi.dsi.fastutil.objects.Reference2ObjectMap;
43
import it.unimi.dsi.fastutil.objects.Reference2ObjectMaps;
54
import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
65
import net.minecraft.core.Holder;
@@ -58,32 +57,49 @@ public static SurfaceRules.RuleSource optimizeSequenceRuleSource(SurfaceRules.Se
5857
noMatchSources.add(innerSource);
5958
}
6059
}
61-
return new OptimizedBiomeLookupSequenceRule(perBiomeSources, List.copyOf(noMatchSources));
60+
@SuppressWarnings("unchecked")
61+
ResourceKey<Biome>[] biomeKeys = new ResourceKey[perBiomeSources.size()];
62+
SurfaceRules.RuleSource[][] sourcesPerBiome = new SurfaceRules.RuleSource[perBiomeSources.size()][];
63+
int i = 0;
64+
for (var entry : Reference2ObjectMaps.fastIterable(perBiomeSources)) {
65+
biomeKeys[i] = entry.getKey();
66+
sourcesPerBiome[i] = entry.getValue().toArray(new SurfaceRules.RuleSource[0]);
67+
i++;
68+
}
69+
return new OptimizedBiomeLookupSequenceRule(biomeKeys, sourcesPerBiome, noMatchSources.toArray(new SurfaceRules.RuleSource[0]));
6270
}
6371

6472
public record OptimizedBiomeLookupSequenceRule(
65-
Reference2ObjectMap<ResourceKey<Biome>, List<SurfaceRules.RuleSource>> sourcesForBiomeMatch,
66-
List<SurfaceRules.RuleSource> sourcesForNoBiomeMatch
73+
ResourceKey<Biome>[] biomeKeys,
74+
SurfaceRules.RuleSource[][] sourcesPerBiome,
75+
SurfaceRules.RuleSource[] sourcesForNoBiomeMatch
6776
) implements SurfaceRules.RuleSource {
6877
@Override
6978
public SurfaceRules.SurfaceRule apply(SurfaceRules.Context context) {
70-
var sourcesForBiomeMatch = this.sourcesForBiomeMatch;
79+
var biomeKeys = this.biomeKeys;
80+
var sourcesPerBiome = this.sourcesPerBiome;
7181
Reference2ObjectOpenHashMap<ResourceKey<Biome>, List<SurfaceRules.SurfaceRule>> compiledBiomeMatch =
72-
new Reference2ObjectOpenHashMap<>(sourcesForBiomeMatch.size());
73-
Reference2ObjectMaps.fastForEach(sourcesForBiomeMatch, entry -> {
74-
SurfaceRules.SurfaceRule[] compiled = new SurfaceRules.SurfaceRule[entry.getValue().size()];
75-
var uncompiled = entry.getValue();
76-
for (int i = 0; i < uncompiled.size(); i++) {
77-
compiled[i] = uncompiled.get(i).apply(context);
82+
new Reference2ObjectOpenHashMap<>(biomeKeys.length);
83+
for (int i = 0; i < biomeKeys.length; i++) {
84+
var uncompiled = sourcesPerBiome[i];
85+
SurfaceRules.SurfaceRule[] compiled = new SurfaceRules.SurfaceRule[uncompiled.length];
86+
for (int j = 0; j < uncompiled.length; j++) {
87+
compiled[j] = uncompiled[j].apply(context);
7888
}
79-
compiledBiomeMatch.put(entry.getKey(), List.of(compiled));
80-
});
89+
compiledBiomeMatch.put(biomeKeys[i], List.of(compiled));
90+
}
8191
var sourcesForNoBiomeMatch = this.sourcesForNoBiomeMatch;
82-
SurfaceRules.SurfaceRule[] compiledNoMatch = new SurfaceRules.SurfaceRule[sourcesForNoBiomeMatch.size()];
83-
for (int i = 0; i < sourcesForNoBiomeMatch.size(); i++) {
84-
compiledNoMatch[i] = sourcesForNoBiomeMatch.get(i).apply(context);
92+
List<SurfaceRules.SurfaceRule> compiledNoMatchList;
93+
if (sourcesForNoBiomeMatch.length > 0) {
94+
SurfaceRules.SurfaceRule[] compiledNoMatch = new SurfaceRules.SurfaceRule[sourcesForNoBiomeMatch.length];
95+
for (int i = 0; i < sourcesForNoBiomeMatch.length; i++) {
96+
compiledNoMatch[i] = sourcesForNoBiomeMatch[i].apply(context);
97+
}
98+
compiledNoMatchList = List.of(compiledNoMatch);
99+
} else {
100+
compiledNoMatchList = List.of();
85101
}
86-
return new CompiledOptimizedBiomeLookupRule(compiledBiomeMatch, List.of(compiledNoMatch), context);
102+
return new CompiledOptimizedBiomeLookupRule(compiledBiomeMatch, compiledNoMatchList, context);
87103
}
88104

89105
@Override

0 commit comments

Comments
 (0)