-
Notifications
You must be signed in to change notification settings - Fork 303
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add convenience methods and make scrolling grids of ingredients much …
…easier to create
- Loading branch information
Showing
37 changed files
with
339 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 3 additions & 1 deletion
4
Common/src/main/java/mezz/jei/common/util/ImmutablePoint2i.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
package mezz.jei.common.util; | ||
|
||
public record ImmutablePoint2i(int x, int y) {} | ||
public record ImmutablePoint2i(int x, int y) { | ||
public static final ImmutablePoint2i ORIGIN = new ImmutablePoint2i(0, 0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
CommonApi/src/main/java/mezz/jei/api/gui/ingredient/IRecipeSlotDrawablesView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package mezz.jei.api.gui.ingredient; | ||
|
||
import mezz.jei.api.gui.builder.IRecipeSlotBuilder; | ||
import mezz.jei.api.recipe.RecipeIngredientRole; | ||
import org.jetbrains.annotations.Unmodifiable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
/** | ||
* Represents all the drawn ingredients in slots that are part of a recipe. | ||
* | ||
* This view is meant as a source of information for drawing, positioning, and tooltips. | ||
* | ||
* @see IRecipeSlotsView for a view with less access to drawable properties of the slots. | ||
* | ||
* @since 19.19.3 | ||
*/ | ||
public interface IRecipeSlotDrawablesView { | ||
/** | ||
* Get all slots for a recipe. | ||
* | ||
* @since 19.19.3 | ||
*/ | ||
@Unmodifiable | ||
List<IRecipeSlotDrawable> getSlots(); | ||
|
||
/** | ||
* Get the list of slots for the given {@link RecipeIngredientRole} for a recipe. | ||
* | ||
* @since 19.19.3 | ||
*/ | ||
default List<IRecipeSlotDrawable> getSlots(RecipeIngredientRole role) { | ||
List<IRecipeSlotDrawable> list = new ArrayList<>(); | ||
for (IRecipeSlotDrawable slotView : getSlots()) { | ||
if (slotView.getRole() == role) { | ||
list.add(slotView); | ||
} | ||
} | ||
return list; | ||
} | ||
|
||
/** | ||
* Get a recipe slot by its name set with {@link IRecipeSlotBuilder#setSlotName(String)}. | ||
* | ||
* @since 19.19.3 | ||
*/ | ||
default Optional<IRecipeSlotDrawable> findSlotByName(String slotName) { | ||
return getSlots().stream() | ||
.filter(slot -> | ||
slot.getSlotName() | ||
.map(slotName::equals) | ||
.orElse(false) | ||
) | ||
.findFirst(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
CommonApi/src/main/java/mezz/jei/api/gui/widgets/IScrollGridWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package mezz.jei.api.gui.widgets; | ||
|
||
import mezz.jei.api.gui.placement.IPlaceable; | ||
import net.minecraft.client.gui.navigation.ScreenRectangle; | ||
|
||
/** | ||
* A scrolling area for ingredients with a scrollbar. | ||
* Modeled after the vanilla creative menu. | ||
* | ||
* Create one with {@link IRecipeExtrasBuilder#addScrollGridWidget}. | ||
* @since 19.19.3 | ||
*/ | ||
public interface IScrollGridWidget extends ISlottedRecipeWidget, IPlaceable<IScrollGridWidget> { | ||
/** | ||
* Get the position and size of this widget, relative to its parent element. | ||
* | ||
* @since 19.19.3 | ||
*/ | ||
ScreenRectangle getScreenRectangle(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 2 additions & 7 deletions
9
CommonApi/src/main/java/mezz/jei/api/gui/widgets/ISlottedRecipeWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.