New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ItemAxe subclasses are impossible. #2646
Comments
the proper fix as told to me is to extend ItemTool directly and set the tool class to axe |
The problem with this approach is that you can't set the toolClass field, meaning you have to implement both getHarvestLevel and getToolClasses. Maybe the toolClass field could be protected in stead of private. |
Yes, there are further problems with being unable to do this, reopening.
|
I may PR a fix for this shortly |
|
it is checked in over 4 separate places |
I'd rather just patch this one ctor than in 4 other places, but I get patching the check as well |
3 places, one of the 4 is the ItemTool constructor, which doesn't count. And even if you patch the constructor here, you still have to patch the 3 other places, because forge's axe tool-class should behave like actual axes, otherwise it's pointless to have the tool class. |
yea I'll probably patch the instanceof checks into tool classes then |
I'm not sure why mojang special cased these particular values. Ya.. I think that'd be best. Add a Enum with a getOrCreate {similar to what we have for Biome type in the BiomeDictionary} And switch all the places where we use String toolType to Enum. So two options: New constructor to bypass the array herpa |
As discussed in MinecraftForge#2646, this is the easiest way to bypass the hardcoded arrays I wasn't confident enough to go through and completely replace said arrays, so I'll provide this for now. One day I'll come back and bypass the arrays completely (unless someone else beats me to it)
In the
ItemAxe
constructor, the attack damage+speed are looked up in a hardcoded array indexed by the input material ordinal. Which means any EnumHelper added materials will immediately crash the game with AIOOBE since their indices are larger than the array -.-Easy fix would be to just set them to 0 if the range is greater than the ordinal for diamond (or whichever vanilla one is last) and let the mod set it in their ctor
The text was updated successfully, but these errors were encountered: