-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
115 additions
and
4 deletions.
There are no files selected for viewing
This file contains 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 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
47 changes: 47 additions & 0 deletions
47
...java/com/cleanroommc/neverenoughanimations/core/mixin/jei/IngredientListOverlayMixin.java
This file contains 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,47 @@ | ||
package com.cleanroommc.neverenoughanimations.core.mixin.jei; | ||
|
||
import com.cleanroommc.neverenoughanimations.animations.OpeningAnimation; | ||
import mezz.jei.api.gui.IGuiProperties; | ||
import mezz.jei.gui.overlay.IngredientListOverlay; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraft.client.gui.inventory.GuiContainer; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
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.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import javax.annotation.Nullable; | ||
import java.awt.*; | ||
|
||
@Mixin(value = IngredientListOverlay.class, remap = false) | ||
public class IngredientListOverlayMixin { | ||
|
||
@Shadow | ||
@Nullable | ||
private IGuiProperties guiProperties; | ||
|
||
@Shadow private Rectangle displayArea; | ||
|
||
@Inject(method = "drawScreen", at = @At("HEAD")) | ||
public void drawScreenPre(Minecraft minecraft, int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { | ||
if (guiProperties != null) { | ||
GlStateManager.pushMatrix(); | ||
GuiScreen screen = Minecraft.getMinecraft().currentScreen; | ||
if (screen instanceof GuiContainer container) { | ||
float val = 1f - OpeningAnimation.getValue(container); | ||
if (val <= 0f) return; | ||
GlStateManager.translate(displayArea.width * val, 0, 0); | ||
} | ||
} | ||
} | ||
|
||
@Inject(method = "drawScreen", at = @At("TAIL")) | ||
public void drawScreenPost(Minecraft minecraft, int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { | ||
if (guiProperties != null) { | ||
GlStateManager.popMatrix(); | ||
} | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...in/java/com/cleanroommc/neverenoughanimations/core/mixin/jei/LeftAreaDispatcherMixin.java
This file contains 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,45 @@ | ||
package com.cleanroommc.neverenoughanimations.core.mixin.jei; | ||
|
||
import com.cleanroommc.neverenoughanimations.animations.OpeningAnimation; | ||
import mezz.jei.gui.overlay.bookmarks.LeftAreaDispatcher; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.gui.GuiScreen; | ||
import net.minecraft.client.gui.inventory.GuiContainer; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
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.Inject; | ||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; | ||
|
||
import java.awt.*; | ||
|
||
@Mixin(value = LeftAreaDispatcher.class, remap = false) | ||
public abstract class LeftAreaDispatcherMixin { | ||
|
||
@Shadow private Rectangle displayArea; | ||
|
||
@Shadow private boolean canShow; | ||
|
||
@Shadow protected abstract boolean hasContent(); | ||
|
||
@Inject(method = "drawScreen", at = @At("HEAD")) | ||
public void drawScreenPre(Minecraft minecraft, int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { | ||
if (canShow && hasContent()) { | ||
GlStateManager.pushMatrix(); | ||
GuiScreen screen = Minecraft.getMinecraft().currentScreen; | ||
if (screen instanceof GuiContainer container) { | ||
float val = 1f - OpeningAnimation.getValue(container); | ||
if (val <= 0f) return; | ||
GlStateManager.translate(-displayArea.width * val, 0, 0); | ||
} | ||
} | ||
} | ||
|
||
@Inject(method = "drawScreen", at = @At("TAIL")) | ||
public void drawScreenPost(Minecraft minecraft, int mouseX, int mouseY, float partialTicks, CallbackInfo ci) { | ||
if (canShow && hasContent()) { | ||
GlStateManager.popMatrix(); | ||
} | ||
} | ||
} |
This file contains 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,13 @@ | ||
{ | ||
"package": "com.cleanroommc.neverenoughanimations.core.mixin.jei", | ||
"refmap": "mixins.neverenoughanimations.refmap.json", | ||
"target": "@env(DEFAULT)", | ||
"minVersion": "0.8", | ||
"compatibilityLevel": "JAVA_8", | ||
"client": [ | ||
], | ||
"mixins": [ | ||
"IngredientListOverlayMixin", | ||
"LeftAreaDispatcherMixin" | ||
] | ||
} |