Allow CT to remove marx recipes
This commit is contained in:
parent
bc1ebc9fa5
commit
685a9058f6
|
@ -131,6 +131,7 @@ public class IndustrialWires {
|
|||
|
||||
proxy.preInit();
|
||||
Compat.preInit();
|
||||
MarxOreHandler.preInit();
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
|
@ -157,7 +158,6 @@ public class IndustrialWires {
|
|||
|
||||
@EventHandler
|
||||
public void init(FMLInitializationEvent e) {
|
||||
MarxOreHandler.init();
|
||||
|
||||
packetHandler.registerMessage(MessageTileSyncIW.HandlerClient.class, MessageTileSyncIW.class, 0, Side.CLIENT);
|
||||
packetHandler.registerMessage(MessagePanelInteract.HandlerServer.class, MessagePanelInteract.class, 1, Side.SERVER);
|
||||
|
|
|
@ -16,6 +16,8 @@ import stanhebben.zenscript.annotations.Optional;
|
|||
import stanhebben.zenscript.annotations.ZenClass;
|
||||
import stanhebben.zenscript.annotations.ZenMethod;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@ZenClass("mods.industrialwires.MarxGenerator")
|
||||
|
@ -50,6 +52,7 @@ public class CTMarxGenerator {
|
|||
@Override
|
||||
public void apply() {
|
||||
MarxOreHandler.put(recipe);
|
||||
Compat.addMarx.accept(recipe);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,4 +60,53 @@ public class CTMarxGenerator {
|
|||
return "Adding Marx Generator Recipe for "+ recipe.output.get();
|
||||
}
|
||||
}
|
||||
@ZenMethod
|
||||
public static void removeRecipe(IIngredient input) {
|
||||
if (input instanceof IItemStack) {
|
||||
CraftTweakerAPI.apply(new Remove((o)-> input.matches(CraftTweakerMC.getIItemStack(o))));
|
||||
return;
|
||||
} else if (input instanceof IOreDictEntry) {
|
||||
String oreName = ((IOreDictEntry) input).getName();
|
||||
int mainId = OreDictionary.getOreID(oreName);
|
||||
CraftTweakerAPI.apply(new Remove((i)->{
|
||||
int[] ids = OreDictionary.getOreIDs(i);
|
||||
for (int id:ids) {
|
||||
if (id==mainId) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
return;
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid parameter "+input);
|
||||
}
|
||||
|
||||
private static class Remove implements IAction {
|
||||
private final Predicate<ItemStack> inputMatcher;
|
||||
|
||||
public Remove(Predicate<ItemStack> inputMatcher) {
|
||||
this.inputMatcher = inputMatcher;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply() {
|
||||
Iterator<MarxOreHandler.OreInfo> ores = MarxOreHandler.getRecipes().iterator();
|
||||
while (ores.hasNext()) {
|
||||
MarxOreHandler.OreInfo curr = ores.next();
|
||||
for (ItemStack input:curr.exampleInput) {
|
||||
if (inputMatcher.test(input)) {
|
||||
ores.remove();
|
||||
Compat.removeMarx.accept(curr);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String describe() {
|
||||
return "Removing Marx Generator Recipes";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,14 +5,18 @@ import blusunrize.immersiveengineering.api.tool.ToolboxHandler;
|
|||
import crafttweaker.CraftTweakerAPI;
|
||||
import ic2.api.item.IBoxable;
|
||||
import ic2.api.item.IC2Items;
|
||||
import malte0811.industrialWires.hv.MarxOreHandler;
|
||||
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;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class Compat {
|
||||
public static Consumer<MarxOreHandler.OreInfo> addMarx = (o)->{};
|
||||
public static Consumer<MarxOreHandler.OreInfo> removeMarx = (o)->{};
|
||||
|
||||
public static void preInit() {
|
||||
callAllForClass(PreInit.class);
|
||||
|
|
|
@ -54,6 +54,8 @@ public class JEIMarx implements IModPlugin {
|
|||
|
||||
@Override
|
||||
public void onRuntimeAvailable(IJeiRuntime jeiRuntime) {
|
||||
Compat.addMarx = (o) -> jeiRuntime.getRecipeRegistry().addRecipe(new MarxRecipeWrapper(o), marx.getUid());
|
||||
Compat.removeMarx = (o) -> jeiRuntime.getRecipeRegistry().removeRecipe(new MarxRecipeWrapper(o), marx.getUid());
|
||||
}
|
||||
|
||||
private class MarxCategory implements IRecipeCategory<MarxRecipeWrapper> {
|
||||
|
@ -122,10 +124,8 @@ public class JEIMarx implements IModPlugin {
|
|||
slot.draw(minecraft, 62, 4);
|
||||
if (recipe.outputSmall!=null&&!recipe.outputSmall.get().isEmpty()) {
|
||||
slot.draw(minecraft, 62, 29);
|
||||
//TODO Localization
|
||||
minecraft.fontRenderer.drawString("x"+ recipe.smallMax+I18n.format(IndustrialWires.MODID+".desc.jei.alt"), 85, 33, 0xff000000);
|
||||
}
|
||||
//TODO Localization
|
||||
minecraft.fontRenderer.drawString("x"+ Utils.formatDouble(recipe.maxYield, "0.#") + I18n.format(IndustrialWires.MODID+".desc.jei.max"), 85, 8, 0xff000000);
|
||||
minecraft.fontRenderer.drawString("~", 0, 3, 0xff000000);
|
||||
minecraft.fontRenderer.drawString((int) (recipe.avgEnergy*MarxOreHandler.defaultEnergy/1000)+" kJ",
|
||||
|
|
|
@ -47,7 +47,7 @@ public class MarxOreHandler {
|
|||
public static double defaultEnergy = 100_000;
|
||||
public static double modifier;
|
||||
|
||||
public static void init() {
|
||||
public static void preInit() {
|
||||
// Vanilla ores
|
||||
putOre("oreIron", .5, 4, "dustIron", "nuggetIron");
|
||||
putOre("oreGold", 1, 4, "dustGold", "nuggetGold");
|
||||
|
|
Loading…
Reference in a new issue