-
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
4 changed files
with
92 additions
and
1 deletion.
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
28 changes: 28 additions & 0 deletions
28
src/main/java/com/cleanroommc/neverenoughanimations/core/LateMixin.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,28 @@ | ||
package com.cleanroommc.neverenoughanimations.core; | ||
|
||
import com.cleanroommc.neverenoughanimations.Tags; | ||
import net.minecraftforge.fml.common.Loader; | ||
import zone.rong.mixinbooter.ILateMixinLoader; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
public class LateMixin implements ILateMixinLoader { | ||
|
||
private static final String[] mods = { | ||
"trashslot" | ||
}; | ||
|
||
@Override | ||
public List<String> getMixinConfigs() { | ||
return Arrays.stream(mods) | ||
.map(m -> "mixin." + Tags.MODID + "." + m + ".json") | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
public boolean shouldMixinConfigQueue(String mixinConfig) { | ||
return Loader.isModLoaded(mixinConfig.split("\\.")[2]); | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
...ain/java/com/cleanroommc/neverenoughanimations/core/mixin/trashslot/ClientProxyMixin.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,51 @@ | ||
package com.cleanroommc.neverenoughanimations.core.mixin.trashslot; | ||
|
||
import com.cleanroommc.neverenoughanimations.NEAConfig; | ||
import com.cleanroommc.neverenoughanimations.animations.OpeningAnimation; | ||
import com.llamalad7.mixinextras.sugar.Share; | ||
import com.llamalad7.mixinextras.sugar.ref.LocalBooleanRef; | ||
import net.blay09.mods.trashslot.client.ClientProxy; | ||
import net.minecraft.client.gui.inventory.GuiContainer; | ||
import net.minecraft.client.renderer.GlStateManager; | ||
import net.minecraftforge.client.event.GuiScreenEvent; | ||
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.CallbackInfo; | ||
|
||
@Mixin(value = ClientProxy.class, remap = false) | ||
public class ClientProxyMixin { | ||
|
||
@Inject(method = "onDrawScreen(Lnet/minecraftforge/client/event/GuiScreenEvent$DrawScreenEvent$Pre;)V", | ||
at = @At(value = "INVOKE", target = "Lnet/blay09/mods/trashslot/client/gui/GuiTrashSlot;update(II)V", shift = At.Shift.BEFORE)) | ||
public void onDrawScreenPre(GuiScreenEvent.DrawScreenEvent.Pre event, CallbackInfo ci, @Share("didDraw") LocalBooleanRef didDraw) { | ||
if (NEAConfig.openingAnimationTime == 0) return; | ||
GuiContainer container = (GuiContainer) event.getGui(); | ||
float scale = OpeningAnimation.getScale(container); | ||
GlStateManager.pushMatrix(); | ||
GlStateManager.translate(container.getGuiLeft(), container.getGuiTop(), 0); | ||
GlStateManager.translate(container.getXSize() / 2f, container.getYSize() / 2f, 0); | ||
GlStateManager.scale(scale, scale, 1f); | ||
GlStateManager.translate(-container.getXSize() / 2f, -container.getYSize() / 2f, 0); | ||
GlStateManager.translate(-container.getGuiLeft(), -container.getGuiTop(), 0); | ||
// GlStateManager.color(1f, 1f, 1f, scale); | ||
didDraw.set(true); | ||
} | ||
|
||
@Inject(method = "onDrawScreen(Lnet/minecraftforge/client/event/GuiScreenEvent$DrawScreenEvent$Pre;)V", at = @At("TAIL")) | ||
public void onDrawScreenPost(GuiScreenEvent.DrawScreenEvent.Pre event, CallbackInfo ci, @Share("didDraw") LocalBooleanRef didDraw) { | ||
if (didDraw.get()) { | ||
GlStateManager.popMatrix(); | ||
} | ||
} | ||
|
||
@Inject(method = "onBackgroundDrawn", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/inventory/GuiContainer;drawSlot(Lnet/minecraft/inventory/Slot;)V", shift = At.Shift.BEFORE)) | ||
public void onDrawBackground(GuiScreenEvent.BackgroundDrawnEvent event, CallbackInfo ci) { | ||
if (NEAConfig.openingAnimationTime == 0) return; | ||
GuiContainer container = (GuiContainer) event.getGui(); | ||
float scale = OpeningAnimation.getScale(container); | ||
GlStateManager.translate(container.getXSize() / 2f, container.getYSize() / 2f, 0); | ||
GlStateManager.scale(scale, scale, 1f); | ||
GlStateManager.translate(-container.getXSize() / 2f, -container.getYSize() / 2f, 0); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/resources/mixin.neverenoughanimations.trashslot.json
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,12 @@ | ||
{ | ||
"package": "com.cleanroommc.neverenoughanimations.core.mixin.trashslot", | ||
"refmap": "mixins.neverenoughanimations.refmap.json", | ||
"target": "@env(DEFAULT)", | ||
"minVersion": "0.8", | ||
"compatibilityLevel": "JAVA_8", | ||
"client": [ | ||
"ClientProxyMixin" | ||
], | ||
"mixins": [ | ||
] | ||
} |