From d57edae3a55131600090a3aee00c85c4b94621ad Mon Sep 17 00:00:00 2001 From: miozune Date: Sat, 7 Sep 2024 12:49:42 +0900 Subject: Followup for the great renaming & cleanup IMC for NEI (#3083) Co-authored-by: Martin Robertz Co-authored-by: boubou19 --- src/main/java/gregtech/common/GTClient.java | 2 +- src/main/java/gtneioreplugin/GTNEIOrePlugin.java | 5 ++- src/main/java/gtneioreplugin/plugin/IMCForNEI.java | 52 ---------------------- .../gtneioreplugin/plugin/NEIPluginConfig.java | 44 ++++++++++++++++++ src/main/java/kubatech/ClientProxy.java | 2 - src/main/java/kubatech/nei/IMCForNEI.java | 46 ------------------- src/main/java/kubatech/nei/NEIConfig.java | 6 +++ 7 files changed, 54 insertions(+), 103 deletions(-) delete mode 100644 src/main/java/gtneioreplugin/plugin/IMCForNEI.java delete mode 100644 src/main/java/kubatech/nei/IMCForNEI.java (limited to 'src/main') diff --git a/src/main/java/gregtech/common/GTClient.java b/src/main/java/gregtech/common/GTClient.java index eafd72b7ac..127c801b40 100644 --- a/src/main/java/gregtech/common/GTClient.java +++ b/src/main/java/gregtech/common/GTClient.java @@ -775,7 +775,7 @@ public class GTClient extends GTProxy implements Runnable { @SubscribeEvent public void onConfigChange(ConfigChangedEvent.OnConfigChangedEvent e) { - if (GregTech.ID.equals(e.modID) && "kekztech/client".equals(e.configID)) { + if (GregTech.ID.equals(e.modID) && "client".equals(e.configID)) { // refresh client preference and send to server, since it's the only config we allow changing at runtime. mPreference = new GTClientPreference(); GTPreLoad.loadClientConfig(); diff --git a/src/main/java/gtneioreplugin/GTNEIOrePlugin.java b/src/main/java/gtneioreplugin/GTNEIOrePlugin.java index 6a168a8070..5c970fd032 100644 --- a/src/main/java/gtneioreplugin/GTNEIOrePlugin.java +++ b/src/main/java/gtneioreplugin/GTNEIOrePlugin.java @@ -4,6 +4,7 @@ import java.io.File; import net.minecraft.creativetab.CreativeTabs; import net.minecraft.item.Item; +import net.minecraftforge.common.MinecraftForge; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -19,7 +20,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.relauncher.Side; import gregtech.GT_Version; -import gtneioreplugin.plugin.IMCForNEI; +import gtneioreplugin.plugin.NEIPluginConfig; import gtneioreplugin.plugin.block.ModBlocks; import gtneioreplugin.util.CSVMaker; import gtneioreplugin.util.GT5OreLayerHelper; @@ -67,7 +68,7 @@ public class GTNEIOrePlugin { @EventHandler public void init(FMLInitializationEvent event) { ModBlocks.init(); - IMCForNEI.IMCSender(); + MinecraftForge.EVENT_BUS.register(new NEIPluginConfig()); } @EventHandler diff --git a/src/main/java/gtneioreplugin/plugin/IMCForNEI.java b/src/main/java/gtneioreplugin/plugin/IMCForNEI.java deleted file mode 100644 index 620140c630..0000000000 --- a/src/main/java/gtneioreplugin/plugin/IMCForNEI.java +++ /dev/null @@ -1,52 +0,0 @@ -package gtneioreplugin.plugin; - -import net.minecraft.nbt.NBTTagCompound; - -import cpw.mods.fml.common.event.FMLInterModComms; -import gtneioreplugin.GTNEIOrePlugin; - -public class IMCForNEI { - - public static void IMCSender() { - // Though these 2 are already registered in NEI jar, we need to re-register - // because new DimensionDisplayItems made tabs a bit taller. - sendHandler("gregtech5.plugin.gtneioreplugin.PluginGT5VeinStat", "gregtech:gt.blockores:386"); - - sendHandler("gregtech5.plugin.gtneioreplugin.PluginGT5SmallOreStat", "gregtech:gt.blockores:85"); - - sendHandler("gregtech5.plugin.gtneioreplugin.PluginGT5UndergroundFluid", "gregtech:gt.metaitem.01:32619"); - sendCatalyst("gregtech5.plugin.gtneioreplugin.PluginGT5UndergroundFluid", "gregtech:gt.blockmachines:1157"); - sendCatalyst("gregtech5.plugin.gtneioreplugin.PluginGT5UndergroundFluid", "gregtech:gt.blockmachines:141"); - sendCatalyst("gregtech5.plugin.gtneioreplugin.PluginGT5UndergroundFluid", "gregtech:gt.blockmachines:142"); - sendCatalyst("gregtech5.plugin.gtneioreplugin.PluginGT5UndergroundFluid", "gregtech:gt.blockmachines:149"); - sendCatalyst("gregtech5.plugin.gtneioreplugin.PluginGT5UndergroundFluid", "gregtech:gt.blockmachines:148"); - } - - private static void sendHandler(String name, String itemStack) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handler", name); - aNBT.setString("modName", GTNEIOrePlugin.NAME); - aNBT.setString("modId", GTNEIOrePlugin.MODID); - aNBT.setBoolean("modRequired", true); - aNBT.setString("itemName", itemStack); - aNBT.setInteger("handlerHeight", 160); - aNBT.setInteger("handlerWidth", 166); - aNBT.setInteger("maxRecipesPerPage", 2); - aNBT.setInteger("yShift", 0); - FMLInterModComms.sendMessage("NotEnoughItems", "registerHandlerInfo", aNBT); - } - - @SuppressWarnings("SameParameterValue") - private static void sendCatalyst(String name, String itemStack, int priority) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handlerID", name); - aNBT.setString("itemName", itemStack); - aNBT.setInteger("priority", priority); - FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT); - } - - @SuppressWarnings("SameParameterValue") - private static void sendCatalyst(String name, String itemStack) { - sendCatalyst(name, itemStack, 0); - } -} diff --git a/src/main/java/gtneioreplugin/plugin/NEIPluginConfig.java b/src/main/java/gtneioreplugin/plugin/NEIPluginConfig.java index 8ce07c124c..d325a1085f 100644 --- a/src/main/java/gtneioreplugin/plugin/NEIPluginConfig.java +++ b/src/main/java/gtneioreplugin/plugin/NEIPluginConfig.java @@ -1,7 +1,21 @@ package gtneioreplugin.plugin; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.minecraft.item.ItemStack; + import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; +import codechicken.nei.event.NEIRegisterHandlerInfosEvent; +import codechicken.nei.recipe.HandlerInfo; +import cpw.mods.fml.common.eventhandler.SubscribeEvent; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.util.GTOreDictUnificator; import gtneioreplugin.GTNEIOrePlugin; import gtneioreplugin.plugin.gregtech5.PluginGT5SmallOreStat; import gtneioreplugin.plugin.gregtech5.PluginGT5UndergroundFluid; @@ -31,5 +45,35 @@ public class NEIPluginConfig implements IConfigureNEI { API.registerUsageHandler(pluginSmallOreStat); API.registerRecipeHandler(pluginGT5UndergroundFluid); API.registerUsageHandler(pluginGT5UndergroundFluid); + + List catalysts = Arrays.asList( + ItemList.OilDrill1, + ItemList.OilDrill2, + ItemList.OilDrill3, + ItemList.OilDrill4, + ItemList.OilDrillInfinite); + for (ItemList catalyst : catalysts) { + API.addRecipeCatalyst(catalyst.get(1), pluginGT5UndergroundFluid); + } + } + + @SubscribeEvent + public void registerHandlerInfo(NEIRegisterHandlerInfosEvent event) { + // Though first two handlers are already registered in NEI jar, we need to re-register + // because new DimensionDisplayItems made tabs a bit taller. + Map handlers = new HashMap<>(); + handlers.put("PluginGT5VeinStat", GTOreDictUnificator.get(OrePrefixes.ore, Materials.Manyullyn, 1)); + handlers.put("PluginGT5SmallOreStat", GTOreDictUnificator.get(OrePrefixes.ore, Materials.Platinum, 1)); + handlers.put("PluginGT5UndergroundFluid", ItemList.Electric_Pump_UEV.get(1)); + for (Map.Entry handler : handlers.entrySet()) { + event.registerHandlerInfo( + new HandlerInfo.Builder( + "gtneioreplugin.plugin.gregtech5." + handler.getKey(), + GTNEIOrePlugin.NAME, + GTNEIOrePlugin.MODID).setHeight(160) + .setMaxRecipesPerPage(2) + .setDisplayStack(handler.getValue()) + .build()); + } } } diff --git a/src/main/java/kubatech/ClientProxy.java b/src/main/java/kubatech/ClientProxy.java index d9b1f5cf17..31b21c4a87 100644 --- a/src/main/java/kubatech/ClientProxy.java +++ b/src/main/java/kubatech/ClientProxy.java @@ -30,7 +30,6 @@ import cpw.mods.fml.common.event.FMLServerStartingEvent; import cpw.mods.fml.common.event.FMLServerStoppedEvent; import cpw.mods.fml.common.event.FMLServerStoppingEvent; import kubatech.api.utils.ModUtils; -import kubatech.nei.IMCForNEI; @SuppressWarnings("unused") public class ClientProxy extends CommonProxy { @@ -42,7 +41,6 @@ public class ClientProxy extends CommonProxy { public void init(FMLInitializationEvent event) { super.init(event); - IMCForNEI.IMCSender(); } public void postInit(FMLPostInitializationEvent event) { diff --git a/src/main/java/kubatech/nei/IMCForNEI.java b/src/main/java/kubatech/nei/IMCForNEI.java deleted file mode 100644 index fe1eb64ebb..0000000000 --- a/src/main/java/kubatech/nei/IMCForNEI.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * spotless:off - * KubaTech - Gregtech Addon - * Copyright (C) 2022 - 2024 kuba6000 - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this library. If not, see . - * spotless:on - */ - -package kubatech.nei; - -import static gregtech.api.enums.Mods.EnderIO; - -import net.minecraft.nbt.NBTTagCompound; - -import cpw.mods.fml.common.event.FMLInterModComms; - -public class IMCForNEI { - - public static void IMCSender() { - if (EnderIO.isModLoaded()) sendCatalyst("mobsinfo.mobhandler", "gregtech:gt.blockmachines:14201"); - } - - private static void sendCatalyst(String aName, String aStack, int aPriority) { - NBTTagCompound aNBT = new NBTTagCompound(); - aNBT.setString("handlerID", aName); - aNBT.setString("itemName", aStack); - aNBT.setInteger("priority", aPriority); - FMLInterModComms.sendMessage("NotEnoughItems", "registerCatalystInfo", aNBT); - } - - private static void sendCatalyst(String aName, String aStack) { - sendCatalyst(aName, aStack, 0); - } -} diff --git a/src/main/java/kubatech/nei/NEIConfig.java b/src/main/java/kubatech/nei/NEIConfig.java index 2d1927f5c2..dad4b9aa93 100644 --- a/src/main/java/kubatech/nei/NEIConfig.java +++ b/src/main/java/kubatech/nei/NEIConfig.java @@ -20,6 +20,8 @@ package kubatech.nei; +import static gregtech.api.enums.Mods.EnderIO; +import static gregtech.api.enums.Mods.MobsInfo; import static kubatech.api.enums.ItemList.LegendaryBlackTea; import static kubatech.api.enums.ItemList.LegendaryButterflyTea; import static kubatech.api.enums.ItemList.LegendaryEarlGrayTea; @@ -37,11 +39,15 @@ import static kubatech.api.enums.ItemList.LegendaryYellowTea; import codechicken.nei.api.API; import codechicken.nei.api.IConfigureNEI; import kubatech.Tags; +import kubatech.api.enums.ItemList; public class NEIConfig implements IConfigureNEI { @Override public void loadConfig() { + if (MobsInfo.isModLoaded() && EnderIO.isModLoaded()) { + API.addRecipeCatalyst(ItemList.ExtremeEntityCrusher.get(1), "mobsinfo.mobhandler"); + } API.hideItem(LegendaryBlackTea.get(1)); API.hideItem(LegendaryButterflyTea.get(1)); API.hideItem(LegendaryEarlGrayTea.get(1)); -- cgit