@@ -38,38 +38,55 @@ public abstract class HandledScreenMixin {
3838 @ Shadow
3939 protected int y ;
4040
41- private int lastMatchedCount = 0 ;
42-
43- @ Inject (method = "render" , at = @ At ("TAIL" ))
44- private void onRender (DrawContext context , int mouseX , int mouseY , float delta , CallbackInfo ci ) {
45- ScreenHandler handler = ((ScreenHandlerProvider <?>) this ).getScreenHandler ();
46- List <Slot > slots = ((ScreenHandlerAccessor ) handler ).getSlots ();
47- Text title = ((HandledScreen )(Object )this ).getTitle ();
48- SearchAutomationController .onScreenRender (title , handler , slots );
49-
50- if (!ToggleScanner .scanningEnabled ) {
51- return ;
52- }
53-
54- int matchedCount = 0 ;
55- for (Slot slot : slots ) {
56- if (processSlot (context , slot )) {
57- matchedCount ++;
58- }
59- }
60-
61- if (LtrynekClient .serversConfig != null && LtrynekClient .serversConfig .soundsEnabled ) {
62- if (matchedCount != lastMatchedCount && matchedCount > 0 ) {
63- AlarmSoundPlayer .playForMatchCount (
64- LtrynekClient .serversConfig ,
65- ClientPriceListManager .getActiveProfile (),
66- matchedCount
67- );
68- }
69- }
70- lastMatchedCount = matchedCount ;
71-
72- }
41+ private int lastMatchedCount = 0 ;
42+ private int currentMatchedCount = 0 ;
43+
44+ @ Inject (method = "render" , at = @ At ("HEAD" ))
45+ private void onRenderHead (DrawContext context , int mouseX , int mouseY , float delta , CallbackInfo ci ) {
46+ currentMatchedCount = 0 ;
47+ }
48+
49+ @ Inject (method = "render" , at = @ At ("TAIL" ))
50+ private void onRender (DrawContext context , int mouseX , int mouseY , float delta , CallbackInfo ci ) {
51+ ScreenHandler handler = ((ScreenHandlerProvider <?>) this ).getScreenHandler ();
52+ List <Slot > slots = ((ScreenHandlerAccessor ) handler ).getSlots ();
53+ Text title = ((HandledScreen )(Object )this ).getTitle ();
54+ SearchAutomationController .onScreenRender (title , handler , slots );
55+
56+ if (!ToggleScanner .scanningEnabled ) {
57+ return ;
58+ }
59+
60+ if (LtrynekClient .serversConfig != null && LtrynekClient .serversConfig .soundsEnabled ) {
61+ if (currentMatchedCount != lastMatchedCount && currentMatchedCount > 0 ) {
62+ AlarmSoundPlayer .playForMatchCount (
63+ LtrynekClient .serversConfig ,
64+ ClientPriceListManager .getActiveProfile (),
65+ currentMatchedCount
66+ );
67+ }
68+ }
69+ lastMatchedCount = currentMatchedCount ;
70+
71+ }
72+
73+ @ Inject (
74+ method = "drawSlot" ,
75+ at = @ At (
76+ value = "INVOKE" ,
77+ target = "Lnet/minecraft/client/gui/DrawContext;drawItem(Lnet/minecraft/item/ItemStack;III)V" ,
78+ shift = At .Shift .BEFORE
79+ )
80+ )
81+ private void onDrawSlotBeforeItem (DrawContext context , Slot slot , CallbackInfo ci ) {
82+ if (!ToggleScanner .scanningEnabled ) {
83+ return ;
84+ }
85+
86+ if (processSlot (context , slot )) {
87+ currentMatchedCount ++;
88+ }
89+ }
7390
7491 @ Inject (method = "removed" , at = @ At ("TAIL" ))
7592 private void onRemoved (CallbackInfo ci ) {
@@ -113,12 +130,12 @@ private boolean processSlot(DrawContext context, Slot slot) {
113130 slot .id
114131 );
115132 ScanResult result = ScanEvaluator .evaluate (input , LtrynekClient .serversConfig );
116- if (result .highlight ) {
117- int realX = this . x + slot .x ;
118- int realY = this . y + slot .y ;
119- context .fill (realX , realY , realX + 16 , realY + 16 , result .color );
120- return true ;
121- }
133+ if (result .highlight ) {
134+ int realX = slot .x ;
135+ int realY = slot .y ;
136+ context .fill (realX , realY , realX + 16 , realY + 16 , result .color );
137+ return true ;
138+ }
122139
123140 return false ;
124141 }
0 commit comments