Slimefun / Slimefun4

Slimefun 4 - A unique Spigot/Paper plugin that looks and feels like a modpack. We've been giving you backpacks, jetpacks, reactors and much more since 2013.
GNU General Public License v3.0
973 stars 545 forks source link

Fortune V pickaxe #380

Closed claer closed 7 years ago

claer commented 7 years ago

Description

Describe your Issue: One of our user tried to get a Fortune V enchanted pickaxe as advertised by Wizard talisman . For this she enchanted A LOT of them (around 400). Because she couldn't get any, I tried to understand the issue with my poor programming skills.

Server Log

n/a

Evidence / Proof

grepping source code for fortune, leads me here: src/me/mrCookieSlime/Slimefun/Lists/SlimefunItems.java: public static ItemStack TALISMAN_WIZARD = new CustomItem(Material.EMERALD, "&aTalisman of the Wizard", 0, new String[] {"", "&rWhile you have this Talisman", "&rin your Inventory it allows you to", "&robtain Fortune Level 4/5 however", "&rit also has a chance to lower the", "&rLevel of some Enchantments on your Item"}); Following the TALISMAN_WIZARD leads in the following block from "src/me/mrCookieSlime/Slimefun/listeners/TalismanListener.java":

 94                 if (!e.getEnchantsToAdd().containsKey(Enchantment.SILK_TOUCH) && Enchantment.LOOT_BONUS_BLOCKS.canEnchantItem(e.getItem())) {
 95                         if (Talisman.checkFor(e, SlimefunItem.getByName("WIZARD_TALISMAN"))) {
 96                                 if (e.getEnchantsToAdd().containsKey(Enchantment.LOOT_BONUS_BLOCKS)) e.getEnchantsToAdd().remove(Enchantment.LOOT_BONUS_BLOCKS);
 97                                 Set<Enchantment> enchantments = e.getEnchantsToAdd().keySet();
 98                                 for (Enchantment en: enchantments) {
 99                                         if (SlimefunStartup.chance(100, 40)) e.getEnchantsToAdd().put(en, SlimefunStartup.randomize(2) + 1);
100                                 }
101
102                                 e.getItem().addUnsafeEnchantment(Enchantment.LOOT_BONUS_BLOCKS, SlimefunStartup.randomize(2) + 3);
103                         }
104                 }

If I understood well, the interesting part is line 102. It defines the loot level to randomize(2) + 3. randomize appears to be only a wrapper to Random. Random returns an integer between 0 inclusive and int exclusive. Therefore, the max enchant level we can get is 4.

Is it possible to change either the description of the wizard talisman or the code to randomize(3)?

Environment

Code extracted from github repository as of today. On our server, we run: CraftBukkit v1_12_R1 CS-CoreLib v1.5.16 Slimefun v4.1.9

Installed Addons ExoticGarden v1.6.3 SlimefunOres v1.4.6

TheBusyBiscuit commented 7 years ago

Go ahead and make the change to the code.