fix: fixed efficiency being split between heads when double headed tools are converted
@@ -2,6 +2,7 @@ package se.mickelus.tetra.module;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
+import net.minecraft.enchantment.Enchantments;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import org.apache.logging.log4j.LogManager;
@@ -78,6 +79,17 @@ public class ItemUpgradeRegistry {
.filter(module -> module.acceptsImprovement(mapping.improvement))
.toArray(ItemModuleMajor[]::new);
if (modules.length > 0) {
+
+ // since efficiency doesn't stack on double headed items it should be fully applied to a single module instead of being split
+ if (Enchantments.EFFICIENCY.equals(entry.getKey())) {
+ float level = 1f * entry.getValue() / mapping.multiplier;
+ for (ItemModuleMajor module : modules) {
+ if (module.acceptsImprovementLevel(mapping.improvement, (int) level)) {
+ module.addImprovement(modularStack, mapping.improvement, (int) level);
+ break;
+ }
+ }
+ } else {
float level = 1f * entry.getValue() / modules.length / mapping.multiplier;
for (int i = 0; i < modules.length; i++) {
@@ -91,6 +103,8 @@ public class ItemUpgradeRegistry {
}
}
}
+
+ }
}
}
}
