EMI

EMI

14M Downloads

[1.20.1] EmiExlusionAreas#getExclusion() does not handle null

CammiePone opened this issue ยท 1 comments

commented

EmiScreenBase#of() is able to return null, resulting in a lot of log spam whenever the mouse is scrolled on a screen that doesn't display EMI (such as the spell crafting screen from Arcanus)

public static List<Bounds> getExclusion(EmiScreenBase base) {
Screen screen = base.screen();
List<Bounds> list = Lists.newArrayList();
list.add(base.bounds());
// EMI buttons
list.add(new Bounds(0, screen.height - 22, base.bounds().left(), 22));
// Search bar
if (EmiScreenManager.search.isVisible()) {
list.add(new Bounds(EmiScreenManager.search.x - 1, EmiScreenManager.search.y - 1, EmiScreenManager.search.getWidth() + 2, EmiScreenManager.search.getHeight() + 2));
}
try {
if (fromClass.containsKey(screen.getClass())) {
for (EmiExclusionArea exclusion : fromClass.get(screen.getClass())) {
exclusion.addExclusionArea(screen, addBounds(list));
}
}
for (EmiExclusionArea exclusion : generic) {
exclusion.addExclusionArea(screen, addBounds(list));
}
} catch (Exception e) {
EmiLog.error("Exception thrown when adding exclusion areas");
e.printStackTrace();
}
return list;
}

public static EmiScreenBase of(Screen screen) {
if (screen instanceof HandledScreen hs) {
HandledScreenAccessor hsa = (HandledScreenAccessor) hs;
ScreenHandler sh = hs.getScreenHandler();
if (sh.slots != null && !sh.slots.isEmpty()) {
int extra = 0;
if (hs instanceof RecipeBookProvider provider) {
if (provider.getRecipeBookWidget().isOpen()) {
extra = 177;
}
}
Bounds bounds = new Bounds(hsa.getX() - extra, hsa.getY(), hsa.getBackgroundWidth() + extra, hsa.getBackgroundHeight());
return new EmiScreenBase(screen, bounds);
}
} else if (screen instanceof RecipeScreen rs) {
return new EmiScreenBase(rs, rs.getBounds());
}
return null;
}

This happens in both dev and production, and while minor, it can make reading logs for bugs a bit frustrating ^^;
latest.log

commented

That's not the issue in the log, but that underlying issue has been fixed