-
Notifications
You must be signed in to change notification settings - Fork 118
Enchantments implementation #591
base: master
Are you sure you want to change the base?
Conversation
…ments EnchantmentStorageMeta)
|
Noice. Thanks! Might be a bit too big though. |
c81fbaf to
bea59bb
Compare
|
@dequis Sadly... However, the diff grew due to the new classes, which might be easily to review. |
|
I don't think you need a new class for every enchantment. Please consider a different system. |
|
@turt2live |
|
Sooo that would be this: https://github.com/GlowstoneMC/Glowstone/compare/1a283e6 Which is basically the same but with inline classes, and a diffstat of +954 -51 instead. I guess the functions are needed because that behavior seems arbitrary. |
|
I'd be inclined to accept the system in this diff if the classes actually did something. Currently they act as property containers which is not ideal at all. There are other systems, such as simple variables, that would better suit the excessive duplication and lack of behaviour. |
|
Also, the methods described by @dequis is just as bad. I do not think that enchantments need a large diff in either case... |
|
@turt2live |
|
The methods are currently only needed due to the direction taken to have them there. I honestly do not feel as though the system proposed is adequate to solve the problem at hand. About half of the enchantments use constant values, which makes them easily solvable. The other half use a formula, which is also easily solvable. Both can be solved with a simple mapping and the existing enum. There is no need for 2 methods for every enchantment, you should be able to get by with 2 formulas (although some would be "constant") for every enchantment that can be defined outside of the enum, but be accessed from the enum. |
|
Function bodies with all the crap around them removed: Sounds like all lineal Only ones that don't seem to fit are the ones that do |
|
Actually you're right. |
|
I end up with two "formulas" and a minimzed diff. |
|
After lots of testing and a few hours I came up with a slightly smaller diff with a bit less complexity as well. I haven't tested the pull request though as I'd like you to review my changes that I've PR'd to your branch before I do so. If you have any questions, please ask. |
|
Seems, like you did strange things in your PR: I also think you mixed up values for Smite and Bane of Arthropods, I think I fixed them, not sure either. So, after some investigation into getMaxRange there are some differences:
So it seems, that you cannot re-use getMinRange everytime. |
|
I did screw up the ordering, and I've fixed that now. As for the formula, I use the modified enchanting levels table as described in the enchanting mechanics. The output table from Glowstone is this with the test program output being this. They both match each other and the wiki article. The test code used was this added to the main method of Glowstone with the workaround of fields and classes being made public where required (this would be the GlowEnchantment class after those modifications). I looked at the code flow and the modified enchantment level is passed down through the methods, meaning that the formulas I use are correct in being used. |
…ments EnchantmentStorageMeta)
This reverts commit c90727a.
|
Well, I can only guess that the wiki page is outdated (source is mc 1.4.6 allegedly) or simply false. See f.e. the values for level 1 for Knockback: 5 - 55. The used formula
Now compare to mc-source (see https://github.com/Bukkit/mc-dev/blob/master/net/minecraft/server/EnchantmentKnockback.java) -min: ==> false, because super.a(int) refers to 1 + i * 10 (see Enchantment.java), I don't know whether this deviation might be appreciably (open for suggestions), however it's not 100% correct. |
|
@turt2live After a long respite I merged your PR and added a parameter simpleRange to cover the different maxRange options. The behaviour should be identical with vanilla now. |
|
Thanks @Tonodus. I've been meaning to test whether or not that pull request was/is valid but haven't had a chance to actually pull the values from vanilla yet. I'll do that as soon as I can. |
|
@turt2live |
#591 Conflicts: src/main/java/net/glowstone/inventory/GlowEnchantingInventory.java
Spigot's update of Bukkit added getSecondary() to EnchantingInventory: GlowstonePlusPlus/Glowkit-Legacy@277baff Update to Minecraft 1.8 whereas Glowkit called it getResource(): GlowstoneMC/Glowkit@f6ee29b Updated Enchanting inventory to include new slot. update the calls from getResource() to getSecondary() for the merge of: #591 Enchantments implementation
This adds basic enchantment functionality.
This PR includes:
This PR does NOT include:
https://github.com/GlowstoneMC/Glowkit/pull/63