Skip to content

Commit

Permalink
Fix: apply all rules from subversions of target version
Browse files Browse the repository at this point in the history
  • Loading branch information
Gegy committed Jan 23, 2024
1 parent 070cfae commit 4afa75e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/main/java/com/mojang/datafixers/DataFixerUpper.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,20 +107,20 @@ private int getLowestFixSameVersion(final int versionKey) {
return fixerVersions.subSet(0, versionKey + 1).lastInt();
}

protected TypeRewriteRule getRule(final int version, final int dataVersion) {
if (version >= dataVersion) {
protected TypeRewriteRule getRule(final int version, final int newVersion) {
if (version >= newVersion) {
return TypeRewriteRule.nop();
}

final int expandedVersion = getLowestFixSameVersion(DataFixUtils.makeKey(version));
final int expandedDataVersion = DataFixUtils.makeKey(dataVersion);

final long key = (long) expandedVersion << 32 | expandedDataVersion;
final long key = (long) version << 32 | newVersion;
return rules.computeIfAbsent(key, k -> {
final int expandedVersion = getLowestFixSameVersion(DataFixUtils.makeKey(version));

final List<TypeRewriteRule> rules = Lists.newArrayList();
for (final DataFix fix : globalList) {
final int fixVersion = fix.getVersionKey();
if (fixVersion > expandedVersion && fixVersion <= expandedDataVersion) {
final int expandedFixVersion = fix.getVersionKey();
final int fixVersion = DataFixUtils.getVersion(expandedFixVersion);
if (expandedFixVersion > expandedVersion && fixVersion <= newVersion) {
final TypeRewriteRule fixRule = fix.getRule();
if (fixRule == TypeRewriteRule.nop()) {
continue;
Expand Down

0 comments on commit 4afa75e

Please sign in to comment.