Skip to content

Commit

Permalink
some changes, added some configs.
Browse files Browse the repository at this point in the history
  • Loading branch information
WanionCane committed Jul 16, 2016
1 parent d52ef50 commit 9ac09c1
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 5 deletions.
10 changes: 10 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ version = "1.1"
group= "wanion.jeihider" // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = "JEIHider"

jar {
manifest {
attributes 'FMLCorePlugin': 'wanion.jeihider.core.JEIHiderCore',
'FMLCorePluginContainsFMLMod': 'false'
}
}

sourceCompatibility = 1.8
targetCompatibility = 1.8

minecraft {
version = "1.10.2-12.18.0.2007-1.10.0"
runDir = "run"
Expand Down
41 changes: 36 additions & 5 deletions src/main/java/wanion/jeihider/JEIHider.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@
*/

import mezz.jei.api.*;
import mezz.jei.api.recipe.IRecipeCategory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.fml.common.Loader;

import javax.annotation.Nonnull;
import java.io.File;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -16,7 +20,21 @@ public class JEIHider implements IModPlugin
{
private IItemBlacklist itemBlacklist;
private IItemRegistry iItemRegistry;
private final List<ItemStack> itemStacksToHide = new ArrayList<ItemStack>();
private final List<ItemStack> itemStacksToHide = new ArrayList<>();
private final boolean hideRecyclerRecipes;
private final boolean hideEnchantmentRecipes;
private final Class<? extends IRecipeCategory> recyclerCategoryClass;
private final Class<? extends IRecipeCategory> enchantmentCategoryClass;

@SuppressWarnings("unchecked")
public JEIHider() throws ClassNotFoundException
{
final Configuration config = new Configuration(new File("." + File.separatorChar + "JEI Hider.cfg"));
hideRecyclerRecipes = Loader.isModLoaded("IC2") && config.get("hideRecyclerRecipes", Configuration.CATEGORY_GENERAL, false).getBoolean();
hideEnchantmentRecipes = Loader.isModLoaded("IC2") && config.get("hideEnchantmentRecipes", Configuration.CATEGORY_GENERAL, false).getBoolean();
recyclerCategoryClass = hideRecyclerRecipes ? (Class<? extends IRecipeCategory>) Class.forName("ic2.jeiIntegration.recipe.misc.ScrapboxRecipeCategory") : null;
enchantmentCategoryClass = hideEnchantmentRecipes ? (Class<? extends IRecipeCategory>) Class.forName("") : null;
}

@Override
public void register(@Nonnull IModRegistry iModRegistry)
Expand All @@ -30,11 +48,24 @@ public void onRuntimeAvailable(@Nonnull IJeiRuntime iJeiRuntime)
{
if (itemStacksToHide.isEmpty()) {
final IRecipeRegistry iRecipeRegistry = iJeiRuntime.getRecipeRegistry();
for (final ItemStack itemStack : iItemRegistry.getItemList())
if (iRecipeRegistry.getRecipeCategoriesWithInput(itemStack).isEmpty() && iRecipeRegistry.getRecipeCategoriesWithOutput(itemStack).isEmpty())
for (final ItemStack itemStack : iItemRegistry.getItemList()) {
final List<IRecipeCategory> recipeCategoriesOfInput = iRecipeRegistry.getRecipeCategoriesWithInput(itemStack);
final List<IRecipeCategory> recipeCategoriesOfOutput = iRecipeRegistry.getRecipeCategoriesWithOutput(itemStack);
if (recipeCategoriesOfInput.isEmpty() && recipeCategoriesOfOutput.isEmpty())
itemStacksToHide.add(itemStack);
if ((hideRecyclerRecipes || hideEnchantmentRecipes) && !recipeCategoriesOfInput.isEmpty() && recipeCategoriesOfOutput.isEmpty()) {
if (recipeCategoriesOfInput.size() == 1) {
if (hideRecyclerRecipes && recipeCategoriesOfInput.get(0).getClass() == recyclerCategoryClass)
itemStacksToHide.add(itemStack);
else if (hideEnchantmentRecipes && recipeCategoriesOfInput.get(0).getClass() == enchantmentCategoryClass)
itemStacksToHide.add(itemStack);
} else if (recipeCategoriesOfInput.size() == 2 && hideRecyclerRecipes && hideEnchantmentRecipes)
if ((recipeCategoriesOfInput.get(0).getClass() == recyclerCategoryClass && recipeCategoriesOfInput.get(1).getClass() == enchantmentCategoryClass) ||
(recipeCategoriesOfInput.get(1).getClass() == recyclerCategoryClass && recipeCategoriesOfInput.get(0).getClass() == enchantmentCategoryClass))
itemStacksToHide.add(itemStack);
}
}
}
for (final ItemStack itemStack : itemStacksToHide)
itemBlacklist.addItemToBlacklist(itemStack);
itemStacksToHide.forEach(itemBlacklist::addItemToBlacklist);
}
}

0 comments on commit 9ac09c1

Please sign in to comment.