-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #360 from IcarussOne/main
Potion Amplifier Visibility Bugfix
- Loading branch information
Showing
5 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...va/mod/acgaming/universaltweaks/bugfixes/misc/potionamplifier/UTPotionAmplifierMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"] | ||
} |