JEI recipes overlapping fix.

This commit is contained in:
Dragon2488 2016-09-18 13:04:39 +07:00
parent d94f16ea07
commit 82dab9d1bd
4 changed files with 45 additions and 9 deletions

View file

@ -0,0 +1,28 @@
package gregtech.jei;
import mezz.jei.api.IJeiHelpers;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.Loader;
public class JEICompat {
public static void hideItem(ItemStack stack) {
if(Loader.isModLoaded("JustEnoughItems")) {
try {
hideItemUnsafe(stack);
} catch (Exception exception) {
System.out.println("Can't blacklist " + stack + " in JEI!");
exception.printStackTrace();
}
}
}
public static void hideItemUnsafe(ItemStack stack) {
IJeiHelpers helpers = JEI_GT_Plugin.getJeiHelpers();
if(helpers != null) {
helpers.getItemBlacklist().addItemToBlacklist(stack);
}
}
}

View file

@ -1,6 +1,5 @@
package gregtech.jei;
import gregtech.api.util.GT_LanguageManager;
import gregtech.api.util.GT_Recipe;
import gregtech.api.util.GT_Utility;
import mezz.jei.Internal;
@ -8,7 +7,6 @@ import mezz.jei.api.IGuiHelper;
import mezz.jei.api.gui.IGuiFluidStackGroup;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.ITooltipCallback;
import mezz.jei.api.recipe.IRecipeWrapper;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;

View file

@ -6,6 +6,7 @@ import mezz.jei.Internal;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.recipe.IRecipeCategory;
import mezz.jei.gui.DrawableResource;
import net.minecraft.client.Minecraft;
import net.minecraft.util.ResourceLocation;
@ -39,9 +40,15 @@ public class JEIGregtehRecipeCategory implements IRecipeCategory<JEIGregtechReci
@Nonnull
@Override
public IDrawable getBackground() {
return Internal.getHelpers().getGuiHelper().createDrawable(
new ResourceLocation(mRecipeMap.mNEIGUIPath),
1, 3, 174, 78, -7, 0, -0, 0);
return new DrawableResource(new ResourceLocation(mRecipeMap.mNEIGUIPath),
1, 3, 174, 78, -7, 0, -0, 0) {
@Override
public int getHeight() {
return super.getHeight() + 50;
}
};
}
@Override

View file

@ -1,10 +1,7 @@
package gregtech.jei;
import gregtech.api.util.GT_Recipe;
import mezz.jei.api.IJeiRuntime;
import mezz.jei.api.IModPlugin;
import mezz.jei.api.IModRegistry;
import mezz.jei.api.JEIPlugin;
import mezz.jei.api.*;
import javax.annotation.Nonnull;
import java.util.stream.Collectors;
@ -12,8 +9,11 @@ import java.util.stream.Collectors;
@JEIPlugin
public class JEI_GT_Plugin implements IModPlugin {
private static IJeiHelpers jeiHelpers;
@Override
public void register(@Nonnull IModRegistry registry) {
jeiHelpers = registry.getJeiHelpers();
registry.addRecipeHandlers(new JEIGregtechRecipeHandler());
for(GT_Recipe.GT_Recipe_Map recipe_map : GT_Recipe.GT_Recipe_Map.sMappings) {
if(recipe_map.mNEIAllowed) {
@ -28,4 +28,7 @@ public class JEI_GT_Plugin implements IModPlugin {
@Override
public void onRuntimeAvailable(@Nonnull IJeiRuntime jeiRuntime) {}
public static IJeiHelpers getJeiHelpers() {
return jeiHelpers;
}
}