Skip to content

Commit

Permalink
trashslot compat
Browse files Browse the repository at this point in the history
  • Loading branch information
brachy84 committed Jul 13, 2024
1 parent 2dc5777 commit 6519be7
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 1 deletion.
2 changes: 1 addition & 1 deletion dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@
* For more details, see https://docs.gradle.org/8.4/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {

devOnlyNonPublishable rfg.deobf("curse.maven:trashslot-235577:2722385")
}
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]);
}
}
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 src/main/resources/mixin.neverenoughanimations.trashslot.json
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": [
]
}

0 comments on commit 6519be7

Please sign in to comment.