Skip to content
This repository has been archived by the owner on Sep 15, 2024. It is now read-only.

Commit

Permalink
recipe book opacity
Browse files Browse the repository at this point in the history
  • Loading branch information
MicrocontrollersDev committed May 24, 2024
1 parent 2402456 commit 0b21bc5
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package dev.microcontrollers.overlaytweaks.mixin.screenopacity;

import com.mojang.blaze3d.systems.RenderSystem;
import dev.microcontrollers.overlaytweaks.config.OverlayTweaksConfig;
import net.minecraft.client.gui.DrawContext;
import net.minecraft.client.gui.screen.recipebook.RecipeBookWidget;
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(RecipeBookWidget.class)
public class RecipeBookWidgetMixin {
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V"))
private void containerOpacityStart(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, OverlayTweaksConfig.CONFIG.instance().containerTextureOpacity / 100F);
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/DrawContext;drawTexture(Lnet/minecraft/util/Identifier;IIIIII)V", shift = At.Shift.AFTER))
private void containerOpacityEnd(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeGroupButtonWidget;render(Lnet/minecraft/client/gui/DrawContext;IIF)V"))
private void widgetOpacityStart(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, OverlayTweaksConfig.CONFIG.instance().containerTextureOpacity / 100F);
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/recipebook/RecipeGroupButtonWidget;render(Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.AFTER))
private void widgetOpacityEnd(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ToggleButtonWidget;render(Lnet/minecraft/client/gui/DrawContext;IIF)V"))
private void toggleButtonOpacityStart(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, OverlayTweaksConfig.CONFIG.instance().containerTextureOpacity / 100F);
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/ToggleButtonWidget;render(Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.AFTER))
private void toggleButtonOpacityEnd(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;render(Lnet/minecraft/client/gui/DrawContext;IIF)V"))
private void searchOpacityStart(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
RenderSystem.enableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, OverlayTweaksConfig.CONFIG.instance().containerTextureOpacity / 100F);
}

@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/widget/TextFieldWidget;render(Lnet/minecraft/client/gui/DrawContext;IIF)V", shift = At.Shift.AFTER))
private void searchOpacityEnd(DrawContext context, int mouseX, int mouseY, float delta, CallbackInfo ci) {
RenderSystem.disableBlend();
RenderSystem.setShaderColor(1F, 1F, 1F, 1F);
}

}
6 changes: 1 addition & 5 deletions src/main/resources/overlaytweaks.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,13 @@
"PotionItemMixin",
"ScreenMixin",
"SubtitlesHudMixin",
//#if MC <= 1.20.4
//$$ "TabNavigationWidgetMixin",
//#endif
"WorldRendererMixin",
"screenopacity.AbstractFurnaceScreenMixin",
"screenopacity.AnvilScreenMixin",
"screenopacity.BeaconScreenMixin",
"screenopacity.BrewingStandScreenMixin",
"screenopacity.CartographyTableScreenMixin",
//#if MC >= 1.20.4
"screenopacity.CrafterScreenMixin",
//#endif
"screenopacity.CraftingScreenMixin",
"screenopacity.CreativeInventoryScreenMixin",
"screenopacity.EnchantmentScreenMixin",
Expand All @@ -41,6 +36,7 @@
"screenopacity.HorseScreenMixin",
"screenopacity.InventoryScreenMixin",
"screenopacity.LoomScreenMixin",
"screenopacity.RecipeBookWidgetMixin",
"screenopacity.ShulkerBoxScreenMixin",
"screenopacity.StonecutterScreenMixin"
],
Expand Down

0 comments on commit 0b21bc5

Please sign in to comment.