Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TradeOffers.SellEnchantedToolFactory toolFactory;
- try {
- toolFactory = (TradeOffers.SellEnchantedToolFactory) tradeFactory;
- } catch(ClassCastException e) {
- LOGGER.error("Enchanted ToolItem or ArmorItem does not have a SellEnchantedToolFactory! ");
- return 0;
- }
- int lvl = MAX_TOOL_ENCHANT_LVL;
- int i = enchantedItem.getEnchantability();
- if (i <= 0) return 0;
- lvl += 1 + 2 * (i / 4 + 1);
- float f = 0.15F;
- lvl = Math.max(1, Math.round((float) lvl + (float) lvl * f));
- int numPossibleEnchants = intLog(lvl, 2);
- List<EnchantmentLevelEntry> possibleEntriesList = EnchantmentHelper.getPossibleEntries(lvl, enchantedStack, false);
- Set<EnchantmentLevelEntry> possibleEntriesSet = new HashSet<>(possibleEntriesList);
- if (lvl > MAX_TOOL_ENCHANT_LVL) {
- return 0;
- }
- for (Map.Entry<Enchantment, Integer> entry : enchantments) {
- Enchantment enchantment = entry.getKey();
- int actualLevel = entry.getValue();
- if (enchantment.isTreasure())
- return 0;
- if (!possibleEntriesSet.contains(new EnchantmentLevelEntry(entry.getKey(), entry.getValue())))
- return 0;
- return 0;
- }
- int price = Math.min(toolFactory.basePrice + INDETERMINATE, 64);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement