Compare commits

..
Author SHA1 Message Date
Jason Mitchell 0e34840c21 More robust IMC handling (#371)
* Complain if IMC adds a handler/catalyst for a handlerID that doesn't exist.

* Look at the right maps this time

* Don't show matches, only misses
2023-04-16 21:22:09 +02:00
CaedisandMartin Robertz a12fadb10d Add option to have the search widget under item panel (#364)
* Add option to have the search widget under item panel

* update bs+sa

* Make heights consistent

---------

Co-authored-by: Martin Robertz <[email protected]>
2023-04-01 23:16:18 +02:00
4 changed files with 43 additions and 16 deletions

No files matched your search

+12 -14
View File
@@ -166,31 +166,29 @@ public class ItemPanel extends PanelWidget {
}
protected int resizeFooter(GuiContainer gui) {
if (!(NEIClientConfig.showItemQuantityWidget() || !NEIClientConfig.isSearchWidgetCentered())) return 0;
final int BUTTON_SIZE = 16;
if (!NEIClientConfig.showItemQuantityWidget() && NEIClientConfig.isSearchWidgetCentered()) return 0;
final int BUTTON_SIZE = 20;
more.w = less.w = BUTTON_SIZE;
quantity.h = BUTTON_SIZE;
if (NEIClientConfig.isSearchWidgetCentered()) {
more.h = less.h = BUTTON_SIZE;
more.x = x + w - BUTTON_SIZE;
more.h = less.h = quantity.h = BUTTON_SIZE;
more.y = less.y = quantity.y = y + h - BUTTON_SIZE;
less.x = x;
quantity.x = x + BUTTON_SIZE + 2;
quantity.w = more.x - quantity.x - 2;
} else {
more.x = less.x;
more.y = y + h - BUTTON_SIZE;
more.h = less.h = BUTTON_SIZE / 2;
less.x = (int) (x + (w * 0.7));
less.y = more.y + more.h;
quantity.h = BUTTON_SIZE;
quantity.x = less.x + less.w + 1;
quantity.x = (int) (x + (w * 0.7)) + 3;
quantity.y = y + h - BUTTON_SIZE;
quantity.w = x + w - quantity.x;
quantity.w = (int) ((w * 0.3) - BUTTON_SIZE - 1);
more.h = less.h = BUTTON_SIZE / 2;
more.y = y + h - (more.h * 2);
less.x = more.x = quantity.x + quantity.w;
less.y = more.y + more.h;
}
return BUTTON_SIZE + 2;
@@ -126,12 +126,11 @@ public class LayoutStyleMinecraft extends LayoutStyle {
presetsPanel.y = 2;
presetsPanel.x = (gui.width - gui.xSize) / 2 + gui.xSize - presetsPanel.w;
searchField.h = 20;
if (NEIClientConfig.isSearchWidgetCentered()) {
searchField.h = 20;
searchField.w = 150;
searchField.x = (gui.width - searchField.w) / 2;
} else {
searchField.h = itemPanel.quantity.h;
searchField.w = (int) (itemPanel.w * (NEIClientConfig.showItemQuantityWidget() ? 0.7 : 1));
searchField.x = itemPanel.x;
}
@@ -282,6 +282,20 @@ public abstract class GuiRecipeTab extends Widget {
handlerMap.keySet().removeAll(handlerRemoverFromIMC);
handlerMap.putAll(handlerAdderFromIMC);
if (!handlerAdderFromIMC.isEmpty()) {
// If we're getting an IMC message, it probably means it should match
Set<String> handlerIds = new HashSet<>(handlerMap.keySet());
handlerAdderFromIMC.keySet().forEach(handlerName -> {
if (!handlerIds.contains(handlerName)) {
NEIClientConfig.logger.warn("Could not find a registered handlerID that matches " + handlerName);
handlerIds.forEach(handler -> {
if (handler.equalsIgnoreCase(handlerName)) {
NEIClientConfig.logger.warn(" -- Did you mean: " + handler);
}
});
}
});
}
NEIClientConfig.logger.info("Sending {}", NEIRegisterHandlerInfosEvent.class.getSimpleName());
MinecraftForge.EVENT_BUS.post(new NEIRegisterHandlerInfosEvent());
}
@@ -13,8 +13,10 @@ import java.nio.channels.ReadableByteChannel;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.minecraft.item.ItemStack;
@@ -227,6 +229,20 @@ public class RecipeCatalysts {
}
}
if (!catalystsAdderFromIMC.isEmpty()) {
// If we're getting an IMC message, it probably means it should match
Set<String> handlerIds = new HashSet<>(GuiRecipeTab.handlerMap.keySet());
catalystsAdderFromIMC.keySet().forEach(handlerName -> {
if (!handlerIds.contains(handlerName)) {
NEIClientConfig.logger.warn("Could not find a registered handlerID that matches " + handlerName);
handlerIds.forEach(handler -> {
if (handler.equalsIgnoreCase(handlerName)) {
NEIClientConfig.logger.warn(" -- Did you mean: " + handler);
}
});
}
});
}
for (Map.Entry<String, List<ItemStack>> entry : catalystsRemoverFromAPI.entrySet()) {
String handlerID = entry.getKey();
if (recipeCatalystMap.containsKey(handlerID)) {