squeek502 / WailaHarvestability

Minecraft mod that adds required harvest level and the effective tool to Waila tooltips of harvestable blocks
The Unlicense
17 stars 21 forks source link

[Feature] Added names instead of numbers for harvestlevels #48

Closed MakerTim closed 8 years ago

MakerTim commented 8 years ago

So, many of my modpack users are requesting this, because i use the mod TAIGA and numbers for harvesting stuff are not that helpful I'm not in any way a forge modder, but looked into your code and made a small add on so it can use multiple mods for multiple harvest levels

I KNOW it's not the best / nicest way of doing this, but it will not break in updates and doesn't need additional API's

So i choose for this way of adding names, all responsibility at this mod side and made this easy addon. It's probably not the final way of handeling this. but at least a temporary fix now

I'm all open for feedback in any way

squeek502 commented 8 years ago

Appreciate the contribution; this is something that existed in previous versions of the mod and should definitely be added back in. However, I would definitely prefer not having the strings hard-coded in this mod, and instead try to get them from the other mods if possible.

For Tinkers' Construct, this could be done using reflection to call HarvestLevels.getHarvestLevelName. Looks like the existing code should work with a slight modification ("tconstruct.library.util.HarvestLevels" changed to "slimeknights.tconstruct.library.utils.HarvestLevels")

Assuming TiC's harvest level implementation is robust and TAIGA uses it in a compatible way, then that might also make it compatible with TAIGA as well.

MakerTim commented 8 years ago

I will look in to that now

squeek502 commented 8 years ago

To be more specific, I think these changes might be all you need:

In TooltipHandler.tooltipEvent, do something like:

int level = ((ItemTool) item).getToolMaterial().getHarvestLevel();
String name = StringHelper.getHarvestLevelName(level);
event.getToolTip().add(I18n.format("wailaharvestability.harvestlevel") + name);

and then change this line of StringHelper to:

HarvestLevels = Class.forName("slimeknights.tconstruct.library.utils.HarvestLevels");
MakerTim commented 8 years ago

Well, you were right ;)

squeek502 commented 8 years ago

Nice, will give more feedback once I get a chance to test it.

squeek502 commented 8 years ago

Thanks! :+1: