Skip to content

Commit

Permalink
Simplify to a single version for this update, and remove methods adde…
Browse files Browse the repository at this point in the history
…d and deprecated in the same version
  • Loading branch information
mezz committed Oct 1, 2024
1 parent 81f7bb7 commit 64b14c4
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 218 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ default IRecipeSlotBuilder addInputSlot(int x, int y) {
*
* @return a {@link IRecipeSlotBuilder} that has further methods for adding ingredients, setting position, etc.
*
* @since 15.20.3
* @since 15.20.0
*/
default IRecipeSlotBuilder addInputSlot() {
return addSlot(RecipeIngredientRole.INPUT);
Expand All @@ -61,7 +61,7 @@ default IRecipeSlotBuilder addOutputSlot(int x, int y) {
*
* @return a {@link IRecipeSlotBuilder} that has further methods for adding ingredients, setting position, etc.
*
* @since 15.20.3
* @since 15.20.0
*/
default IRecipeSlotBuilder addOutputSlot() {
return addSlot(RecipeIngredientRole.OUTPUT);
Expand All @@ -88,7 +88,7 @@ default IRecipeSlotBuilder addSlot(RecipeIngredientRole role, int x, int y) {
* @param role the {@link RecipeIngredientRole} of this slot (for lookups).
* @return a {@link IRecipeSlotBuilder} that has further methods for adding ingredients, etc.
*
* @since 15.20.1
* @since 15.20.0
*/
IRecipeSlotBuilder addSlot(RecipeIngredientRole role);

Expand All @@ -101,7 +101,7 @@ default IRecipeSlotBuilder addSlot(RecipeIngredientRole role, int x, int y) {
* @since 15.10.0
* @deprecated there are easier ways to create slotted widgets now. Use {@link IRecipeExtrasBuilder#addSlottedWidget}.
*/
@Deprecated(since = "15.20.3", forRemoval = true)
@Deprecated(since = "15.20.0", forRemoval = true)
@SuppressWarnings("removal")
IRecipeSlotBuilder addSlotToWidget(RecipeIngredientRole role, mezz.jei.api.gui.widgets.ISlottedWidgetFactory<?> widgetFactory);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ default void addTooltipCallback(IRecipeSlotTooltipCallback tooltipCallback) {
* Get the area that this recipe slot draws on, including the area covered by its background texture.
* Useful for laying out other recipe elements relative to the slot.
*
* @since 15.20.3
* @since 15.20.0
*/
Rect2i getAreaIncludingBackground();
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*
* @see IRecipeSlotsView for a view with less access to drawable properties of the slots.
*
* @since 15.20.3
* @since 15.20.0
*/
public interface IRecipeSlotDrawablesView {
/**
* Get all slots for a recipe.
*
* @since 15.20.3
* @since 15.20.0
*/
@Unmodifiable
List<IRecipeSlotDrawable> getSlots();

/**
* Get the list of slots for the given {@link RecipeIngredientRole} for a recipe.
*
* @since 15.20.3
* @since 15.20.0
*/
default List<IRecipeSlotDrawable> getSlots(RecipeIngredientRole role) {
List<IRecipeSlotDrawable> list = new ArrayList<>();
Expand All @@ -44,7 +44,7 @@ default List<IRecipeSlotDrawable> getSlots(RecipeIngredientRole role) {
/**
* Get a recipe slot by its name set with {@link IRecipeSlotBuilder#setSlotName(String)}.
*
* @since 15.20.3
* @since 15.20.0
*/
default Optional<IRecipeSlotDrawable> findSlotByName(String slotName) {
return getSlots().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Represents a horizontal alignment of an element inside a larger area.
* @since 15.20.1
* @since 15.20.0
*/
public enum HorizontalAlignment {
LEFT {
Expand All @@ -26,7 +26,7 @@ public int getXPos(int availableWidth, int elementWidth) {

/**
* Calculate the x position needed to align an element with the given width inside the availableArea.
* @since 15.20.1
* @since 15.20.0
*/
public abstract int getXPos(int availableWidth, int elementWidth);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
/**
* Interface for things that can have their position set, and be aligned vertically and horizontally in an area.
*
* @since 15.20.1
* @since 15.20.0
*/
public interface IPlaceable<THIS extends IPlaceable<THIS>> {
/**
* Place this element at the given position.
* @since 15.20.1
* @since 15.20.0
*/
THIS setPosition(int xPos, int yPos);

/**
* Place this element inside the given area, with the given alignment.
*
* @since 15.20.1
* @since 15.20.0
*/
default THIS setPosition(int areaX, int areaY, int areaWidth, int areaHeight, HorizontalAlignment horizontalAlignment, VerticalAlignment verticalAlignment) {
int x = areaX + horizontalAlignment.getXPos(areaWidth, getWidth());
Expand All @@ -25,13 +25,13 @@ default THIS setPosition(int areaX, int areaY, int areaWidth, int areaHeight, Ho

/**
* Get the width of this element.
* @since 15.20.1
* @since 15.20.0
*/
int getWidth();

/**
* Get the height of this element.
* @since 15.20.1
* @since 15.20.0
*/
int getHeight();
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/**
* Represents a vertical alignment of an element inside a larger box (availableArea).
* @since 15.20.1
* @since 15.20.0
*/
public enum VerticalAlignment {
TOP {
Expand All @@ -26,7 +26,7 @@ public int getYPos(int availableHeight, int elementHeight) {

/**
* Calculate the y position needed to align an element with the given height inside the availableArea.
* @since 15.20.1
* @since 15.20.0
*/
public abstract int getYPos(int availableHeight, int elementHeight);
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public interface IRecipeExtrasBuilder {
/**
* Get the recipe slots that were created in {@link IRecipeCategory#setRecipe}.
*
* @since 15.20.3
* @since 15.20.0
*/
IRecipeSlotDrawablesView getRecipeSlots();

Expand All @@ -46,7 +46,7 @@ public interface IRecipeExtrasBuilder {
/**
* Add a {@link IDrawable} for the recipe category, and place it after with {@link IPlaceable} methods.
*
* @since 15.20.1
* @since 15.20.0
*/
IPlaceable<?> addDrawable(IDrawable drawable);

Expand All @@ -61,7 +61,7 @@ public interface IRecipeExtrasBuilder {
* Add a {@link ISlottedRecipeWidget} for the recipe category, and
* mark that the slots are going to be handled by the slotted widget.
*
* @since 15.20.3
* @since 15.20.0
*/
void addSlottedWidget(ISlottedRecipeWidget widget, List<IRecipeSlotDrawable> slots);

Expand All @@ -85,7 +85,7 @@ public interface IRecipeExtrasBuilder {
*
* Set the contents by using the methods in {@link IScrollBoxWidget}.
*
* @since 15.19.6
* @since 15.20.0
*/
IScrollBoxWidget addScrollBoxWidget(int width, int height, int xPos, int yPos);

Expand All @@ -97,83 +97,35 @@ public interface IRecipeExtrasBuilder {
*
* You can move the resulting grid by using the {@link IScrollGridWidget}'s {@link IPlaceable} methods.
*
* @since 15.20.3
* @since 15.20.0
*/
IScrollGridWidget addScrollGridWidget(List<IRecipeSlotDrawable> slots, int columns, int visibleRows);

/**
* Add a vanilla-style recipe arrow to the recipe layout.
*
* @since 15.20.0
* @deprecated use {@link #addRecipeArrow()} and then set the position with {@link IPlaceable} methods.
*/
@Deprecated(since = "15.20.1", forRemoval = true)
default void addRecipeArrow(int xPos, int yPos) {
addRecipeArrow()
.setPosition(xPos, yPos);
}

/**
* Add a vanilla-style recipe arrow to the recipe layout.
*
* @since 15.20.1
*/
IPlaceable<?> addRecipeArrow();

/**
* Add a vanilla-style recipe plus sign to the recipe layout.
*
* @since 15.20.0
* @deprecated use {@link #addRecipePlusSign()} and then set the position with {@link IPlaceable} methods.
*/
@Deprecated(since = "15.20.1", forRemoval = true)
default void addRecipePlusSign(int xPos, int yPos) {
addRecipePlusSign()
.setPosition(xPos, yPos);
}

/**
* Add a vanilla-style recipe plus sign to the recipe layout.
*
* @since 15.20.1
*/
IPlaceable<?> addRecipePlusSign();

/**
* Add a vanilla-style recipe arrow that fills over time in a loop.
*
* @since 15.20.0
* @deprecated use {@link #addAnimatedRecipeArrow(int)} and then set the position with {@link IPlaceable} methods.
*/
@Deprecated(since = "15.20.1", forRemoval = true)
default void addAnimatedRecipeArrow(int ticksPerCycle, int xPos, int yPos) {
addAnimatedRecipeArrow(ticksPerCycle)
.setPosition(xPos, yPos);
}

/**
* Add a vanilla-style recipe arrow that fills over time in a loop.
*
* @since 15.20.1
*/
IPlaceable<?> addAnimatedRecipeArrow(int ticksPerCycle);

/**
* Add a vanilla-style recipe flame that empties over time in a loop.
*
* @since 15.20.0
* @deprecated use {@link #addAnimatedRecipeFlame(int)} and then set the position with {@link IPlaceable} methods.
*/
@Deprecated(since = "15.20.1", forRemoval = true)
default void addAnimatedRecipeFlame(int cookTime, int xPos, int yPos) {
addAnimatedRecipeFlame(cookTime)
.setPosition(xPos, yPos);
}

/**
* Add a vanilla-style recipe flame that empties over time in a loop.
*
* @since 15.20.1
*/
IPlaceable<?> addAnimatedRecipeFlame(int cookTime);

Expand All @@ -186,25 +138,12 @@ default void addAnimatedRecipeFlame(int cookTime, int xPos, int yPos) {
* Text can be vertically and horizontally aligned using the methods in {@link ITextWidget}.
* By default, text is vertically aligned "top" and horizontally aligned "left" inside the area given.
*
* @since 15.20.1
* @since 15.20.0
*/
default ITextWidget addText(FormattedText text, int maxWidth, int maxHeight) {
return addText(List.of(text), maxWidth, maxHeight);
}

/**
* Add text to the recipe layout.
*
* Automatically supports text wrapping and truncation of very long lines.
* If text is truncated, it will be displayed with an ellipsis (...) and can be viewed fully with a tooltip.
*
* Text can be vertically and horizontally aligned using the methods in {@link ITextWidget}.
* By default, text is vertically aligned "top" and horizontally aligned "left" inside the area given.
*
* @since 15.20.1
*/
ITextWidget addText(List<FormattedText> text, int maxWidth, int maxHeight);

/**
* Add text to the recipe layout.
*
Expand All @@ -215,30 +154,6 @@ default ITextWidget addText(FormattedText text, int maxWidth, int maxHeight) {
* By default, text is vertically aligned "top" and horizontally aligned "left" inside the area given.
*
* @since 15.20.0
* @deprecated use {@link #addText(FormattedText, int, int)} and then set the position.
*/
@Deprecated(since = "15.20.1", forRemoval = true)
default ITextWidget addText(FormattedText text, int xPos, int yPos, int maxWidth, int maxHeight) {
return addText(List.of(text), maxWidth, maxHeight)
.setPosition(xPos, yPos);
}

/**
* Add text to the recipe layout.
*
* Automatically supports text wrapping and truncation of very long lines.
* If text is truncated, it will be displayed with an ellipsis (...) and can be viewed fully with a tooltip.
*
* Text can be vertically and horizontally aligned using the methods in {@link ITextWidget}.
* By default, text is vertically aligned "top" and horizontally aligned "left" inside the area given.
*
* @since 15.20.0
* @deprecated use {@link #addText(List, int, int)} and then set the position.
*/
@Deprecated(since = "15.20.1", forRemoval = true)
default ITextWidget addText(List<FormattedText> text, int xPos, int yPos, int maxWidth, int maxHeight) {
return addText(text, maxWidth, maxHeight)
.setPosition(xPos, yPos);
}

ITextWidget addText(List<FormattedText> text, int maxWidth, int maxHeight);
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ public interface IScrollBoxWidget extends IRecipeWidget, IJeiInputHandler {
* Get the width available for displaying contents in the scroll box.
* The scroll bar takes up some of the space, so this can be used in order to create accurately-sized contents.
*
* @since 15.19.6
* @since 15.20.0
*/
int getContentAreaWidth();

/**
* Get the visible height for displaying contents in the scroll box.
* The actual height of the contents can be taller, because the box can scroll to show more.
*
* @since 15.19.6
* @since 15.20.0
*/
int getContentAreaHeight();

/**
* Set the contents to display inside the scroll box.
* The drawable width should match {@link #getContentAreaWidth()}, and the height can be any height.
*
* @since 15.19.6
* @since 15.20.0
*/
IScrollBoxWidget setContents(IDrawable contents);

/**
* Display text in the scroll box.
* Text will be automatically wrapped in order to fit inside of {@link #getContentAreaWidth()}.
*
* @since 15.19.6
* @since 15.20.0
*/
IScrollBoxWidget setContents(List<FormattedText> text);
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
* Modeled after the vanilla creative menu.
*
* Create one with {@link IRecipeExtrasBuilder#addScrollGridWidget}.
* @since 15.20.3
* @since 15.20.0
*/
public interface IScrollGridWidget extends ISlottedRecipeWidget, IPlaceable<IScrollGridWidget> {
/**
* Get the position and size of this widget, relative to its parent element.
*
* @since 15.20.3
* @since 15.20.0
*/
ScreenRectangle getScreenRectangle();
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
* @deprecated use {@link IRecipeExtrasBuilder#addScrollGridWidget} instead, it's much simpler
*/
@SuppressWarnings({"DeprecatedIsStillUsed", "removal"})
@Deprecated(since = "15.20.3", forRemoval = true)
@Deprecated(since = "15.20.0", forRemoval = true)
public interface IScrollGridWidgetFactory<R> extends ISlottedWidgetFactory<R> {
/**
* @since 15.10.0
Expand Down
Loading

0 comments on commit 64b14c4

Please sign in to comment.