aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/me/shedaniel/rei/api/DisplayHelper.java
blob: 8234c20b341246563e931c61fcfe1a31164c97de (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package me.shedaniel.rei.api;

import me.shedaniel.rei.RoughlyEnoughItemsCore;
import net.minecraft.util.ActionResult;

import java.awt.*;
import java.util.List;

import static net.minecraft.util.ActionResult.PASS;

public interface DisplayHelper {
    
    List<DisplayBoundsHandler> getSortedBoundsHandlers(Class screenClass);
    
    List<DisplayBoundsHandler> getAllBoundsHandlers();
    
    DisplayBoundsHandler getResponsibleBoundsHandler(Class screenClass);
    
    void registerBoundsHandler(DisplayBoundsHandler handler);
    
    BaseBoundsHandler getBaseBoundsHandler();
    
    public static interface DisplayBoundsHandler<T> {
        public static final Rectangle EMPTY = new Rectangle();
        
        Class getBaseSupportedClass();
        
        Rectangle getLeftBounds(T screen);
        
        Rectangle getRightBounds(T screen);
        
        default ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, T screen, Rectangle fullBounds) {
            return PASS;
        }
        
        default ActionResult isInZone(boolean isOnRightSide, double mouseX, double mouseY) {
            return PASS;
        }
        
        default Rectangle getItemListArea(Rectangle rectangle) {
            return new Rectangle(rectangle.x + 2, rectangle.y + 24, rectangle.width - 4, rectangle.height - (RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField ? 27 + 22 : 27));
        }
        
        default boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) {
            return false;
        }
        
        default float getPriority() {
            return 0f;
        }
    }
    
}