Skip to content

Commit

Permalink
Merge branch '1.19.4' into 1.19.3
Browse files Browse the repository at this point in the history
  • Loading branch information
emilyploszaj committed Nov 3, 2024
2 parents 5b2e73e + e26b4ba commit 246bd9c
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 33 deletions.
14 changes: 7 additions & 7 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
### Additions
* Added support for quoting in search queries and OR splitting up words rather than needing a space
* Added visibility options for the EMI config and recipe tree buttons
* EMI config button now is visible by default when toggled, to prevent people from accidentally hiding the mod without knowing how to undo it

### Tweaks
* Tweak a small few recipe IDs to be synthetic when they previously weren't
* Updated config UI on modern versions to be more similar to vanilla changes
* Tweaked "default stack" bind to also toggle during resolution
* EMI visibility toast is now only shown when help level is verbose, due to other features preventing accidental hiding
* EMI config enum selection screen now is consistent with the rest of the config screen on later versions

### Fixes
* Added additional dev mode nags for synthetic IDs #730
* Added further safety around recipe baking to prevent self mutation from affecting EMI significantly #776
* Further update JEI integration with null backgrounds #755
* Fixed JEI dependency on 1.19 versions #780
* Fixed stack default bind not toggling in recipe tree
* #689
9 changes: 1 addition & 8 deletions forge/src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,4 @@ authors = "Emi"
description = '''
A featureful and accessible item and recipe viewer
'''
logoFile = "icon.png"

[[dependencies.emi]]
modId = "jei"
mandatory = false
versionRange = "[15.20.0.0,)"
ordering = "BEFORE"
side = "CLIENT"
logoFile = "icon.png"
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ minecraft_version=1.19.3
enabled_platforms=fabric,forge

archives_base_name=emi
mod_version=1.1.17
mod_version=1.1.18
maven_group=dev.emi

architectury_version=4.9.83
Expand Down
4 changes: 2 additions & 2 deletions xplat/src/main/java/dev/emi/emi/api/widget/SlotWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,8 +282,8 @@ private boolean slotInteraction(Function<EmiBind, Boolean> function) {
EmiRecipe recipe = getRecipe();
if (canResolve()) {
if (function.apply(EmiConfig.defaultStack)) {
if (BoM.isDefaultRecipe(RecipeScreen.resolve, recipe)) {
BoM.removeRecipe(RecipeScreen.resolve, recipe);
if (BoM.isDefaultRecipe(getStack(), recipe)) {
BoM.removeRecipe(getStack(), recipe);
} else {
BoM.addRecipe(RecipeScreen.resolve, recipe);
}
Expand Down
35 changes: 35 additions & 0 deletions xplat/src/main/java/dev/emi/emi/config/ButtonVisibility.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package dev.emi.emi.config;

import dev.emi.emi.EmiPort;
import net.minecraft.text.Text;

public enum ButtonVisibility implements ConfigEnum {
AUTO("auto"),
SHOWN("shown"),
HIDDEN("hidden"),
;

private final String name;

private ButtonVisibility(String name) {
this.name = name;
}

public boolean resolve(boolean fallback) {
return switch (this) {
case AUTO -> fallback;
case SHOWN -> true;
case HIDDEN -> false;
};
}

@Override
public String getName() {
return name;
}

@Override
public Text getText() {
return EmiPort.translatable("emi.button_visibility." + name);
}
}
8 changes: 8 additions & 0 deletions xplat/src/main/java/dev/emi/emi/config/EmiConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ public class EmiConfig {
@ConfigValue("ui.empty-search-sidebar-focus")
public static SidebarType emptySearchSidebarFocus = SidebarType.NONE;

@Comment("Whether the EMI config button should be visible.")
@ConfigValue("ui.emi-config-button-visibility")
public static ButtonVisibility emiConfigButtonVisibility = ButtonVisibility.SHOWN;

@Comment("Whether the recipe tree button should be visible.")
@ConfigValue("ui.recipe-tree-button-visibility")
public static ButtonVisibility recipeTreeButtonVisibility = ButtonVisibility.AUTO;

@ConfigGroup("ui.recipe-screen")
@Comment("The maximum height the recipe screen will grow to be if space is available in pixels.")
@ConfigValue("ui.maximum-recipe-screen-height")
Expand Down
2 changes: 0 additions & 2 deletions xplat/src/main/java/dev/emi/emi/screen/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,6 @@ public void render(MatrixStack raw, int mouseX, int mouseY, float delta) {
this.renderBackgroundTexture(-100);
list.render(context.raw(), mouseX, mouseY, delta);
super.render(context.raw(), mouseX, mouseY, delta);
list.render(context.raw(), mouseX, mouseY, delta);
super.render(context.raw(), mouseX, mouseY, delta);
if (list.getHoveredEntry() != null) {
EmiRenderHelper.drawTooltip(this, context, list.getHoveredEntry().getTooltip(mouseX, mouseY), mouseX, mouseY, Math.min(width / 2 - 16, maxWidth));
}
Expand Down
44 changes: 31 additions & 13 deletions xplat/src/main/java/dev/emi/emi/screen/EmiScreenManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,17 @@ public static EmiStackInteraction getHoveredStack(int mouseX, int mouseY, boolea
return getHoveredStack(mouseX, mouseY, notClick, false);
}

public static int getDebugTextX() {
int x = 4;
if (emi.visible) {
x = Math.max(4, 4 + 22);
}
if (tree.visible) {
x = Math.max(4, 4 + 22 + 22);
}
return x;
}

public static EmiStackInteraction getHoveredStack(int mouseX, int mouseY, boolean notClick,
boolean ignoreLastHoveredCraftable) {
if (client.currentScreen == null) {
Expand Down Expand Up @@ -591,35 +602,38 @@ public static void render(EmiDrawContext context, int mouseX, int mouseY, float
return;
}
boolean visible = !isDisabled();
emi.visible = visible;
tree.visible = visible;
emi.visible = EmiConfig.emiConfigButtonVisibility.resolve(visible);
tree.visible = EmiConfig.recipeTreeButtonVisibility.resolve(visible);
for (SidebarPanel panel : panels) {
panel.updateWidgetVisibility();
}
renderWidgets(context, mouseX, mouseY, delta, base);
if (isDisabled()) {
int screenHeight = base.screen().height;
if (!EmiReloadManager.isLoaded()) {
int reloadInfoX = getDebugTextX();
if (EmiReloadManager.getStatus() == -1) {
context.drawTextWithShadow(EmiPort.translatable("emi.reloading.error"), 4, screenHeight - 16);
context.drawTextWithShadow(EmiPort.translatable("emi.reloading.error"), reloadInfoX, screenHeight - 16);
} else if (EmiReloadManager.getStatus() == 0) {
context.drawTextWithShadow(EmiPort.translatable("emi.reloading.waiting"), 4, screenHeight - 16);
context.drawTextWithShadow(EmiPort.translatable("emi.reloading.waiting"), reloadInfoX, screenHeight - 16);
} else {
context.drawTextWithShadow(EmiPort.translatable("emi.reloading"), 4, screenHeight - 16);
context.drawTextWithShadow(EmiReloadManager.reloadStep, 4, screenHeight - 26);
context.drawTextWithShadow(EmiPort.translatable("emi.reloading"), reloadInfoX, screenHeight - 16);
context.drawTextWithShadow(EmiReloadManager.reloadStep, reloadInfoX, screenHeight - 26);
if (System.currentTimeMillis() > EmiReloadManager.reloadWorry) {
context.drawTextWithShadow(EmiPort.translatable("emi.reloading.worry"), 4, screenHeight - 36);
context.drawTextWithShadow(EmiPort.translatable("emi.reloading.worry"), reloadInfoX, screenHeight - 36);
}
}
} else {
}
EmiProfiler.pop();
lastHoveredCraftable = null;
return;
} else if (EmiRecipes.activeWorker != null) {
context.drawTextWithShadow(EmiPort.translatable("emi.reloading.still_baking_recipes"), 48, base.screen().height - 16);
int bakingX = getDebugTextX();
context.drawTextWithShadow(EmiPort.translatable("emi.reloading.still_baking_recipes"), bakingX, base.screen().height - 16);
} else {
renderDevMode(context, mouseX, mouseY, delta, base);
}
renderWidgets(context, mouseX, mouseY, delta, base);
EmiProfiler.push("sidebars");
for (SidebarPanel panel : panels) {
panel.render(context, mouseX, mouseY, delta);
Expand Down Expand Up @@ -764,13 +778,14 @@ private static void renderDevMode(EmiDrawContext context, int mouseX, int mouseY
int color = 0xFFFFFF;
Text title = EmiPort.literal("EMI Dev Mode");
int off = -16;
int devTextX = getDebugTextX();
if (!EmiReloadLog.warnings.isEmpty()) {
color = 0xFF0000;
off = -11;
String warnCount = EmiReloadLog.warningCount + " Warnings";
context.drawTextWithShadow(EmiPort.literal(warnCount), 48, screen.height - 21, color);
context.drawTextWithShadow(EmiPort.literal(warnCount), devTextX, screen.height - 21, color);
int width = Math.max(client.textRenderer.getWidth(title), client.textRenderer.getWidth(warnCount));
if (mouseX >= 48 && mouseX < width + 48 && mouseY > screen.height - 28) {
if (mouseX >= devTextX && mouseX < width + devTextX && mouseY > screen.height - 28) {
screen.renderTooltip(context.raw(), Stream.concat(Stream.of(" EMI detected some issues, see log for full details"),
EmiReloadLog.warnings.stream()).map(s -> {
String a = s;
Expand All @@ -782,7 +797,7 @@ private static void renderDevMode(EmiDrawContext context, int mouseX, int mouseY
.collect(Collectors.toList()), 0, 20);
}
}
context.drawTextWithShadow(title, 48, screen.height + off, color);
context.drawTextWithShadow(title, devTextX, screen.height + off, color);
}
}

Expand Down Expand Up @@ -1279,9 +1294,12 @@ public static boolean recipeInteraction(EmiRecipe recipe, Function<EmiBind, Bool
public static void toggleVisibility(boolean notify) {
EmiConfig.enabled = !EmiConfig.enabled;
EmiConfig.writeConfig();
if (notify && !EmiConfig.enabled && EmiConfig.helpLevel.has(HelpLevel.NORMAL)) {
if (notify && !EmiConfig.enabled && EmiConfig.helpLevel.has(HelpLevel.VERBOSE)) {
client.getToastManager().add(new DisabledToast());
}
if (EmiConfig.enabled) {
forceRecalculate();
}
}

private static boolean give(EmiStack stack, int amount, int mode) {
Expand Down
5 changes: 5 additions & 0 deletions xplat/src/main/resources/assets/emi/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@
"emi.recipe_book_action.default": "Default",
"emi.recipe_book_action.toggle_craftables": "Toggle Craftables",
"emi.recipe_book_action.toggle_visibility": "Toggle Visibility",
"emi.button_visibility.auto": "Auto",
"emi.button_visibility.shown": "Shown",
"emi.button_visibility.hidden": "Hidden",

"config.emi.group.general": "General",
"config.emi.group.general.search": "Search",
Expand Down Expand Up @@ -147,6 +150,8 @@
"config.emi.ui.miscraft_prevention": "Miscraft Prevention",
"config.emi.ui.fluid_unit": "Fluid Unit",
"config.emi.ui.show_cost_per_batch": "Show Cost Per Batch",
"config.emi.ui.emi_config_button_visibility": "EMI Config Button Visibility",
"config.emi.ui.recipe_tree_button_visibility": "Recipe Tree Button Visibility",
"config.emi.ui.recipe_default_button": "Recipe Default Button",
"config.emi.ui.recipe_tree_button": "Recipe Tree Button",
"config.emi.ui.recipe_fill_button": "Recipe Fill Button",
Expand Down

0 comments on commit 246bd9c

Please sign in to comment.