Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Book Binder #3299

Closed
wants to merge 8 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
import io.github.thebusybiscuit.slimefun4.api.items.settings.IntRangeSetting;
import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;

import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.AContainer;
import me.mrCookieSlime.Slimefun.Objects.SlimefunItem.abstractItems.MachineRecipe;
import me.mrCookieSlime.Slimefun.api.inventory.BlockMenu;
Expand Down Expand Up @@ -129,13 +128,14 @@ private Map<Enchantment, Integer> combineEnchantments(Map<Enchantment, Integer>
if (!hasConflicts) {
enchantments.merge(entry.getKey(), entry.getValue(), (a, b) -> {
int maxLevel = entry.getKey().getMaxLevel();
return combineEnchantmentLevels(maxLevel, a, b);
int newLevel = combineEnchantmentLevels(maxLevel, a, b);

return newLevel == 0 ? null : newLevel;
});
}
}

return enchantments;

}

private int combineEnchantmentLevels(int maxLevel, int lvl1, int lvl2) {
Expand All @@ -145,9 +145,9 @@ private int combineEnchantmentLevels(int maxLevel, int lvl1, int lvl2) {
* unless it uses bypass-vanilla-max-level
*/
if (maxLevel <= lvl1 && !bypassVanillaMaxLevel.getValue()) {
return maxLevel;
return 0;
} else if (hasCustomMaxLevel.getValue()) {
return lvl1 + 1 > customMaxLevel.getValue() ? customMaxLevel.getValue() : lvl1 + 1;
return lvl1 + 1 > customMaxLevel.getValue() ? 0 : lvl1 + 1;
} else {
return lvl1 + 1;
}
Expand All @@ -165,7 +165,6 @@ private int combineEnchantmentLevels(int maxLevel, int lvl1, int lvl2) {
} else {
return highestLevel;
}

}
}
}
}