2727
2828import com .genuineflix .tooltip .WorldTooltip ;
2929
30- import cpw .mods .fml .common .ModContainer ;
30+ import cpw .mods .fml .common .Loader ;
3131import cpw .mods .fml .common .eventhandler .SubscribeEvent ;
32- import cpw .mods .fml .common .registry .GameData ;
3332import cpw .mods .fml .common .registry .GameRegistry ;
34- import cpw .mods .fml .common .registry .GameRegistry .UniqueIdentifier ;
3533
3634public class TooltipSystem {
3735
38- public static String nameFromStack (final ItemStack stack ) {
36+ private static void drawGradientRect (final int x , final int y , int w , int h , final int color1 , final int color2 ) {
37+ w += x ;
38+ h += y ;
39+ final float alpha1 = (color1 >> 24 & 0xff ) / 255F ;
40+ final float red1 = (color1 >> 16 & 0xff ) / 255F ;
41+ final float green1 = (color1 >> 8 & 0xff ) / 255F ;
42+ final float blue1 = (color1 & 0xff ) / 255F ;
43+ final float alpha2 = (color2 >> 24 & 0xff ) / 255F ;
44+ final float red2 = (color2 >> 16 & 0xff ) / 255F ;
45+ final float green2 = (color2 >> 8 & 0xff ) / 255F ;
46+ final float blue2 = (color2 & 0xff ) / 255F ;
47+ GL11 .glDisable (GL11 .GL_TEXTURE_2D );
48+ GL11 .glEnable (GL11 .GL_BLEND );
49+ GL11 .glDisable (GL11 .GL_ALPHA_TEST );
50+ GL11 .glBlendFunc (GL11 .GL_SRC_ALPHA , GL11 .GL_ONE_MINUS_SRC_ALPHA );
51+ GL11 .glShadeModel (GL11 .GL_SMOOTH );
52+ final Tessellator tessellator = Tessellator .instance ;
53+ tessellator .startDrawingQuads ();
54+ tessellator .setColorRGBA_F (red1 , green1 , blue1 , alpha1 );
55+ tessellator .addVertex (w , y , 0 );
56+ tessellator .addVertex (x , y , 0 );
57+ tessellator .setColorRGBA_F (red2 , green2 , blue2 , alpha2 );
58+ tessellator .addVertex (x , h , 0 );
59+ tessellator .addVertex (w , h , 0 );
60+ tessellator .draw ();
61+ GL11 .glShadeModel (GL11 .GL_FLAT );
62+ GL11 .glDisable (GL11 .GL_BLEND );
63+ GL11 .glEnable (GL11 .GL_ALPHA_TEST );
64+ GL11 .glEnable (GL11 .GL_TEXTURE_2D );
65+ }
66+
67+ public static String modNameFromStack (final ItemStack stack ) {
3968 try {
40- final UniqueIdentifier ui = GameRegistry .findUniqueIdentifierFor (stack .getItem ());
41- final ModContainer mod = GameData .findModOwner (GameData .getItemRegistry ().getNameForObject (stack .getItem ()));
42- final String modname = mod == null ? "Minecraft" : mod .getName ();
43- return modname ;
69+ return Loader .instance ().getIndexedModList ().get (GameRegistry .findUniqueIdentifierFor (stack .getItem ()).modId ).getName ();
4470 }
4571 catch (final Exception e ) {
46- return "" ;
72+ return "Minecraft " ;
4773 }
4874 }
4975
@@ -103,43 +129,6 @@ private void addInfo(final List<String> list) {
103129 }
104130 }
105131
106- private void addModInfo (final List <String > list ) {
107- final String modName = TooltipSystem .nameFromStack (entityItem .getEntityItem ());
108- if (!modName .isEmpty ())
109- list .add (EnumChatFormatting .BLUE .toString () + EnumChatFormatting .ITALIC .toString () + modName + EnumChatFormatting .RESET .toString ());
110- }
111-
112- protected void drawGradientRect (final int x , final int y , int w , int h , final int color1 , final int color2 ) {
113- w += x ;
114- h += y ;
115- final float alpha1 = (color1 >> 24 & 0xff ) / 255F ;
116- final float red1 = (color1 >> 16 & 0xff ) / 255F ;
117- final float green1 = (color1 >> 8 & 0xff ) / 255F ;
118- final float blue1 = (color1 & 0xff ) / 255F ;
119- final float alpha2 = (color2 >> 24 & 0xff ) / 255F ;
120- final float red2 = (color2 >> 16 & 0xff ) / 255F ;
121- final float green2 = (color2 >> 8 & 0xff ) / 255F ;
122- final float blue2 = (color2 & 0xff ) / 255F ;
123- GL11 .glDisable (GL11 .GL_TEXTURE_2D );
124- GL11 .glEnable (GL11 .GL_BLEND );
125- GL11 .glDisable (GL11 .GL_ALPHA_TEST );
126- GL11 .glBlendFunc (GL11 .GL_SRC_ALPHA , GL11 .GL_ONE_MINUS_SRC_ALPHA );
127- GL11 .glShadeModel (GL11 .GL_SMOOTH );
128- final Tessellator tessellator = Tessellator .instance ;
129- tessellator .startDrawingQuads ();
130- tessellator .setColorRGBA_F (red1 , green1 , blue1 , alpha1 );
131- tessellator .addVertex (w , y , 0 );
132- tessellator .addVertex (x , y , 0 );
133- tessellator .setColorRGBA_F (red2 , green2 , blue2 , alpha2 );
134- tessellator .addVertex (x , h , 0 );
135- tessellator .addVertex (w , h , 0 );
136- tessellator .draw ();
137- GL11 .glShadeModel (GL11 .GL_FLAT );
138- GL11 .glDisable (GL11 .GL_BLEND );
139- GL11 .glEnable (GL11 .GL_ALPHA_TEST );
140- GL11 .glEnable (GL11 .GL_TEXTURE_2D );
141- }
142-
143132 private void drawItemTip () {
144133 List <String > list = null ;
145134 if (useNei )
@@ -148,11 +137,11 @@ private void drawItemTip() {
148137 }
149138 catch (final Exception e ) {}
150139 if (list == null )
151- list = entityItem .getEntityItem ().getTooltip (entityPlayer , false );
140+ list = entityItem .getEntityItem ().getTooltip (entityPlayer , Minecraft . getMinecraft (). gameSettings . advancedItemTooltips );
152141 if (list == null )
153142 return ;
154143 // addInfo(list);
155- addModInfo ( list );
144+ list . add ( EnumChatFormatting . BLUE . toString () + EnumChatFormatting . ITALIC . toString () + TooltipSystem . modNameFromStack ( entityItem . getEntityItem ()) + EnumChatFormatting . RESET . toString () );
156145 if (list .size () > 0 ) {
157146 if (entityItem .getEntityItem ().stackSize > 1 )
158147 list .set (0 , entityItem .getEntityItem ().stackSize + " x " + list .get (0 ));
0 commit comments