Skip to content

Commit

Permalink
Merge pull request #360 from IcarussOne/main
Browse files Browse the repository at this point in the history
Potion Amplifier Visibility Bugfix
  • Loading branch information
ACGaming authored Jan 17, 2024
2 parents 29157f2 + ff1a2d0 commit 1a4d0fc
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ All changes are toggleable via config files.
* **Particle Spawning:** Fixes various particle types not showing up on the client
* **Piston Progress:** Properly saves the last state of pistons to tags
* **Portal Traveling Dupe:** Fixes duplication issues that can occur when entities travel through portals
* **Potion Amplifier Visibility:** Fixes potion effects not displaying their level when it is above 'IV'
* **Shear Mooshroom Dupe:** Fixes a duplication exploit connected to shearing mooshrooms
* **Skeleton Aim:** Fixes skeletons not looking at their targets when strafing
* **Sleep Resets Weather:** Fixes sleeping always resetting rain and thunder times
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package mod.acgaming.universaltweaks.bugfixes.misc.potionamplifier.mixin;

import java.util.Collection;
import java.util.Iterator;

import net.minecraft.client.renderer.InventoryEffectRenderer;
import net.minecraft.client.resources.I18n;
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
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;
import org.spongepowered.asm.mixin.injection.callback.LocalCapture;

import mod.acgaming.universaltweaks.config.UTConfigBugfixes;
import mod.acgaming.universaltweaks.config.UTConfigTweaks;

// MC-130847
// https://bugs.mojang.com/browse/MC-130847
// Courtesy of fonnymunkey
@Mixin(InventoryEffectRenderer.class)
public class UTPotionAmplifierMixin
{
private int amplifier = 0;

@Inject(
method = "drawActivePotionEffects",
at = @At(value = "INVOKE", target = "Lnet/minecraft/client/Minecraft;getTextureManager()Lnet/minecraft/client/renderer/texture/TextureManager;"),
locals = LocalCapture.CAPTURE_FAILHARD
)
public void rlmixins_vanillaInventoryEffectRenderer_drawActivePotionEffects_Inject(CallbackInfo ci, int i, int j, int k, Collection collection, int l, Iterator var6, PotionEffect potioneffect, Potion potion)
{
this.amplifier = potioneffect.getAmplifier();
}

@ModifyArg(method = "drawActivePotionEffects", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/FontRenderer;drawStringWithShadow(Ljava/lang/String;FFI)I", ordinal = 0))
public String rlmixins_vanillaInventoryEffectRenderer_drawActivePotionEffects_Modify(String text)
{
if (this.amplifier > 3 && this.amplifier < 10) text += " " + I18n.format("enchantment.level." + (this.amplifier + 1));
if (this.amplifier >= 10 && this.amplifier < 128) text += " " + (this.amplifier + 1);
this.amplifier = 0;
return text;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,11 @@ public static class MiscCategory
@Config.Name("Particle Spawning")
@Config.Comment("Fixes various particle types not showing up on the client")
public boolean utParticleSpawningToggle = true;

@Config.RequiresMcRestart
@Config.Name("Potion Amplifier Visibility")
@Config.Comment("Fixes potion effects not displaying their level when it is above 'IV'")
public boolean utPotionAmplifierVisibilityToggle = true;

@Config.RequiresMcRestart
@Config.Name("Packet Size")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public List<String> getMixinConfigs()
configs.add("mixins.bugfixes.entities.villagermantle.json");
configs.add("mixins.bugfixes.misc.depthmask.json");
configs.add("mixins.bugfixes.misc.modelgap.json");
configs.add("mixins.bugfixes.misc.potionamplifier.json");
configs.add("mixins.bugfixes.misc.smoothlighting.json");
configs.add("mixins.bugfixes.misc.startup.json");
configs.add("mixins.bugfixes.world.frustumculling.json");
Expand Down Expand Up @@ -260,6 +261,8 @@ public boolean shouldMixinConfigQueue(String mixinConfig)
return UTConfigBugfixes.MISC.utDepthMaskToggle;
case "mixins.bugfixes.misc.modelgap.json":
return UTConfigBugfixes.MISC.MODEL_GAP.utModelGapToggle;
case "mixins.bugfixes.misc.potionamplifier.json":
return UTConfigBugfixes.MISC.utPotionAmplifierVisibilityToggle;
case "mixins.bugfixes.misc.smoothlighting.json":
return UTConfigBugfixes.MISC.utAccurateSmoothLighting;
case "mixins.bugfixes.misc.startup.json":
Expand Down
7 changes: 7 additions & 0 deletions src/main/resources/mixins.bugfixes.misc.potionamplifier.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"package": "mod.acgaming.universaltweaks.bugfixes.misc.potionamplifier.mixin",
"refmap": "universaltweaks.refmap.json",
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"client": ["UTPotionAmplifierMixin"]
}

0 comments on commit 1a4d0fc

Please sign in to comment.