wip. auto-crafting still broken

This commit is contained in:
PrototypeTrousers
2023-01-07 18:25:31 -03:00
parent dde87448a9
commit 653557bc65
2 changed files with 9 additions and 4 deletions
@@ -9,10 +9,14 @@ import java.lang.reflect.Method;
public class ToolClass {
private static Class<?> GTToolClass;
private static Method getMaxItemDamage = null;
private static Method getItemDamage = null;
static {
try {
GTToolClass = Class.forName("gregtech.api.items.IToolItem", false, Launch.classLoader);
getItemDamage = ReflectionHelper.findMethod(GTToolClass, "getItemDamage", null, ItemStack.class);
getMaxItemDamage = ReflectionHelper.findMethod(GTToolClass, "getMaxItemDamage", null, ItemStack.class);
} catch (ClassNotFoundException ignored) {
try {
GTToolClass = Class.forName("gregtech.api.items.toolitem.IGTTool", false, Launch.classLoader);
@@ -23,10 +27,11 @@ public class ToolClass {
}
private static final Enum<Interfaces> GTToolInterface = getGTToolInterface();
private static final Method getMaxItemDamage = ReflectionHelper.findMethod(GTToolClass, "getMaxItemDamage", null, ItemStack.class);
private static final Method getItemDamage = ReflectionHelper.findMethod(GTToolClass, "getItemDamage", null, ItemStack.class);
public static Class<?> getGTToolClass() {
if (GTToolClass == null) {
System.out.printf("TToolClass == null");
}
return GTToolClass;
}
@@ -58,7 +63,7 @@ public class ToolClass {
throw new RuntimeException(e);
}
} else {
return itemStack.getMaxDamage();
return itemStack.getItemDamage();
}
}
+1 -1
View File
@@ -1416,7 +1416,7 @@ public class Platform {
//consider methods below moving to a compability class
public static boolean isGTDamageableItem(Item item) {
return ((GTLoaded) && item.getClass().isInstance(ToolClass.getGTToolClass()));
return ((GTLoaded) && ToolClass.getGTToolClass().isAssignableFrom(item.getClass()));
}
public static MetaTileEntity getMetaTileEntity(IBlockAccess world, BlockPos pos) {