Skip to content

Commit

Permalink
custom pumpkin opacity (#9)
Browse files Browse the repository at this point in the history
* custom pumpkin opacity

* fix spacing

* add comment

just in case anyone is confused on why its there
  • Loading branch information
MicrocontrollersDev authored Feb 23, 2024
1 parent a43c8c4 commit 429dffa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/club/sk1er/patcher/config/PatcherConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,14 @@ public class PatcherConfig extends Config {
)
public static float fireOverlayOpacity = 1.0F;

@Slider( // todo add percentage
name = "Pumpkin Overlay Opacity",
description = "Change the opacity of the pumpkin overlay.",
category = "Miscellaneous", subcategory = "Overlays",
min = 0F, max = 1.0F
)
public static float pumpkinOverlayOpacity = 1.0F;

@Switch(
name = "Hide Fire Overlay with Fire Resistance",
description = "Hide the fire overlay when you have fire resistance active.\n" +
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package club.sk1er.patcher.mixins.features;

import club.sk1er.patcher.config.PatcherConfig;
import net.minecraft.client.gui.GuiIngame;
import net.minecraft.client.gui.ScaledResolution;
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.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(GuiIngame.class)
public class GuiIngameMixin_PumpkinBlurRendering {
@Inject(method = "renderPumpkinOverlay", at = @At("HEAD"), cancellable = true)
private void patcher$cancelPumpkinOverlay(ScaledResolution scaledRes, CallbackInfo ci) {
if (PatcherConfig.pumpkinOverlayOpacity == 0) ci.cancel(); // micro-optimization, let's skip all the math to render if it's not going to be visible anyways
}

@ModifyArg(method = "renderPumpkinOverlay", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/renderer/GlStateManager;color(FFFF)V"), index = 3)
private float patcher$modifyPumpkinOpacity(float alpha) {
return PatcherConfig.pumpkinOverlayOpacity;
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.patcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
"features.GuiIngameForgeMixin_CrosshairRendering",
"features.GuiIngameForgeMixin_TitleRendering",
"features.GuiIngameMixin_CrosshairVisibility",
"features.GuiIngameMixin_PumpkinBlurRendering",
"features.GuiMultiplayerMixin_FastServerJoin",
"features.GuiNewChatMixin_ChatDelay",
"features.GuiNewChatMixin_CompactChat",
Expand Down

0 comments on commit 429dffa

Please sign in to comment.