Sort initial relic sub affixes like on official server

Relics created by commands are not affected, unless the "-sorted" flag is added
This commit is contained in:
Melledy 2024-02-06 23:09:26 -08:00
parent 1bad1b85a5
commit f67450203d
3 changed files with 19 additions and 1 deletions

View File

@ -268,6 +268,8 @@ public class CommandArgs {
}
item.getSubAffixes().forEach(subAffix -> subAffix.setStep(subAffix.getCount() * 2));
} if (this.hasFlag("-sorted")) {
item.sortSubAffixes();
}
}

View File

@ -1,6 +1,7 @@
package emu.lunarcore.game.inventory;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.bson.types.ObjectId;
@ -103,6 +104,8 @@ public class GameItem {
// Sub affixes
int baseSubAffixes = Math.min(Math.max(getExcel().getRarity().getVal() - 2, 0), 3);
this.addSubAffixes(Utils.randomRange(baseSubAffixes, baseSubAffixes + 1));
// Sort sub affixes
this.sortSubAffixes();
}
break;
default:
@ -238,6 +241,14 @@ public class GameItem {
public int getMaxNormalSubAffixCount() {
return (getExcel().getRarity().getVal() - 1) + (int) Math.floor(this.getLevel() / 3.0);
}
public void sortSubAffixes() {
if (this.subAffixes == null || this.subAffixes.size() == 0) {
return;
}
Collections.sort(this.subAffixes);
}
// Database

View File

@ -9,7 +9,7 @@ import lombok.Setter;
@Getter
@Entity(useDiscriminator = false)
public class GameItemSubAffix {
public class GameItemSubAffix implements Comparable<GameItemSubAffix> {
private int id; // Affix id
@Setter private int count;
@ -43,4 +43,9 @@ public class GameItemSubAffix {
return proto;
}
@Override
public int compareTo(GameItemSubAffix o) {
return this.getId() - o.getId();
}
}