2020import org .apache .commons .lang3 .Validate ;
2121import org .apache .logging .log4j .LogManager ;
2222import org .apache .logging .log4j .Logger ;
23- import org .lwjgl .opengl .GL11 ;
2423import top .fpsmaster .FPSMaster ;
2524import top .fpsmaster .font .impl .UFontRenderer ;
2625import top .fpsmaster .utils .render .draw .Hover ;
2726import top .fpsmaster .utils .render .draw .Images ;
28- import top .fpsmaster .utils .render .draw .Rects ;
29- import top .fpsmaster .utils .render .gui .UiScale ;
3027
3128import java .awt .image .BufferedImage ;
3229import java .net .UnknownHostException ;
@@ -39,17 +36,13 @@ public class ServerListEntry {
3936 private static final Logger logger = LogManager .getLogger ();
4037 private static final ThreadPoolExecutor field_148302_b = new ScheduledThreadPoolExecutor (5 , (new ThreadFactoryBuilder ()).setNameFormat ("Server Pinger #%d" ).setDaemon (true ).build ());
4138 private static final ResourceLocation UNKNOWN_SERVER = new ResourceLocation ("textures/misc/unknown_server.png" );
42- private static final ResourceLocation SERVER_SELECTION_BUTTONS = new ResourceLocation ("textures/gui/server_selection.png" );
4339 private final Minecraft mc ;
4440 private final ServerData server ;
4541 private final ResourceLocation serverIcon ;
4642 private String field_148299_g ;
4743 private DynamicTexture field_148305_h ;
48-
49-
50- int x , y , width , height ;
51-
52- GuiMultiplayer owner ;
44+ private final GuiMultiplayer owner ;
45+ private long lastClick = 0 ;
5346
5447 protected ServerListEntry (GuiMultiplayer multiplayer , ServerData p_i45048_2_ ) {
5548 this .owner = multiplayer ;
@@ -60,18 +53,13 @@ protected ServerListEntry(GuiMultiplayer multiplayer, ServerData p_i45048_2_) {
6053 }
6154
6255
63- public void drawEntry (int slotIndex , int x , int y , int listWidth , int slotHeight , int mouseX , int mouseY , boolean isSelected ) {
56+ public void drawEntry (int slotIndex , int x , int y , int listWidth , int mouseX , int mouseY ) {
6457 if (!this .server .field_78841_f ) {
6558 this .server .field_78841_f = true ;
6659 this .server .pingToServer = -2L ;
6760 this .server .serverMOTD = "" ;
6861 this .server .populationInfo = "" ;
6962
70- this .x = x ;
71- this .y = y ;
72- this .width = listWidth ;
73- this .height = slotHeight ;
74-
7563 field_148302_b .submit (() -> {
7664 try {
7765 owner .oldServerPinger .ping (ServerListEntry .this .server );
@@ -102,7 +90,6 @@ public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight
10290 int j = text .getStringWidth (s2 );
10391 text .drawString (s2 , x + listWidth - j - 15 - 2 - 5 , y + 1 + 5 , -1 );
10492 int k = 0 ;
105- String s = null ;
10693 int l ;
10794 String s1 ;
10895 if (flag2 ) {
@@ -139,7 +126,7 @@ public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight
139126 }
140127
141128// this.mc.getTextureManager().bindTexture(Gui.icons);
142- Images .drawUV (Gui .icons , x + listWidth - 15 - 5 , y + 5 , k * 10 , 176 + l * 8 , 10 , 8 , 256 , 256 ,-1 ,false );
129+ Images .drawUV (Gui .icons , x + listWidth - 18 , y + 7 , k * 10 , 176 + l * 8 , 10 , 8 , 256 , 256 ,-1 ,false );
143130
144131// Gui.drawModalRectWithCustomSizedTexture(UiScale.scale(x + listWidth - 15 - 5), UiScale.scale(y + 5), (float) (k * 10), (float) (176 + l * 8), 10, 8, 256.0F, 256.0F);
145132 if (this .server .getBase64EncodedIconData () != null && !this .server .getBase64EncodedIconData ().equals (this .field_148299_g )) {
@@ -166,19 +153,16 @@ public void drawEntry(int slotIndex, int x, int y, int listWidth, int slotHeight
166153// this.owner.setHoveringText(s);
167154// }
168155
169- if (Hover .is (x + listWidth - 16 , y + 4 , 16 , 12 , mouseX , mouseY )) {
170- text .drawString (s1 , x + listWidth - 8 , y + 4 , -1 );
156+ if (Hover .is (x + listWidth - 18 , y + 7 , 10 , 8 , mouseX , mouseY )) {
157+ text .drawString (s1 , mouseX + 6 , mouseY - 6 , -1 );
171158 }
172159 }
173160
174161 protected void drawTextureAt (int p_178012_1_ , int p_178012_2_ , ResourceLocation p_178012_3_ ) {
175162 Images .draw (p_178012_3_ , p_178012_1_ , p_178012_2_ , 32 , 32 );
176163 }
177164
178- private boolean func_178013_b () {
179- return true ;
180- }
181-
165+ @ SuppressWarnings ("VulnerableCodeUsages" )
182166 private void prepareServerIcon () {
183167 if (this .server .getBase64EncodedIconData () == null ) {
184168 this .mc .getTextureManager ().deleteTexture (this .serverIcon );
@@ -217,12 +201,16 @@ private void prepareServerIcon() {
217201
218202 }
219203
220- public void clicked (int mouseX , int mouseY , int button ) {
221- }
222-
223204 public ServerData getServerData () {
224205 return this .server ;
225206 }
207+
208+ public void triggerClick () {
209+ if (Minecraft .getSystemTime () - lastClick < 250L ) {
210+ FMLClientHandler .instance ().connectToServer (owner , getServerData ());
211+ }
212+ lastClick = Minecraft .getSystemTime ();
213+ }
226214}
227215
228216
0 commit comments