mirror of
https://github.com/GTNewHorizons/WailaHarvestability.git
synced 2026-11-25 06:14:34 +00:00
Updated to the newer methods to get ability/harvest level names
* Should be backwards compatible * Fixes #20
This commit is contained in:
1 parent
49fd19f743
commit
5ef85912e9
2 files changed
+38
-23
No files matched your search
@@ -1,5 +1,6 @@
|
||||
package squeek.wailaharvestability.helpers;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import squeek.wailaharvestability.ModWailaHarvestability;
|
||||
@@ -10,20 +11,44 @@ import net.minecraft.util.StatCollector;
|
||||
public class StringHelper
|
||||
{
|
||||
|
||||
//private static DecimalFormat df = new DecimalFormat("##.##");
|
||||
public static Class<?> HarvestLevels = null;
|
||||
public static Method getHarvestLevelName = null;
|
||||
static
|
||||
{
|
||||
try
|
||||
{
|
||||
HarvestLevels = Class.forName("tconstruct.library.util.HarvestLevels");
|
||||
getHarvestLevelName = HarvestLevels.getDeclaredMethod("getHarvestLevelName", int.class);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
// Taken from tconstruct.client.gui.ToolStationGui
|
||||
public static String getHarvestLevelName(int num)
|
||||
{
|
||||
if (ModWailaHarvestability.hasIguanaTweaks)
|
||||
return ProxyIguanaTweaks.getHarvestLevelName(num);
|
||||
|
||||
String unlocalized = "gui.partcrafter.mining" + (num + 1);
|
||||
String localized = StringHelper.getLocalizedString(unlocalized);
|
||||
if (!unlocalized.equals(localized))
|
||||
return localized;
|
||||
if (getHarvestLevelName != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
return (String) getHarvestLevelName.invoke(null, num);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
return String.valueOf(num);
|
||||
{
|
||||
if (ModWailaHarvestability.hasIguanaTweaks)
|
||||
return ProxyIguanaTweaks.getHarvestLevelName(num);
|
||||
|
||||
String unlocalized = "gui.partcrafter.mining" + (num + 1);
|
||||
String localized = StringHelper.getLocalizedString(unlocalized);
|
||||
if (!unlocalized.equals(localized))
|
||||
return localized;
|
||||
}
|
||||
return String.valueOf(num);
|
||||
}
|
||||
|
||||
// for TCon version < 1.5.3
|
||||
|
||||
@@ -1,23 +1,18 @@
|
||||
package squeek.wailaharvestability.proxy;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import net.minecraft.block.Block;
|
||||
|
||||
public class ProxyIguanaTweaks
|
||||
{
|
||||
private static Class<?> IguanaTweaksTConstruct = null;
|
||||
private static Class<?> HarvestLevels = null;
|
||||
private static Method proxyGetHarvestLevelName;
|
||||
private static Block oreGravel = null;
|
||||
|
||||
public static void init()
|
||||
{
|
||||
try
|
||||
{
|
||||
IguanaTweaksTConstruct = Class.forName("iguanaman.iguanatweakstconstruct.IguanaTweaksTConstruct");
|
||||
proxyGetHarvestLevelName = IguanaTweaksTConstruct.getDeclaredMethod("getHarvestLevelName", int.class);
|
||||
|
||||
Class<?> TContent = Class.forName("tconstruct.common.TContent");
|
||||
oreGravel = (Block) TContent.getDeclaredField("oreGravel").get(null);
|
||||
HarvestLevels = Class.forName("iguanaman.iguanatweakstconstruct.util.HarvestLevels");
|
||||
proxyGetHarvestLevelName = HarvestLevels.getDeclaredMethod("getHarvestLevelName", int.class);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -31,7 +26,7 @@ public class ProxyIguanaTweaks
|
||||
|
||||
try
|
||||
{
|
||||
harvestLevelName = (String) proxyGetHarvestLevelName.invoke(IguanaTweaksTConstruct, num);
|
||||
harvestLevelName = (String) proxyGetHarvestLevelName.invoke(null, num);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -40,9 +35,4 @@ public class ProxyIguanaTweaks
|
||||
|
||||
return harvestLevelName;
|
||||
}
|
||||
|
||||
public static boolean isGravelOre(Block block)
|
||||
{
|
||||
return oreGravel != null && Block.isEqualTo(oreGravel, block);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user