Skip to content

Commit

Permalink
Fix EMI crash if EmiSearchWidget is not present, Closes CyclopsMC/Int…
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Oct 28, 2024
1 parent b7ae63b commit f3cfa11
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.cyclops.integratedterminalscompat.modcompat.emi;

import dev.emi.emi.api.EmiApi;
import dev.emi.emi.api.EmiEntrypoint;
import dev.emi.emi.api.EmiPlugin;
import dev.emi.emi.api.EmiRegistry;
Expand Down Expand Up @@ -87,7 +88,7 @@ public void onTerminalStorageScreenSize(TerminalStorageScreenSizeEvent event) {
public void onSearchFieldUpdated(TerminalStorageTabClientSearchFieldUpdateEvent event) {
// Copy the terminal search box contents into the JEI search box.
if (!EmiScreenManager.isDisabled() && TerminalButtonItemStackCraftingGridSearchSync.isSearchSynced(event.getClientTab())) {
EmiScreenManager.search.setValue(event.getSearchString() + "");
EmiApi.setSearchText(event.getSearchString() + "");
}
}

Expand All @@ -96,11 +97,11 @@ public void onKeyTyped(ScreenEvent.KeyReleased.Post event) {
// Copy the JEI search box contents into the terminal search box.
if (event.getScreen() instanceof ContainerScreenTerminalStorage) {
ContainerScreenTerminalStorage<?, ?> gui = ((ContainerScreenTerminalStorage<?, ?>) event.getScreen());
if (!EmiScreenManager.isDisabled() && EmiScreenManager.search.isFocused()) {
if (!EmiScreenManager.isDisabled() && EmiApi.isSearchFocused()) {
gui.getSelectedClientTab().ifPresent(tab -> {
if (TerminalButtonItemStackCraftingGridSearchSync.isSearchSynced(tab)) {
WidgetTextFieldExtended fieldSearch = gui.getFieldSearch();
fieldSearch.setValue(EmiScreenManager.search.getValue());
fieldSearch.setValue(EmiApi.getSearchText());
tab.setInstanceFilter(gui.getMenu().getSelectedChannel(), fieldSearch.getValue() + "");
}
});
Expand Down

0 comments on commit f3cfa11

Please sign in to comment.