mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-21 02:17:42 +01:00
Add configuration option to replace incompatible enchantments (#1419)
This commit is contained in:
@@ -27,7 +27,7 @@ index 664cbce2e06fcb95d3d3d6c5302fc9119f938925..bc9778c705d23acd84fa1cdeff6b403b
|
||||
++i;
|
||||
} else if (targets.size() == 1) {
|
||||
diff --git a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
index 8a7c30e316db4960b0b62ca0e366c19febead214..29ba769c5f803ce2dc5285e65284febf9ee28eb2 100644
|
||||
index 8a7c30e316db4960b0b62ca0e366c19febead214..fdf2bf10a533c3d4ee145880e6949dadf6ce5410 100644
|
||||
--- a/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
+++ b/src/main/java/net/minecraft/world/inventory/AnvilMenu.java
|
||||
@@ -228,7 +228,8 @@ public class AnvilMenu extends ItemCombinerMenu {
|
||||
@@ -40,12 +40,16 @@ index 8a7c30e316db4960b0b62ca0e366c19febead214..29ba769c5f803ce2dc5285e65284febf
|
||||
|
||||
if (this.player.getAbilities().instabuild || itemstack.is(Items.ENCHANTED_BOOK)) {
|
||||
flag3 = true;
|
||||
@@ -240,16 +241,16 @@ public class AnvilMenu extends ItemCombinerMenu {
|
||||
@@ -240,16 +241,20 @@ public class AnvilMenu extends ItemCombinerMenu {
|
||||
Enchantment enchantment1 = (Enchantment) iterator1.next();
|
||||
|
||||
if (enchantment1 != enchantment && !enchantment.isCompatibleWith(enchantment1)) {
|
||||
- flag3 = canDoUnsafeEnchants; // Purpur
|
||||
+ flag4 = canDoUnsafeEnchants || (org.purpurmc.purpur.PurpurConfig.allowUnsafeEnchants && org.purpurmc.purpur.PurpurConfig.allowIncompatibleEnchants); // Purpur flag3 -> flag4
|
||||
+ if (!flag4 && org.purpurmc.purpur.PurpurConfig.replaceIncompatibleEnchants) {
|
||||
+ iterator1.remove();
|
||||
+ flag4 = true;
|
||||
+ }
|
||||
++i;
|
||||
}
|
||||
}
|
||||
@@ -60,7 +64,7 @@ index 8a7c30e316db4960b0b62ca0e366c19febead214..29ba769c5f803ce2dc5285e65284febf
|
||||
i2 = enchantment.getMaxLevel();
|
||||
}
|
||||
|
||||
@@ -389,7 +390,7 @@ public class AnvilMenu extends ItemCombinerMenu {
|
||||
@@ -389,7 +394,7 @@ public class AnvilMenu extends ItemCombinerMenu {
|
||||
sendAllDataToRemote(); // CraftBukkit - SPIGOT-6686: Always send completed inventory to stay in sync with client
|
||||
this.broadcastChanges();
|
||||
// Purpur start
|
||||
@@ -87,10 +91,10 @@ index 33548cd10758f3cc891c40d760b9e0a86dc8a2cb..a7909c60a17ab004ab8f6cd39abb2118
|
||||
this.getOrCreateTag().put(key, element);
|
||||
}
|
||||
diff --git a/src/main/java/org/purpurmc/purpur/PurpurConfig.java b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
index 55963ed03a2e552636035b498cf7441bd4c3ee59..0ebd43cf4163e2f3b06d1f6475421c03e08a1bd5 100644
|
||||
index 55963ed03a2e552636035b498cf7441bd4c3ee59..5697ce5ead8dc7e463206a56d489c99c861a9bb1 100644
|
||||
--- a/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
+++ b/src/main/java/org/purpurmc/purpur/PurpurConfig.java
|
||||
@@ -285,14 +285,32 @@ public class PurpurConfig {
|
||||
@@ -285,14 +285,34 @@ public class PurpurConfig {
|
||||
|
||||
public static boolean allowInfinityMending = false;
|
||||
public static boolean allowCrossbowInfinity = false;
|
||||
@@ -99,6 +103,7 @@ index 55963ed03a2e552636035b498cf7441bd4c3ee59..0ebd43cf4163e2f3b06d1f6475421c03
|
||||
+ public static boolean allowIncompatibleEnchants = true;
|
||||
+ public static boolean allowHigherEnchantsLevels = true;
|
||||
+ public static boolean allowUnsafeEnchantCommand = false;
|
||||
+ public static boolean replaceIncompatibleEnchants = false;
|
||||
private static void enchantmentSettings() {
|
||||
if (version < 5) {
|
||||
boolean oldValue = getBoolean("settings.enchantment.allow-infinite-and-mending-together", false);
|
||||
@@ -120,6 +125,7 @@ index 55963ed03a2e552636035b498cf7441bd4c3ee59..0ebd43cf4163e2f3b06d1f6475421c03
|
||||
+ allowIncompatibleEnchants = getBoolean("settings.enchantment.anvil.allow-incompatible-enchants", allowIncompatibleEnchants);
|
||||
+ allowHigherEnchantsLevels = getBoolean("settings.enchantment.anvil.allow-higher-enchants-levels", allowHigherEnchantsLevels);
|
||||
+ allowUnsafeEnchantCommand = getBoolean("settings.enchantment.allow-unsafe-enchant-command", allowUnsafeEnchants); // allowUnsafeEnchants as default for backwards compatability
|
||||
+ replaceIncompatibleEnchants = getBoolean("settings.enchantment.anvil.replace-incompatible-enchants", replaceIncompatibleEnchants);
|
||||
}
|
||||
|
||||
public static boolean endermanShortHeight = false;
|
||||
|
||||
Reference in New Issue
Block a user