diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-03-21 12:23:14 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-03-21 12:23:14 +0800 |
| commit | 7c4788f86f589d71b319e186fa5d8a468046bcc1 (patch) | |
| tree | b87fd23a6d65a96e381c27fe0470d1f50e77a635 /api/src/main/java/me | |
| parent | 2c29cac8a5e0878696c8e6635f4e41ed4845b41c (diff) | |
| download | RoughlyEnoughItems-7c4788f86f589d71b319e186fa5d8a468046bcc1.tar.gz RoughlyEnoughItems-7c4788f86f589d71b319e186fa5d8a468046bcc1.tar.bz2 RoughlyEnoughItems-7c4788f86f589d71b319e186fa5d8a468046bcc1.zip | |
Rely on ScreenRegistry more on calculating the bounds
Signed-off-by: shedaniel <daniel@shedaniel.me>
Diffstat (limited to 'api/src/main/java/me')
4 files changed, 32 insertions, 9 deletions
diff --git a/api/src/main/java/me/shedaniel/rei/api/REIHelper.java b/api/src/main/java/me/shedaniel/rei/api/REIHelper.java index f02ba4024..2911dab04 100644 --- a/api/src/main/java/me/shedaniel/rei/api/REIHelper.java +++ b/api/src/main/java/me/shedaniel/rei/api/REIHelper.java @@ -40,7 +40,6 @@ import java.util.Optional; @Environment(EnvType.CLIENT) public interface REIHelper extends Reloadable { - /** * @return the instance of {@link REIHelper} */ diff --git a/api/src/main/java/me/shedaniel/rei/api/ingredient/EntryStack.java b/api/src/main/java/me/shedaniel/rei/api/ingredient/EntryStack.java index b817c33b6..6f4b7294f 100644 --- a/api/src/main/java/me/shedaniel/rei/api/ingredient/EntryStack.java +++ b/api/src/main/java/me/shedaniel/rei/api/ingredient/EntryStack.java @@ -172,15 +172,14 @@ public interface EntryStack<T> extends TextRepresentable, Renderer { @Deprecated public static final Settings<Function<EntryStack<?>, List<Component>>> TOOLTIP_APPEND_EXTRA = new Settings<>(stack -> Collections.emptyList()); - private static short nextId; private R defaultValue; private short id; @ApiStatus.Internal public Settings(R defaultValue) { this.defaultValue = defaultValue; - this.id = nextId++; SETTINGS.add(this); + this.id = (short) SETTINGS.indexOf(this); } @ApiStatus.Internal diff --git a/api/src/main/java/me/shedaniel/rei/api/registry/screen/OverlayDecider.java b/api/src/main/java/me/shedaniel/rei/api/registry/screen/OverlayDecider.java index f23ed695a..abcc7b35c 100644 --- a/api/src/main/java/me/shedaniel/rei/api/registry/screen/OverlayDecider.java +++ b/api/src/main/java/me/shedaniel/rei/api/registry/screen/OverlayDecider.java @@ -59,11 +59,11 @@ public interface OverlayDecider extends Comparable<OverlayDecider> { } /** - * Checks if mouse is inside the overlay + * Checks if a point is inside the overlay, return false for indicating that REI should not display anything here. * * @param mouseX mouse's x coordinates * @param mouseY mouse's y coordinates - * @return whether mouse is inside the overlay + * @return whether a point is inside the overlay */ default InteractionResult isInZone(double mouseX, double mouseY) { return PASS; diff --git a/api/src/main/java/me/shedaniel/rei/api/registry/screen/ScreenRegistry.java b/api/src/main/java/me/shedaniel/rei/api/registry/screen/ScreenRegistry.java index 4484e5050..d89f95169 100644 --- a/api/src/main/java/me/shedaniel/rei/api/registry/screen/ScreenRegistry.java +++ b/api/src/main/java/me/shedaniel/rei/api/registry/screen/ScreenRegistry.java @@ -66,19 +66,36 @@ public interface ScreenRegistry extends Reloadable { List<OverlayDecider> getDeciders(); /** - * Registers an overlay decider + * Registers an overlay decider, may be an instance of {@link DisplayBoundsProvider} for providing + * the boundaries of a screen. * * @param decider the decider to register */ void registerDecider(OverlayDecider decider); + /** + * Registers a provider for getting the focused stack by the mouse. + * + * @param provider the provider to register + */ void registerFocusedStack(FocusedStackProvider provider); /** - * Gets the bounds of the overlay. + * Returns the main center screen bounds returned, provided by deciders. + * + * @param screen the screen to check + * @param <T> the type of screen + * @return the main center screen bounds, may be an empty {@link Rectangle} if there are no providers + */ + <T extends Screen> Rectangle getScreenBounds(T screen); + + /** + * Returns the bounds of the overlay, provided by deciders. * - * @param screen the current screen - * @return the left bounds + * @param location the side of the overlay + * @param screen the screen to check + * @param <T> the type of screen + * @return the overlay bounds decided by the {@code location} */ <T extends Screen> Rectangle getOverlayBounds(DisplayPanelLocation location, T screen); @@ -130,5 +147,13 @@ public interface ScreenRegistry extends Reloadable { */ <T extends Screen> void registerClickArea(Class<? extends T> screenClass, ClickArea<T> area); + /** + * Handles the click area, returns an optional collection of category identifiers. + * + * @param screenClass the class of the screen + * @param context the click area context + * @param <T> the type of screen + * @return the collection of category identifiers, may be null if there are no click area handlers. + */ @Nullable <T extends Screen> Set<ResourceLocation> handleClickArea(Class<T> screenClass, ClickArea.ClickAreaContext<T> context); } |
