package asm.mixins;

import dev.crucifixbeta.mod.gui.menu.EpsilonMenuStyle;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.widget.ButtonWidget;
import net.minecraft.client.gui.widget.PressableWidget;
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;

@Environment(EnvType.CLIENT)
@Mixin({PressableWidget.class})
public class MixinMenuButtonWidget {
   @Inject(
      method = {"renderWidget"},
      at = {@At("HEAD")},
      cancellable = true
   )
   private void crucifix$renderEpsilonMenuButton(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
      if (EpsilonMenuStyle.isCurrentStyledScreen() && (Object)this instanceof ButtonWidget var7) {
         EpsilonMenuStyle.renderButton(var7, context, mouseX, mouseY, delta);
         ci.cancel();
      }
   }
}
