-
Notifications
You must be signed in to change notification settings - Fork 204
Fix the JEI green overlay appearing in cheat mode on phantom slots and fix the crafting station slots not having a hover overlay #2817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
d8daf53
Fix JEI green overlay appearing when in cheat mode
Zorbatron c130b96
Remove redundant cancel from mixin
Zorbatron a8b8795
Add combined method for both overlays
Zorbatron fe80e10
Move the overlay drawing to drawOverlay
Zorbatron 5f74b28
Mixin into ItemSlot apply the same fixes as done in our GTFluidSlot
Zorbatron f657da4
Only use `hoveringOverIngredient` since it returns the same object du…
Zorbatron 930a69f
oops
Zorbatron 8e25a8a
Merge branch 'master' into zb/jei-drag-overlay-fix
Zorbatron 4165a5a
Fix certain slots not having an overlay due to the theme not being a …
Zorbatron caf3334
Fix the crafting station input slots having both overlays at the same…
Zorbatron e3ce70d
Fix being able to ghost drag when you shouldn't be able to
Zorbatron 3c09c81
Merge branch 'master' into zb/jei-drag-overlay-fix
Zorbatron de75335
Remove mixin debug annotation
Zorbatron File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| package gregtech.api.util; | ||
|
|
||
| import net.minecraft.enchantment.EnchantmentData; | ||
|
|
||
| import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; | ||
| import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin; | ||
| import mezz.jei.Internal; | ||
|
|
||
| public class JEIUtil { | ||
|
|
||
| /** | ||
| * Check if the player is currently hovering over a valid ingredient for this slot. <br/> | ||
| * Will always return false is JEI is not installed. | ||
| */ | ||
| public static boolean hoveringOverIngredient(JeiGhostIngredientSlot<?> jeiGhostIngredientSlot) { | ||
| if (!Mods.JustEnoughItems.isModLoaded()) return false; | ||
| return ModularUIJeiPlugin.hoveringOverIngredient(jeiGhostIngredientSlot); | ||
| } | ||
|
|
||
| public static Object getBookStackIfEnchantment(Object ingredient) { | ||
| if (ingredient instanceof EnchantmentData enchantmentData) { | ||
| return Internal.getIngredientRegistry() | ||
| .getIngredientHelper(enchantmentData) | ||
| .getCheatItemStack(enchantmentData); | ||
| } | ||
|
|
||
| return ingredient; | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| package gregtech.mixins.mui2; | ||
|
|
||
| import gregtech.api.util.JEIUtil; | ||
|
|
||
| import net.minecraft.item.ItemStack; | ||
|
|
||
| import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin; | ||
| import com.cleanroommc.modularui.widgets.ItemSlot; | ||
| import com.llamalad7.mixinextras.injector.wrapmethod.WrapMethod; | ||
| import com.llamalad7.mixinextras.injector.wrapoperation.Operation; | ||
| import mezz.jei.gui.ghost.GhostIngredientDrag; | ||
| import org.jetbrains.annotations.NotNull; | ||
| import org.jetbrains.annotations.Nullable; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.Shadow; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Redirect; | ||
|
|
||
| // TODO: remove once MUI PR 146 merges into a release we use | ||
| @Mixin(value = ItemSlot.class, remap = false) | ||
| public abstract class ItemSlotMixin { | ||
|
|
||
| @Shadow | ||
| public abstract @Nullable ItemStack castGhostIngredientIfValid(@NotNull Object ingredient); | ||
|
|
||
| @Redirect(method = "draw", | ||
| at = @At(value = "INVOKE", | ||
| target = "Lcom/cleanroommc/modularui/integration/jei/ModularUIJeiPlugin;hasDraggingGhostIngredient()Z")) | ||
| private boolean onlyHighlightOnValidDrag() { | ||
| GhostIngredientDrag<?> ingredientDrag = ModularUIJeiPlugin.getGhostDrag(); | ||
| if (ingredientDrag == null) return false; | ||
| Object ingredient = ingredientDrag.getIngredient(); | ||
| if (ingredient == null) return false; | ||
| return castGhostIngredientIfValid(ingredient) != null; | ||
| } | ||
|
|
||
| @WrapMethod(method = "castGhostIngredientIfValid(Ljava/lang/Object;)Lnet/minecraft/item/ItemStack;") | ||
| public @Nullable ItemStack addSupportForEnchantedBooks(Object ingredient, Operation<ItemStack> original) { | ||
| return original.call(JEIUtil.getBookStackIfEnchantment(ingredient)); | ||
| } | ||
| } |
22 changes: 22 additions & 0 deletions
22
src/main/java/gregtech/mixins/mui2/ModularUIJeiPluginMixin.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| package gregtech.mixins.mui2; | ||
|
|
||
| import com.cleanroommc.modularui.integration.jei.JeiGhostIngredientSlot; | ||
| import com.cleanroommc.modularui.integration.jei.ModularUIJeiPlugin; | ||
| import mezz.jei.config.Config; | ||
| import org.spongepowered.asm.mixin.Mixin; | ||
| import org.spongepowered.asm.mixin.injection.At; | ||
| import org.spongepowered.asm.mixin.injection.Inject; | ||
| import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; | ||
|
|
||
| @Mixin(value = ModularUIJeiPlugin.class) | ||
| public class ModularUIJeiPluginMixin { | ||
|
|
||
| // TODO: remove this mixin when the fix from Brachy makes it into a release we use | ||
| @Inject(method = "hoveringOverIngredient", at = @At(value = "HEAD"), remap = false, cancellable = true) | ||
| private static void cancelIfCheatsOn(JeiGhostIngredientSlot<?> ingredientSlot, | ||
| CallbackInfoReturnable<Boolean> cir) { | ||
| if (Config.isCheatItemsEnabled()) { | ||
| cir.setReturnValue(false); | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.