Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<EnchantmentLevelEntry> generateEnchantments(Random random, ItemStack stack, int level, boolean treasureAllowed) {
- List<EnchantmentLevelEntry> list = Lists.newArrayList();
- Item item = stack.getItem();
- int i = item.getEnchantability();
- if (i <= 0) {
- return list;
- } else {
- level += 1 + random.nextInt(i / 4 + 1) + random.nextInt(i / 4 + 1);
- float f = (random.nextFloat() + random.nextFloat() - 1.0F) * 0.15F;
- level = MathHelper.clamp(Math.round((float)level + (float)level * f), 1, Integer.MAX_VALUE);
- List<EnchantmentLevelEntry> list2 = getPossibleEntries(level, stack, treasureAllowed);
- if (!list2.isEmpty()) {
- list.add(WeightedPicker.getRandom(random, list2));
- while(random.nextInt(50) <= level) {
- removeConflicts(list2, (EnchantmentLevelEntry)Util.getLast(list));
- if (list2.isEmpty()) {
- break;
- }
- list.add(WeightedPicker.getRandom(random, list2));
- level /= 2;
- }
- }
- return list;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement