Skip to content

Commit

Permalink
fix(utils): fix getHighestEnchantment function
Browse files Browse the repository at this point in the history
  • Loading branch information
WakelessSloth56 committed Jul 18, 2022
1 parent e11a318 commit 3944669
Showing 1 changed file with 7 additions and 5 deletions.
Expand Up @@ -34,14 +34,16 @@ static void enchantRandom(ListTag enchantments, int level) {


static CompoundTag getHighestEnchantment(ListTag enchantments) {
int highestIndex = 0;
int highestLevel = 0;
int index = 0;
short highestLevel = 0;
for (int i = 0, l = enchantments.size(); i < l; i++) {
if (enchantments.getCompound(i).getShort("lvl") > highestLevel) {
highestIndex = i;
short lvl = enchantments.getCompound(i).getShort("lvl");
if (lvl > highestLevel) {
index = i;
highestLevel = lvl;
}
}
return enchantments.getCompound(highestIndex);
return enchantments.getCompound(index);
}

static boolean isOverLimit(ListTag enchantments) {
Expand Down

0 comments on commit 3944669

Please sign in to comment.