wip. auto-crafting still broken
This commit is contained in:
@@ -9,10 +9,14 @@ import java.lang.reflect.Method;
|
|||||||
|
|
||||||
public class ToolClass {
|
public class ToolClass {
|
||||||
private static Class<?> GTToolClass;
|
private static Class<?> GTToolClass;
|
||||||
|
private static Method getMaxItemDamage = null;
|
||||||
|
private static Method getItemDamage = null;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
GTToolClass = Class.forName("gregtech.api.items.IToolItem", false, Launch.classLoader);
|
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) {
|
} catch (ClassNotFoundException ignored) {
|
||||||
try {
|
try {
|
||||||
GTToolClass = Class.forName("gregtech.api.items.toolitem.IGTTool", false, Launch.classLoader);
|
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 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() {
|
public static Class<?> getGTToolClass() {
|
||||||
|
if (GTToolClass == null) {
|
||||||
|
System.out.printf("TToolClass == null");
|
||||||
|
}
|
||||||
return GTToolClass;
|
return GTToolClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +63,7 @@ public class ToolClass {
|
|||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return itemStack.getMaxDamage();
|
return itemStack.getItemDamage();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1416,7 +1416,7 @@ public class Platform {
|
|||||||
|
|
||||||
//consider methods below moving to a compability class
|
//consider methods below moving to a compability class
|
||||||
public static boolean isGTDamageableItem(Item item) {
|
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) {
|
public static MetaTileEntity getMetaTileEntity(IBlockAccess world, BlockPos pos) {
|
||||||
|
|||||||
Reference in New Issue
Block a user