1
1
package sunsetsatellite .catalyst .core .mixin ;
2
2
3
+ import com .llamalad7 .mixinextras .sugar .Local ;
3
4
import net .minecraft .client .gui .Gui ;
4
5
import net .minecraft .client .gui .GuiTooltip ;
5
6
import net .minecraft .core .block .Block ;
6
7
import net .minecraft .core .item .ItemStack ;
7
8
import net .minecraft .core .item .block .ItemBlock ;
8
9
import net .minecraft .core .lang .I18n ;
9
10
import net .minecraft .core .player .inventory .slot .Slot ;
11
+ import org .jetbrains .annotations .ApiStatus ;
12
+ import org .objectweb .asm .Opcodes ;
13
+ import org .spongepowered .asm .mixin .Debug ;
10
14
import org .spongepowered .asm .mixin .Mixin ;
11
15
import org .spongepowered .asm .mixin .injection .At ;
16
+ import org .spongepowered .asm .mixin .injection .Desc ;
12
17
import org .spongepowered .asm .mixin .injection .Inject ;
13
18
import org .spongepowered .asm .mixin .injection .callback .CallbackInfoReturnable ;
14
19
import org .spongepowered .asm .mixin .injection .callback .LocalCapture ;
15
20
import sunsetsatellite .catalyst .core .util .ICustomDescription ;
16
21
22
+ import java .util .Objects ;
23
+
24
+ @ Debug (
25
+ export = true
26
+ )
17
27
@ Mixin (
18
28
value = GuiTooltip .class ,
19
29
remap = false
@@ -28,12 +38,36 @@ public void injectCustomTooltip(ItemStack itemStack, boolean showDescription, Sl
28
38
if (itemStack != null && itemStack .getItem () instanceof ItemBlock ){
29
39
Block block = Block .blocksList [itemStack .getItem ().id ];
30
40
if (block instanceof ICustomDescription ){
31
- text .append (((ICustomDescription ) block ).getDescription (itemStack )).append ("\n " );
41
+ if (!Objects .equals (((ICustomDescription ) block ).getDescription (itemStack ), "" )){
42
+ text .append (((ICustomDescription ) block ).getDescription (itemStack )).append ("\n " );
43
+ }
32
44
}
33
45
}
34
46
if (itemStack != null && itemStack .getItem () instanceof ICustomDescription ){
35
- text .append (((ICustomDescription ) itemStack .getItem ()).getDescription (itemStack )).append ("\n " );
47
+ if (!Objects .equals (((ICustomDescription ) itemStack .getItem ()).getDescription (itemStack ), "" )){
48
+ text .append (((ICustomDescription ) itemStack .getItem ()).getDescription (itemStack )).append ("\n " );
49
+ }
36
50
}
37
51
}
52
+
53
+ @ Inject (
54
+ method = "getTooltipText(Lnet/minecraft/core/item/ItemStack;ZLnet/minecraft/core/player/inventory/slot/Slot;)Ljava/lang/String;" ,
55
+ at = @ At (value = "JUMP" ,opcode = Opcodes .IFEQ ,ordinal = 12 )
56
+ )
57
+ public void injectPersistentTooltip (ItemStack itemStack , boolean showDescription , Slot slot , CallbackInfoReturnable <String > cir , @ Local StringBuilder text ){
58
+ if (itemStack != null && itemStack .getItem () instanceof ItemBlock ){
59
+ Block block = Block .blocksList [itemStack .getItem ().id ];
60
+ if (block instanceof ICustomDescription ){
61
+ if (!Objects .equals (((ICustomDescription ) block ).getPersistentDescription (itemStack ), "" )){
62
+ text .append ("\n " ).append (((ICustomDescription ) block ).getPersistentDescription (itemStack ));
63
+ }
64
+ }
65
+ }
66
+ if (itemStack != null && itemStack .getItem () instanceof ICustomDescription ){
67
+ if (!Objects .equals (((ICustomDescription ) itemStack .getItem ()).getPersistentDescription (itemStack ), "" )){
68
+ text .append ("\n " ).append (((ICustomDescription ) itemStack .getItem ()).getPersistentDescription (itemStack ));
69
+ }
70
+ }
71
+ }
38
72
}
39
73
0 commit comments