Skip to content

Commit

Permalink
Add config options for min and max bookshelves + levels for enchantme…
Browse files Browse the repository at this point in the history
…nt cracker
  • Loading branch information
Earthcomputer committed Apr 4, 2024
1 parent 8ebb89f commit c36ec63
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 2 deletions.
40 changes: 40 additions & 0 deletions src/main/java/net/earthcomputer/clientcommands/Configs.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,46 @@ public static void setMaxEnchantItemThrows(int maxEnchantItemThrows) {
Configs.maxEnchantItemThrows = Mth.clamp(maxEnchantItemThrows, 0, 1000000);
}

@Config(setter = @Config.Setter("setMinEnchantBookshelves"))
private static int minEnchantBookshelves = 0;
public static int getMinEnchantBookshelves() {
return minEnchantBookshelves;
}
public static void setMinEnchantBookshelves(int minEnchantBookshelves) {
Configs.minEnchantBookshelves = Mth.clamp(minEnchantBookshelves, 0, 15);
Configs.maxEnchantBookshelves = Math.max(Configs.maxEnchantBookshelves, Configs.minEnchantBookshelves);
}

@Config(setter = @Config.Setter("setMaxEnchantBookshelves"))
private static int maxEnchantBookshelves = 15;
public static int getMaxEnchantBookshelves() {
return maxEnchantBookshelves;
}
public static void setMaxEnchantBookshelves(int maxEnchantBookshelves) {
Configs.maxEnchantBookshelves = Mth.clamp(maxEnchantBookshelves, 0, 15);
Configs.minEnchantBookshelves = Math.min(Configs.minEnchantBookshelves, Configs.maxEnchantBookshelves);
}

@Config(setter = @Config.Setter("setMinEnchantLevels"))
private static int minEnchantLevels = 1;
public static int getMinEnchantLevels() {
return minEnchantLevels;
}
public static void setMinEnchantLevels(int minEnchantLevels) {
Configs.minEnchantLevels = Mth.clamp(minEnchantLevels, 1, 30);
Configs.maxEnchantLevels = Math.max(Configs.maxEnchantLevels, Configs.minEnchantLevels);
}

@Config(setter = @Config.Setter("setMaxEnchantLevels"))
private static int maxEnchantLevels = 30;
public static int getMaxEnchantLevels() {
return maxEnchantLevels;
}
public static void setMaxEnchantLevels(int maxEnchantLevels) {
Configs.maxEnchantLevels = Mth.clamp(maxEnchantLevels, 1, 30);
Configs.minEnchantLevels = Math.min(Configs.minEnchantLevels, Configs.maxEnchantLevels);
}

@Config(setter = @Config.Setter("setChorusManipulation"), temporary = true)
private static boolean chorusManipulation = false;
public static boolean getChorusManipulation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ public static String manipulateEnchantments(Item item, Predicate<List<Enchantmen

int[] enchantLevels = new int[3];
RandomSource rand = RandomSource.create();
for (int bookshelvesNeeded = 0; bookshelvesNeeded <= 15; bookshelvesNeeded++) {
for (int bookshelvesNeeded = Configs.getMinEnchantBookshelves(); bookshelvesNeeded <= Configs.getMaxEnchantBookshelves(); bookshelvesNeeded++) {
rand.setSeed(xpSeed);
for (int slot = 0; slot < 3; slot++) {
int level = EnchantmentHelper.getEnchantmentCost(rand, slot, bookshelvesNeeded, stack);
Expand All @@ -362,7 +362,10 @@ public static String manipulateEnchantments(Item item, Predicate<List<Enchantmen
for (int slot = 0; slot < 3; slot++) {
List<EnchantmentInstance> enchantments = getEnchantmentList(rand, xpSeed, stack, slot,
enchantLevels[slot]);
if (enchantmentsPredicate.test(enchantments)) {
if (enchantmentsPredicate.test(enchantments)
&& enchantLevels[slot] >= Configs.getMinEnchantLevels()
&& enchantLevels[slot] <= Configs.getMaxEnchantLevels()
) {
return new ManipulateResult(times, bookshelvesNeeded, slot, enchantments);
}
}
Expand Down

0 comments on commit c36ec63

Please sign in to comment.