Make modifier crystals smarter about showing in JEI
@@ -22,12 +22,14 @@ import mezz.jei.api.runtime.IIngredientManager;
import mezz.jei.api.runtime.IJeiRuntime;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.inventory.AbstractContainerScreen;
+import net.minecraft.core.NonNullList;
import net.minecraft.core.Registry;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.TagKey;
import net.minecraft.world.Container;
import net.minecraft.world.effect.MobEffectInstance;
import net.minecraft.world.inventory.AbstractContainerMenu;
+import net.minecraft.world.item.CreativeModeTab;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.alchemy.Potion;
@@ -51,6 +53,7 @@ import slimeknights.tconstruct.fluids.TinkerFluids;
import slimeknights.tconstruct.library.materials.definition.IMaterial;
import slimeknights.tconstruct.library.materials.definition.MaterialVariantId;
import slimeknights.tconstruct.library.modifiers.ModifierEntry;
+import slimeknights.tconstruct.library.modifiers.ModifierId;
import slimeknights.tconstruct.library.recipe.TinkerRecipeTypes;
import slimeknights.tconstruct.library.recipe.alloying.AlloyRecipe;
import slimeknights.tconstruct.library.recipe.casting.IDisplayableCastingRecipe;
@@ -101,6 +104,7 @@ import slimeknights.tconstruct.tools.TinkerModifiers;
import slimeknights.tconstruct.tools.TinkerTools;
import slimeknights.tconstruct.tools.item.ArmorSlotType;
import slimeknights.tconstruct.tools.item.CreativeSlotItem;
+import slimeknights.tconstruct.tools.item.ModifierCrystalItem;
import javax.annotation.Nullable;
import java.util.Collections;
@@ -317,6 +321,10 @@ public class JEIPlugin implements IModPlugin {
SlotType slotType = CreativeSlotItem.getSlot(stack);
return slotType != null ? slotType.getName() : "";
});
+ registry.registerSubtypeInterpreter(VanillaTypes.ITEM_STACK, TinkerModifiers.modifierCrystal.get(), (stack, context) -> {
+ ModifierId id = ModifierCrystalItem.getModifier(stack);
+ return id == null ? "" : id.toString();
+ });
}
@Override
@@ -383,7 +391,9 @@ public class JEIPlugin implements IModPlugin {
IIngredientManager manager = jeiRuntime.getIngredientManager();
// shown via the modifiers
- manager.removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, Collections.singletonList(new ItemStack(TinkerModifiers.modifierCrystal)));
+ NonNullList<ItemStack> modifierCrystals = NonNullList.create();
+ TinkerModifiers.modifierCrystal.get().fillItemCategory(CreativeModeTab.TAB_SEARCH, modifierCrystals);
+ manager.removeIngredientsAtRuntime(VanillaTypes.ITEM_STACK, modifierCrystals);
// hide knightslime and slimesteel until implemented
removeFluid(manager, TinkerFluids.moltenSoulsteel.get(), TinkerFluids.moltenSoulsteel.asItem());
