1
1
package io .wispforest .lavender .mixin ;
2
2
3
+ import com .llamalad7 .mixinextras .sugar .Local ;
4
+ import com .llamalad7 .mixinextras .sugar .ref .LocalRef ;
3
5
import io .wispforest .lavender .book .LavenderBookItem ;
4
6
import io .wispforest .lavender .book .BookLoader ;
5
7
import io .wispforest .lavender .client .AssociatedEntryTooltipComponent ;
12
14
import net .minecraft .client .gui .tooltip .TooltipComponent ;
13
15
import net .minecraft .client .gui .tooltip .TooltipPositioner ;
14
16
import org .spongepowered .asm .mixin .Mixin ;
15
- import org .spongepowered .asm .mixin .Unique ;
16
17
import org .spongepowered .asm .mixin .injection .At ;
17
18
import org .spongepowered .asm .mixin .injection .Inject ;
18
19
import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
19
20
21
+ import java .util .ArrayList ;
20
22
import java .util .List ;
21
23
24
+ import static io .wispforest .lavender .client .AssociatedEntryTooltipComponent .entryTriggerProgress ;
25
+
22
26
@ Mixin (DrawContext .class )
23
27
public class DrawContextMixin {
24
28
25
- @ Unique
26
- private static float entryTriggerProgress = 0f ;
27
-
28
29
@ Inject (method = "drawTooltip(Lnet/minecraft/client/font/TextRenderer;Ljava/util/List;IILnet/minecraft/client/gui/tooltip/TooltipPositioner;)V" , at = @ At ("HEAD" ))
29
- private void injectTooltipComponents (TextRenderer textRenderer , List <TooltipComponent > components , int x , int y , TooltipPositioner positioner , CallbackInfo ci ) {
30
+ private void injectTooltipComponents (TextRenderer textRenderer , List <TooltipComponent > components , int x , int y , TooltipPositioner positioner , CallbackInfo ci , @ Local ( argsOnly = true ) LocalRef < List < TooltipComponent >> componentsRef ) {
30
31
var client = MinecraftClient .getInstance ();
31
32
32
33
if (AssociatedEntryTooltipComponent .tooltipStack != null && AssociatedEntryTooltipComponent .tooltipStack .get () != null ) {
@@ -51,8 +52,11 @@ private void injectTooltipComponents(TextRenderer textRenderer, List<TooltipComp
51
52
52
53
if (bookIndex == -1 ) return ;
53
54
55
+ components = new ArrayList <>(components );
54
56
components .add (new AssociatedEntryTooltipComponent (LavenderBookItem .itemOf (book ), associatedEntry , entryTriggerProgress ));
55
- entryTriggerProgress += Delta .compute (entryTriggerProgress , Screen .hasAltDown () ? 1.35f : 0f , client .getLastFrameDuration () * .125 );
57
+ componentsRef .set (components );
58
+
59
+ entryTriggerProgress += Delta .compute (entryTriggerProgress , Screen .hasAltDown () ? 1.35f : 0f , client .getLastFrameDuration () * .125f );
56
60
57
61
if (entryTriggerProgress >= .95 ) {
58
62
LavenderBookScreen .pushEntry (book , associatedEntry );
@@ -68,7 +72,5 @@ private void injectTooltipComponents(TextRenderer textRenderer, List<TooltipComp
68
72
return ;
69
73
}
70
74
}
71
-
72
- entryTriggerProgress += Delta .compute (entryTriggerProgress , 0f , client .getLastFrameDuration () * .125 );
73
75
}
74
76
}
0 commit comments