2017-08-27 22:45:52 +02:00
|
|
|
package malte0811.industrialWires.compat;
|
|
|
|
|
|
|
|
import blusunrize.immersiveengineering.api.ApiUtils;
|
|
|
|
import blusunrize.immersiveengineering.api.tool.ToolboxHandler;
|
|
|
|
import crafttweaker.CraftTweakerAPI;
|
|
|
|
import ic2.api.item.IBoxable;
|
|
|
|
import ic2.api.item.IC2Items;
|
2017-08-29 22:01:51 +02:00
|
|
|
import malte0811.industrialWires.hv.MarxOreHandler;
|
2017-08-27 22:45:52 +02:00
|
|
|
import net.minecraft.item.Item;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraftforge.fml.common.Optional;
|
|
|
|
|
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import java.lang.reflect.Method;
|
2017-08-29 22:01:51 +02:00
|
|
|
import java.util.function.Consumer;
|
2017-08-27 22:45:52 +02:00
|
|
|
|
|
|
|
public class Compat {
|
2017-08-29 22:01:51 +02:00
|
|
|
public static Consumer<MarxOreHandler.OreInfo> addMarx = (o)->{};
|
|
|
|
public static Consumer<MarxOreHandler.OreInfo> removeMarx = (o)->{};
|
2017-08-27 22:45:52 +02:00
|
|
|
|
|
|
|
public static void preInit() {
|
2017-08-29 21:31:22 +02:00
|
|
|
callAllForClass(PreInit.class);
|
|
|
|
}
|
|
|
|
public static void init() {
|
|
|
|
callAllForClass(Init.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void callAllForClass(Class c) {
|
|
|
|
Method[] methods = c.getDeclaredMethods();
|
2017-08-27 22:45:52 +02:00
|
|
|
for (Method m : methods) {
|
2017-08-29 21:31:22 +02:00
|
|
|
if (m.getReturnType() == void.class && m.getParameterCount() == 0) {
|
2017-08-27 22:45:52 +02:00
|
|
|
try {
|
2017-08-29 21:31:22 +02:00
|
|
|
m.setAccessible(true);
|
|
|
|
m.invoke(null);
|
2017-08-27 22:45:52 +02:00
|
|
|
} catch (IllegalAccessException | InvocationTargetException e) {
|
|
|
|
e.printStackTrace();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-08-29 21:31:22 +02:00
|
|
|
private static class PreInit {
|
|
|
|
@Optional.Method(modid = "crafttweaker")
|
|
|
|
private static void preInitCraftTweaker() {
|
|
|
|
CraftTweakerAPI.registerClass(CTMarxGenerator.class);
|
|
|
|
}
|
2017-08-27 22:45:52 +02:00
|
|
|
}
|
|
|
|
|
2017-08-29 21:31:22 +02:00
|
|
|
private static class Init {
|
|
|
|
@Optional.Method(modid = "ic2")
|
|
|
|
private static void initIC2() {
|
|
|
|
Item tinnedFood = IC2Items.getItem("filled_tin_can").getItem();
|
|
|
|
ItemStack emptyMug = IC2Items.getItem("mug", "empty");
|
|
|
|
ToolboxHandler.addFoodType((s) -> s.getItem() == tinnedFood);
|
|
|
|
ToolboxHandler.addFoodType((s) ->
|
|
|
|
s.getItem() == emptyMug.getItem() && !ItemStack.areItemStacksEqual(emptyMug, ApiUtils.copyStackWithAmount(s, 1))
|
|
|
|
);
|
|
|
|
Item cable = IC2Items.getItem("cable", "type:copper,insulation:0").getItem();
|
|
|
|
ToolboxHandler.addWiringType((s, w) -> s.getItem() == cable);
|
|
|
|
ToolboxHandler.addToolType((s) -> {
|
|
|
|
Item a = s.getItem();
|
|
|
|
return a instanceof IBoxable && ((IBoxable) a).canBeStoredInToolbox(s);
|
|
|
|
});
|
|
|
|
}
|
2017-08-27 22:45:52 +02:00
|
|
|
}
|
2017-08-29 21:31:22 +02:00
|
|
|
}
|