Skip to content

Commit

Permalink
Update to JEI 9.4+
Browse files Browse the repository at this point in the history
  • Loading branch information
KnightMiner committed Mar 15, 2022
1 parent 559341d commit 3e2b780
Show file tree
Hide file tree
Showing 13 changed files with 34 additions and 42 deletions.
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ mantle_version=1.8.36
mantle_range=[1.8.36,)

# Optional compat
jei_version=9.3.+
jei_range=[9.3.2.92,)
jei_version=9.4.+
jei_range=[9.4.0,)
probe_version=3.0.6-8
crt_version=7.1.0.307
crt_range=[7.1.0.245,)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import mezz.jei.api.gui.ingredient.IRecipeSlotTooltipCallback;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -135,7 +135,7 @@ public static int drawVariableFluids(IRecipeLayoutBuilder builder, RecipeIngredi
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, AlloyRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, AlloyRecipe recipe, IFocusGroup focuses) {
// inputs
int maxAmount = drawVariableFluids(builder, RecipeIngredientRole.INPUT, 19, 11, 48, 32, recipe.getDisplayInputs(), recipe.getOutput().getAmount(), FLUID_TOOLTIP);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -83,7 +83,7 @@ public List<Component> getTooltipStrings(MoldingRecipe recipe, IRecipeSlotsView
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, MoldingRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, MoldingRecipe recipe, IFocusGroup focuses) {
// basic input output
builder.addSlot(RecipeIngredientRole.INPUT, 3, 24).addIngredients(recipe.getMaterial());
builder.addSlot(RecipeIngredientRole.OUTPUT, 51, 24).addItemStack(recipe.getResultItem());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import mezz.jei.api.gui.ingredient.IRecipeSlotView;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -100,7 +100,7 @@ public List<Component> getTooltipStrings(IDisplayableCastingRecipe recipe, IReci
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, IDisplayableCastingRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, IDisplayableCastingRecipe recipe, IFocusGroup focuses) {
// items
List<ItemStack> casts = recipe.getCastItems();
if (!casts.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,11 @@
import mezz.jei.api.constants.VanillaTypes;
import mezz.jei.api.ingredients.IIngredientHelper;
import mezz.jei.api.ingredients.IIngredientType;
import mezz.jei.api.ingredients.ITypedIngredient;
import mezz.jei.api.ingredients.subtypes.UidContext;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.SpawnEggItem;
import slimeknights.tconstruct.plugin.jei.TConstructJEIConstants;

Expand All @@ -27,6 +25,7 @@ public IIngredientType<EntityType> getIngredientType() {
return TConstructJEIConstants.ENTITY_TYPE;
}

@SuppressWarnings("removal")
@Nullable
@Override
public EntityType getMatch(Iterable<EntityType> iterable, EntityType type, UidContext context) {
Expand Down Expand Up @@ -85,21 +84,15 @@ public String getErrorInfo(@Nullable EntityType type) {
}

/** Applies the item focuses to the list of entities */
public static List<EntityType> applyFocus(RecipeIngredientRole role, List<EntityType> displayInputs, List<? extends IFocus<?>> focuses) {
for (IFocus<?> focus : focuses) {
if (focus.getRole() == role) {
ITypedIngredient<?> value = focus.getTypedValue();
if (value.getType() == VanillaTypes.ITEM) {
ItemStack stack = (ItemStack)value.getIngredient();
if (stack.getItem() instanceof SpawnEggItem egg) {
EntityType<?> type = egg.getType(null);
if (displayInputs.contains(type)) {
return Collections.singletonList(type);
}
}
}
}
}
return displayInputs;
public static List<EntityType> applyFocus(RecipeIngredientRole role, List<EntityType> displayInputs, IFocusGroup focuses) {
return focuses.getFocuses(VanillaTypes.ITEM)
.filter(focus -> focus.getRole() == role)
.map(focus -> focus.getTypedValue().getIngredient().getItem())
.filter(item -> item instanceof SpawnEggItem)
.<EntityType>map(item -> ((SpawnEggItem) item).getType(null))
.filter(displayInputs::contains)
.map(Collections::singletonList)
.findFirst()
.orElse(displayInputs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import mezz.jei.api.gui.ingredient.IRecipeSlotView;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.ChatFormatting;
Expand Down Expand Up @@ -90,7 +90,7 @@ public void draw(EntityMeltingRecipe recipe, IRecipeSlotsView slot, PoseStack ma

@SuppressWarnings("rawtypes")
@Override
public void setRecipe(IRecipeLayoutBuilder builder, EntityMeltingRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, EntityMeltingRecipe recipe, IFocusGroup focuses) {
// inputs, filtered by spawn egg item
List<EntityType> displayTypes = EntityIngredientHelper.applyFocus(RecipeIngredientRole.INPUT, recipe.getEntityInputs(), focuses);
builder.addSlot(RecipeIngredientRole.INPUT, 19, 11)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import mezz.jei.api.gui.builder.IRecipeLayoutBuilder;
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.network.chat.Component;
Expand All @@ -15,8 +15,6 @@
import slimeknights.tconstruct.plugin.jei.TConstructJEIConstants;
import slimeknights.tconstruct.tools.TinkerTools;

import java.util.List;

public class SeveringCategory implements IRecipeCategory<SeveringRecipe> {
public static final ResourceLocation BACKGROUND_LOC = TConstruct.getResource("textures/gui/jei/tinker_station.png");
private static final Component TITLE = TConstruct.makeTranslation("jei", "severing.title");
Expand Down Expand Up @@ -49,7 +47,7 @@ public Component getTitle() {
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, SeveringRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, SeveringRecipe recipe, IFocusGroup focuses) {
builder.addSlot(RecipeIngredientRole.INPUT, 3, 3)
.setCustomRenderer(TConstructJEIConstants.ENTITY_TYPE, entityRenderer)
.addIngredients(TConstructJEIConstants.ENTITY_TYPE, EntityIngredientHelper.applyFocus(RecipeIngredientRole.INPUT, recipe.getEntityInputs(), focuses));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IRecipeSlotTooltipCallback;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
Expand Down Expand Up @@ -51,7 +51,7 @@ public Component getTitle() {
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, MeltingRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, MeltingRecipe recipe, IFocusGroup focuses) {
// input
builder.addSlot(RecipeIngredientRole.INPUT, 24, 18).addIngredients(recipe.getInput());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import mezz.jei.api.gui.ingredient.IRecipeSlotTooltipCallback;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import net.minecraft.ChatFormatting;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -84,7 +84,7 @@ public void draw(MeltingRecipe recipe, IRecipeSlotsView slots, PoseStack matrice
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, MeltingRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, MeltingRecipe recipe, IFocusGroup focuses) {
// input
builder.addSlot(RecipeIngredientRole.INPUT, 24, 18).addIngredients(recipe.getInput());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public IIngredientType<ModifierEntry> getIngredientType() {
return TConstructJEIConstants.MODIFIER_TYPE;
}

@SuppressWarnings("removal")
@Nullable
@Override
public ModifierEntry getMatch(Iterable<ModifierEntry> iterable, ModifierEntry check, UidContext context) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
Expand Down Expand Up @@ -187,7 +187,7 @@ public List<Component> getTooltipStrings(IDisplayModifierRecipe recipe, IRecipeS
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, IDisplayModifierRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, IDisplayModifierRecipe recipe, IFocusGroup focuses) {
// inputs
builder.addSlot(RecipeIngredientRole.INPUT, 3, 33).addItemStacks(recipe.getDisplayItems(0));
builder.addSlot(RecipeIngredientRole.INPUT, 25, 15).addItemStacks(recipe.getDisplayItems(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import mezz.jei.api.gui.drawable.IDrawable;
import mezz.jei.api.gui.ingredient.IRecipeSlotsView;
import mezz.jei.api.helpers.IGuiHelper;
import mezz.jei.api.recipe.IFocus;
import mezz.jei.api.recipe.IFocusGroup;
import mezz.jei.api.recipe.RecipeIngredientRole;
import mezz.jei.api.recipe.category.IRecipeCategory;
import net.minecraft.client.Minecraft;
Expand All @@ -24,7 +24,6 @@
import slimeknights.tconstruct.tables.TinkerTables;

import java.awt.Color;
import java.util.List;
import java.util.Objects;

public class PartBuilderCategory implements IRecipeCategory<IDisplayPartBuilderRecipe> {
Expand Down Expand Up @@ -66,7 +65,7 @@ public void draw(IDisplayPartBuilderRecipe recipe, IRecipeSlotsView slots, PoseS
}

@Override
public void setRecipe(IRecipeLayoutBuilder builder, IDisplayPartBuilderRecipe recipe, List<? extends IFocus<?>> focuses) {
public void setRecipe(IRecipeLayoutBuilder builder, IDisplayPartBuilderRecipe recipe, IFocusGroup focuses) {
// items
builder.addSlot(RecipeIngredientRole.INPUT, 25, 16).addItemStacks(MaterialItemList.getItems(recipe.getMaterial().getVariant()));
builder.addSlot(RecipeIngredientRole.INPUT, 4, 16).addItemStacks(recipe.getPatternItems());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public IIngredientType<Pattern> getIngredientType() {
return TConstructJEIConstants.PATTERN_TYPE;
}

@SuppressWarnings("removal")
@Nullable
@Override
public Pattern getMatch(Iterable<Pattern> iterable, Pattern match, UidContext context) {
Expand Down

0 comments on commit 3e2b780

Please sign in to comment.