Skip to content

Commit

Permalink
added REI/EMI support
Browse files Browse the repository at this point in the history
  • Loading branch information
SrRapero720 committed Apr 9, 2024
1 parent aaa11e0 commit 0f2ab11
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 24 deletions.
7 changes: 6 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@ dependencies {

// DEPENDENCIES
implementation fg.deobf("org.embeddedt:embeddium-${mcversion}:${embeddiumversion}")
implementation fg.deobf("curse.maven:jei-238222:${jeiversion}")
compileOnly fg.deobf("curse.maven:jei-238222:${jeiversion}")
compileOnly fg.deobf("curse.maven:roughly-enough-items-310111:${reiversion}")
compileOnly fg.deobf("curse.maven:cloth-config-348521:4973441")
compileOnly fg.deobf("curse.maven:architectury-api-419699:5084452")

implementation fg.deobf("curse.maven:emi-580555:${emiversion}")
runtimeOnly fg.deobf("curse.maven:textrues-embeddium-options-910506:${embeddiumoptionsversion}")
runtimeOnly fg.deobf("curse.maven:oculus-581495:${oculusversion}")

Expand Down
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
- 🐛 This avoid invisible models/textures for mods with some weird reliance on MC resources.
- [🐛] Fix wrong AVG display on initial games
- 🛠️ AVG was also tweaked to store 18 values instead of 14
- [🔥] Added EMI/REI support for "Hide JEI until searching" feature
- [🛠️] Revoked license (now is ARR)


Expand Down
2 changes: 2 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ zumerange=[0.18,0.19)
embeddiumoptionsversion=5069200
oculusversion=5108615
jeiversion=4712868
emiversion=5096955
reiversion=4951142


################
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/me/srrapero720/embeddiumplus/EmbyConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ public class EmbyConfig {
public static volatile double darknessFullMoonBrightCache;

// PERFORMANCE;
public static final BooleanValue hideJREI;
public static final BooleanValue hideJREMI;
public static final BooleanValue fontShadows;
public static final BooleanValue fastChests;
public static final BooleanValue fastBeds;
public static volatile boolean hideJREICache;
public static volatile boolean hideJREMICache;
public static volatile boolean fontShadowsCache;
public static volatile boolean fastChestsCache;
public static volatile boolean fastBedsCache;
Expand Down Expand Up @@ -232,7 +232,7 @@ public class EmbyConfig {
// embeddiumplus -> performance
BUILDER.push("performance");

hideJREI = BUILDER
hideJREMI = BUILDER
.comment("Toggles JREI item rendering until searching", "Increases performance a little bit and cleans your screen when you don't want to use it")
.define("hideJREI", false);

Expand Down Expand Up @@ -372,7 +372,7 @@ public static void updateCache(ModConfigEvent ignored) {
darknessNewMoonBrightCache = darknessNewMoonBright.get();
darknessFullMoonBrightCache = darknessFullMoonBright.get();

hideJREICache = hideJREI.get();
hideJREMICache = hideJREMI.get();
fontShadowsCache = fontShadows.get();
fastChestsCache = fastChests.get();
fastBedsCache = fastBeds.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,12 +162,12 @@ public static void setPerformanceOptions(List<OptionGroup> groups, SodiumOptions
.setControl(TickBoxControl::new)
.setBinding(
(options, value) -> {
EmbyConfig.hideJREI.set(value);
EmbyConfig.hideJREICache = value;
EmbyConfig.hideJREMI.set(value);
EmbyConfig.hideJREMICache = value;
},
(options) -> EmbyConfig.hideJREICache)
(options) -> EmbyConfig.hideJREMICache)
.setImpact(OptionImpact.LOW)
.setEnabled(EmbyTools.isModInstalled("jei"))
.setEnabled(EmbyTools.isModInstalled("jei") || EmbyTools.isModInstalled("roughlyenoughitems") || EmbyTools.isModInstalled("emi"))
.build();

builder.add(fontShadow);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ public void onLoad(String s) {}
@Override
public boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
if (targetClassName.contains("zume.Zume") && !EmbyTools.isModInstalled("zume")) return false;
if (targetClassName.contains("jei.Jei") && !EmbyTools.isModInstalled("jei")) return false;
if (targetClassName.contains("jei_rei_emi.Jei") && !EmbyTools.isModInstalled("jei")) return false;
if (targetClassName.contains("jei_rei_emi.Rei") && !EmbyTools.isModInstalled("roughlyenoughitems")) return false;
if (targetClassName.contains("jei_rei_emi.Emi") && !EmbyTools.isModInstalled("emi")) return false;

// go ahead
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package me.srrapero720.embeddiumplus.mixins.impl.jei_rei_emi;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import dev.emi.emi.runtime.EmiDrawContext;
import dev.emi.emi.screen.EmiScreenManager;
import dev.emi.emi.screen.widget.EmiSearchWidget;
import me.srrapero720.embeddiumplus.EmbyConfig;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Pseudo;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.Iterator;
import java.util.List;

@Mixin(value = EmiScreenManager.class, remap = false)
@Pseudo
public class EmiOverlayMixin {
@Shadow public static EmiSearchWidget search;
@Unique private static int checkedPos = 0;

@WrapOperation(method = "render", at = @At(value = "INVOKE", target = "Ldev/emi/emi/screen/EmiScreenManager$SidebarPanel;render(Ldev/emi/emi/runtime/EmiDrawContext;IIF)V"))
private static void inject$renderStackOverlay(EmiScreenManager.SidebarPanel instance, EmiDrawContext totalPages, int i, int context, float mouseX, Operation<Void> original) {
if (!EmbyConfig.hideJREMICache) {
original.call(instance, totalPages, i, context, mouseX);
} else {
if (checkedPos == 1 && search.getValue().isEmpty()) {
checkedPos++;
return;
}
original.call(instance, totalPages, i, context, mouseX);
checkedPos++;
}
}

@Inject(method = "render", at = @At("RETURN"))
private static void inject$renderCleanup(EmiDrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
checkedPos = 0;
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package me.srrapero720.embeddiumplus.mixins.impl.jei;
package me.srrapero720.embeddiumplus.mixins.impl.jei_rei_emi;

import me.srrapero720.embeddiumplus.EmbyConfig;
import mezz.jei.gui.elements.GuiIconToggleButton;
Expand All @@ -13,14 +13,15 @@
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(value = IngredientListOverlay.class, remap = false)
@Pseudo
public class JeiOverlayMixin {
@Shadow @Final private GuiTextFieldFilter searchField;
@Shadow @Final private GuiIconToggleButton configButton;
@Shadow @Final private ScreenPropertiesCache screenPropertiesCache;

@Inject(method = "drawScreen", at = @At(value = "INVOKE", target = "Lmezz/jei/gui/overlay/IngredientGridWithNavigation;draw(Lnet/minecraft/client/Minecraft;Lnet/minecraft/client/gui/GuiGraphics;IIF)V"), cancellable = true)
public void inject$renderOverlay(Minecraft minecraft, GuiGraphics guiGraphics, int mouseX, int mouseY, float partialTicks, CallbackInfo ci) {
if (!EmbyConfig.hideJREICache) return;
if (!EmbyConfig.hideJREMICache) return;

String value = searchField.getValue();
if (value.isEmpty()) {
Expand All @@ -33,7 +34,7 @@ public class JeiOverlayMixin {

@Inject(method = "drawTooltips", at = @At(value = "HEAD"), cancellable = true)
public void inject$renderOverlay(Minecraft minecraft, GuiGraphics guiGraphics, int mouseX, int mouseY, CallbackInfo ci) {
if (!EmbyConfig.hideJREICache) return;
if (!EmbyConfig.hideJREMICache) return;

String value = searchField.getValue();
if (value.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package me.srrapero720.embeddiumplus.mixins.impl.jei_rei_emi;

import com.llamalad7.mixinextras.injector.wrapoperation.Operation;
import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation;
import me.shedaniel.rei.api.client.gui.widgets.Widget;
import me.shedaniel.rei.impl.client.REIRuntimeImpl;
import me.shedaniel.rei.impl.client.gui.ScreenOverlayImpl;
import me.shedaniel.rei.impl.client.gui.dragging.CurrentDraggingStack;
import me.shedaniel.rei.impl.client.gui.widget.entrylist.EntryListWidget;
import me.shedaniel.rei.impl.client.gui.widget.search.OverlaySearchField;
import me.srrapero720.embeddiumplus.EmbyConfig;
import net.minecraft.client.gui.GuiGraphics;
import org.spongepowered.asm.mixin.*;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.ArrayList;
import java.util.List;

@Mixin(value = ScreenOverlayImpl.class, priority = 500, remap = false)
@Pseudo
public class ReiOverlayMixin {
@Unique private EntryListWidget embPlus$entryListWidget;

@WrapOperation(method = "init", at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z"))
public boolean redirect$addOnList(List<Widget> instance, Object e, Operation<Boolean> original) {
if (e instanceof EntryListWidget listWidget) {
embPlus$entryListWidget = listWidget;
return false;
} else {
return original.call(instance, e);
}
}

@Inject(method = "renderWidgets", at = @At("TAIL"))
public void inject$bottom(GuiGraphics graphics, int mouseX, int mouseY, float delta, CallbackInfo ci) {
if (EmbyConfig.hideJREMICache && REIRuntimeImpl.getSearchField().getText().isEmpty()) return;
embPlus$entryListWidget.render(graphics, mouseX, mouseY, delta);
}
}
4 changes: 2 additions & 2 deletions src/main/resources/assets/embeddiumplus/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,8 @@
"embeddium.plus.options.fog.desc": "If disabled, removed fog effect only in the overworld",
"embeddium.plus.options.fontshadow.title": "Font Shadows",
"embeddium.plus.options.fontshadow.desc": "If disabled, text will stop rendering shadows giving a flat style.\nIncreases FPS depending of how much text is on the screen, specially with BetterF3 mods",
"embeddium.plus.options.jei.title": "Hide JEI Until Searching",
"embeddium.plus.options.jei.desc": "If enabled, JEI item list will be hidden unless you search for something. Press space to search for everything.",
"embeddium.plus.options.jei.title": "Hide JEI/REI/EMI Until Searching",
"embeddium.plus.options.jei.desc": "If enabled, JEI/REI/EMI item list will be hidden unless you search for something. Press space to search for everything.",
"embeddium.plus.options.screen.title": "Fullscreen Mode",
"embeddium.plus.options.screen.desc": "Windowed - the game will display in a small window.\nBorderless - the game will be fullscreened, and locked to your monitor's refresh rate, but allow you to tab out easily.\nFullscreen - the game will display in native fullscreen mode.",
"embeddium.plus.options.screen.borderless": "Borderless",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/embeddiumplus/lang/es_mx.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@
"embeddium.plus.options.fog.desc": "Si se desactiva, la niebla no se mostrara en la superficie",
"embeddium.plus.options.fontshadow.title": "Sombra en los textos",
"embeddium.plus.options.fontshadow.desc": "Si se desactiva, los textos dejaran de renderizar sombras.\nIncrementa el rendimiento en menus con mucho texto, como el BetterF3",
"embeddium.plus.options.jei.title": "Ocultar JEI hasta buscar",
"embeddium.plus.options.jei.desc": "Si se desactiva, los items en el JEI se ocultan hasta que busques algo. Escribe un espacio para buscar cualquier cosa",
"embeddium.plus.options.jei.title": "Ocultar JEI/REI/EMI hasta buscar",
"embeddium.plus.options.jei.desc": "Si se desactiva, los items en el JEI/REI/EMI se ocultan hasta que busques algo. Escribe un espacio para buscar cualquier cosa",
"embeddium.plus.options.screen.title": "Pantalla Completa",
"embeddium.plus.options.screen.desc": "Ventana - el juego se mostrara en una ventana.\nSin Bordes - el juego se pondra en pantalla completa pero en modo ventana, y bloqueado a los hercios de tu sistema, pero te deja cambiar de ventanas mas rapido.\nPantalla Completa - el juego se mostrara en pantalla completa nativamente",
"embeddium.plus.options.screen.borderless": "Sin Bordes",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/embeddiumplus/lang/fr_fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@
"embeddium.plus.options.fadein.desc": "Contrôle à quel vitesse se fait le fondu enchaîné. Aucune perte de performance, Détaillés prend simplement plus de temps, mais semble un peu plus cool. Ne marche pas actuellement.",
"embeddium.plus.options.fog.title": "Active le brouillard",
"embeddium.plus.options.fog.desc": "Désactive tout le brouillard dans l'Overworld",
"embeddium.plus.options.jei.title": "Cache le JEI jusqu'a sa recherche",
"embeddium.plus.options.jei.desc": "Désactive les items JEI sauf si on cherche quelque chose. Appuyez sur Espace pour chercher.",
"embeddium.plus.options.jei.title": "Cache le JEI/REI/EMI jusqu'a sa recherche",
"embeddium.plus.options.jei.desc": "Désactive les items JEI/REI/EMI sauf si on cherche quelque chose. Appuyez sur Espace pour chercher.",
"embeddium.plus.options.screen.title": "Mode Plein Ecran",
"embeddium.plus.options.screen.desc": "Fenêtré - le jeu s'affichera dans une petite fenêtre.\nSans bordure - le jeu sera en plein écran et verrouillé au taux de rafraîchissement de votre moniteur, mais vous permettra de passer facilement d'une fenêtre à l'autre.\nPlein écran - le jeu s'affichera en mode plein écran natif",
"embeddium.plus.options.screen.borderless": "Sans bordure",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/embeddiumplus/lang/ru_ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"embeddium.plus.options.fog.desc": "Если отключено, тумана удаляется только в Надземном мире.",
"embeddium.plus.options.fontshadow.title": "Тени шрифта",
"embeddium.plus.options.fontshadow.desc": "Если отключить, текст перестанет отображать тени, получая плоский стиль.\nУвеличивает частоту кадров в секунду в зависимости от того, сколько текста находится на экране.",
"embeddium.plus.options.jei.title": "Скрыть JEI до поиска",
"embeddium.plus.options.jei.desc": "Скрывает предметы JEI до того, как вы введёте поисковой запрос. Нажмите пробел, чтобы показать все предметы.",
"embeddium.plus.options.jei.title": "Скрыть JEI/REI/EMI до поиска",
"embeddium.plus.options.jei.desc": "Скрывает предметы JEI/REI/EMI до того, как вы введёте поисковой запрос. Нажмите пробел, чтобы показать все предметы.",
"embeddium.plus.options.screen.title": "Полноэкранный режим",
"embeddium.plus.options.screen.desc": "Оконный — игра будет отображаться в маленьком окне.\nБезрамочный — игра будет отображаться в полноэкранном режиме и привязана к частоте обновления вашего монитора, но позволит вам легко переключаться между вкладками.\nПолноэкранный — игра будет отображаться в обычном полноэкранном режиме.",
"embeddium.plus.options.screen.borderless": "Безрамочный",
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/assets/embeddiumplus/lang/zh_cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@
"embeddium.plus.options.fog.desc": "禁用后,移除世界中的所有迷雾效果。",
"embeddium.plus.options.fontshadow.title": "字体阴影",
"embeddium.plus.options.fontshadow.desc": "禁用后,文本将停止渲染阴影,显得扁平化。\nFPS能提高多少,取决于屏幕上有多少文本,特别是安装了更好的F3(BetterF3)模组后。",
"embeddium.plus.options.jei.title": "不在搜索时隐藏JEI",
"embeddium.plus.options.jei.desc": "启用后,会隐藏JEI物品列表中的物品,直到你搜索了某些内容。输入空格可以搜索到所有内容。",
"embeddium.plus.options.jei.title": "不在搜索时隐藏JEI/REI/EMI",
"embeddium.plus.options.jei.desc": "启用后,会隐藏JEI/REI/EMI物品列表中的物品,直到你搜索了某些内容。输入空格可以搜索到所有内容。",
"embeddium.plus.options.screen.title": "全屏模式",
"embeddium.plus.options.screen.desc": "窗口化 - 游戏将在一个小窗口中显示。\n无边框 - 游戏将全屏显示、将帧率锁定到你显示器的刷新率,但允许你随便切换到其他窗口。\n全屏 - 游戏将以原生全屏模式显示。",
"embeddium.plus.options.screen.borderless": "无边框",
Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/embeddiumplus.mixin.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@
"fontshadow.FontMixin",
"fontshadow.FontMixin$StringRenderOutputMixin",
"fps.GpuUsageMixin",
"jei.JeiOverlayMixin",
"jei_rei_emi.EmiOverlayMixin",
"jei_rei_emi.JeiOverlayMixin",
"jei_rei_emi.ReiOverlayMixin",
"language.LanguageMixin",
"togglefog.FogMixin",
"zume.ZumeKeyBindsForgeMixin"
Expand Down

0 comments on commit 0f2ab11

Please sign in to comment.