1
1
package se .icus .mag .statuseffecttimer .mixin ;
2
2
3
- import com .google . common . collect . Ordering ;
3
+ import com .llamalad7 . mixinextras . sugar . Local ;
4
4
import net .fabricmc .api .EnvType ;
5
5
import net .fabricmc .api .Environment ;
6
6
import net .minecraft .client .MinecraftClient ;
7
7
import net .minecraft .client .gui .DrawableHelper ;
8
8
import net .minecraft .client .gui .hud .InGameHud ;
9
9
import net .minecraft .client .resource .language .I18n ;
10
10
import net .minecraft .client .util .math .MatrixStack ;
11
- import net .minecraft .entity .effect .StatusEffect ;
12
11
import net .minecraft .entity .effect .StatusEffectInstance ;
13
12
import net .minecraft .util .math .MathHelper ;
14
13
import org .jetbrains .annotations .NotNull ;
19
18
import org .spongepowered .asm .mixin .injection .Inject ;
20
19
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
21
20
22
- import java .util .Collection ;
21
+ import java .util .List ;
23
22
24
23
// Set priority to 500, to load before default at 1000. This is to better cooperate with HUDTweaks.
25
24
@ Environment (EnvType .CLIENT )
@@ -28,38 +27,14 @@ public abstract class StatusEffectTimerMixin extends DrawableHelper {
28
27
@ Shadow @ Final
29
28
private MinecraftClient client ;
30
29
31
- @ Inject (method = "renderStatusEffectOverlay" , at = @ At ("TAIL" ))
32
- private void renderDurationOverlay (MatrixStack matrices , CallbackInfo c ) {
33
- Collection <StatusEffectInstance > collection = this .client .player .getStatusEffects ();
34
- if (!collection .isEmpty ()) {
35
- // Replicate vanilla placement algorithm to get the duration
36
- // labels to line up exactly right.
37
-
38
- int beneficialCount = 0 ;
39
- int nonBeneficialCount = 0 ;
40
- for (StatusEffectInstance statusEffectInstance : Ordering .natural ().reverse ().sortedCopy (collection )) {
41
- StatusEffect statusEffect = statusEffectInstance .getEffectType ();
42
- if (statusEffectInstance .shouldShowIcon ()) {
43
- int x = this .client .getWindow ().getScaledWidth ();
44
- int y = 1 ;
45
-
46
- if (this .client .isDemo ()) {
47
- y += 15 ;
48
- }
49
-
50
- if (statusEffect .isBeneficial ()) {
51
- beneficialCount ++;
52
- x -= 25 * beneficialCount ;
53
- } else {
54
- nonBeneficialCount ++;
55
- x -= 25 * nonBeneficialCount ;
56
- y += 26 ;
57
- }
58
-
59
- drawStatusEffectOverlay (matrices , statusEffectInstance , x , y );
60
- }
61
- }
62
- }
30
+ @ Inject (method = "renderStatusEffectOverlay" ,
31
+ at = @ At (value = "INVOKE" , target = "Ljava/util/List;add(Ljava/lang/Object;)Z" , shift = At .Shift .AFTER ))
32
+ private void appendOverlayDrawing (MatrixStack matrices , CallbackInfo c ,
33
+ @ Local List <Runnable > list , @ Local StatusEffectInstance statusEffectInstance ,
34
+ @ Local (ordinal = 4 ) int x , @ Local (ordinal = 3 ) int y ) {
35
+ list .add (() -> {
36
+ drawStatusEffectOverlay (matrices , statusEffectInstance , x , y );
37
+ });
63
38
}
64
39
65
40
private void drawStatusEffectOverlay (MatrixStack matrices , StatusEffectInstance statusEffectInstance , int x , int y ) {
0 commit comments