33import com .mojang .realmsclient .gui .ChatFormatting ;
44import me .earth .earthhack .api .module .Module ;
55import me .earth .earthhack .api .module .util .Category ;
6+ import me .earth .earthhack .api .setting .Complexity ;
67import me .earth .earthhack .api .setting .Setting ;
7- import me .earth .earthhack .api .setting .settings .BooleanSetting ;
8- import me .earth .earthhack .api .setting .settings .ColorSetting ;
9- import me .earth .earthhack .api .setting .settings .EnumSetting ;
8+ import me .earth .earthhack .api .setting .settings .*;
109import me .earth .earthhack .impl .Earthhack ;
1110import me .earth .earthhack .impl .managers .Managers ;
1211import me .earth .earthhack .impl .managers .render .TextRenderer ;
1514import me .earth .earthhack .impl .modules .client .hud .modes .Modules ;
1615import me .earth .earthhack .impl .modules .client .hud .modes .PotionColor ;
1716import me .earth .earthhack .impl .modules .client .hud .modes .Potions ;
18- import me .earth .earthhack .impl .modules .client .hud .util .HUDData ;
1917import me .earth .earthhack .impl .util .client .ModuleUtil ;
2018import me .earth .earthhack .impl .util .math .MathUtil ;
2119import me .earth .earthhack .impl .util .math .rotation .RotationUtil ;
2220import me .earth .earthhack .impl .util .minecraft .DamageUtil ;
2321import me .earth .earthhack .impl .util .network .ServerUtil ;
2422import me .earth .earthhack .impl .util .render .ColorHelper ;
2523import me .earth .earthhack .impl .util .render .ColorUtil ;
24+ import me .earth .earthhack .impl .util .text .ChatUtil ;
2625import me .earth .earthhack .impl .util .text .TextColor ;
2726import net .minecraft .block .material .Material ;
2827import net .minecraft .client .Minecraft ;
28+ import net .minecraft .client .entity .EntityPlayerSP ;
2929import net .minecraft .client .gui .ScaledResolution ;
3030import net .minecraft .client .renderer .GlStateManager ;
3131import net .minecraft .client .renderer .RenderHelper ;
3838import org .lwjgl .opengl .GL11 ;
3939
4040import java .awt .*;
41+ import java .time .DateTimeException ;
42+ import java .time .LocalDateTime ;
43+ import java .time .format .DateTimeFormatter ;
4144import java .util .List ;
4245import java .util .*;
4346import java .util .stream .Collectors ;
@@ -76,12 +79,24 @@ public class HUD extends Module {
7679 register (new BooleanSetting ("CurrentTps" , true ));
7780 protected final Setting <Boolean > animations =
7881 register (new BooleanSetting ("Animations" , true ));
82+ protected final Setting <Boolean > serverBrand =
83+ register (new BooleanSetting ("ServerBrand" , false ));
84+
85+ protected final Setting <Boolean > time =
86+ register (new BooleanSetting ("Time" , false ));
87+ protected final Setting <String > timeFormat =
88+ register (new StringSetting ("TimeFormat" , "hh:mm:ss" ));
89+
90+ protected final Setting <Integer > textOffset =
91+ register (new NumberSetting <>("Offset" , 2 , 0 , 10 ))
92+ .setComplexity (Complexity .Expert );
7993
8094 protected final List <Map .Entry <String , Module >> modules = new ArrayList <>();
8195
8296 protected final Map <Module , ArrayEntry > arrayEntries = new HashMap <>();
8397 protected final Map <Module , ArrayEntry > removeEntries = new HashMap <>();
8498
99+ protected DateTimeFormatter formatter = DateTimeFormatter .ofPattern ("hh:mm:ss" );
85100 protected ScaledResolution resolution = new ScaledResolution (mc );
86101 protected int width ;
87102 protected int height ;
@@ -120,6 +135,16 @@ public HUD() {
120135 potionColorMap .put (MobEffects .LEVITATION , new Color (206 , 255 , 255 ));
121136 potionColorMap .put (MobEffects .LUCK , new Color (51 , 153 , 0 ));
122137 potionColorMap .put (MobEffects .UNLUCK , new Color (192 , 164 , 77 ));
138+ timeFormat .addObserver (e -> {
139+ if (!e .isCancelled ()) {
140+ try {
141+ formatter = DateTimeFormatter .ofPattern (e .getValue ());
142+ } catch (IllegalArgumentException iae ) {
143+ ChatUtil .sendMessageScheduled (TextColor .RED + "Invalid DateTimeFormat: " + TextColor .WHITE + e .getValue ());
144+ formatter = DateTimeFormatter .ofPattern ("hh:mm:ss" );
145+ }
146+ }
147+ });
123148 }
124149
125150 protected void renderLogo () {
@@ -130,6 +155,13 @@ protected void renderLogo() {
130155
131156 protected void renderModules () {
132157 int offset = 0 ;
158+ EntityPlayerSP player ;
159+ if (serverBrand .getValue () && (player = mc .player ) != null ) {
160+ String serverBrand = "ServerBrand " + TextColor .GRAY + player .getServerBrand ();
161+ renderText (serverBrand , width - 2 - RENDERER .getStringWidth (serverBrand ), height - 2 - RENDERER .getStringHeightI () - offset - animationY );
162+ offset += RENDERER .getStringHeightI () + textOffset .getValue ();
163+ }
164+
133165 if (potions .getValue () == Potions .Text ) {
134166 final ArrayList <Potion > sorted = new ArrayList <>();
135167 for (final Potion potion : Potion .REGISTRY ) {
@@ -147,15 +179,17 @@ protected void renderModules() {
147179 GL11 .glColor4f (1.0f , 1.0f , 1.0f , 1.0f );
148180 final int x = width - 2 - RENDERER .getStringWidth (label );
149181 renderPotionText (label , x , height - 2 - RENDERER .getStringHeightI () - offset - animationY , effect .getPotion ());
150- offset += RENDERER .getStringHeightI () + 3 ;
182+ offset += RENDERER .getStringHeightI () + textOffset . getValue () ;
151183 }
152184 }
153185 }
186+
154187 if (speed .getValue ()) {
155188 String text = "Speed " + TextColor .GRAY + MathUtil .round (Managers .SPEED .getSpeed (), 2 ) + " km/h" ;
156189 renderText (text , width - 2 - RENDERER .getStringWidth (text ), height - 2 - RENDERER .getStringHeightI () - offset - animationY );
157- offset += RENDERER .getStringHeightI () + 3 ;
190+ offset += RENDERER .getStringHeightI () + textOffset . getValue () ;
158191 }
192+
159193 if (tps .getValue ()) {
160194 String tps = "TPS " + TextColor .GRAY + MathUtil .round (Managers .TPS .getTps (), 2 );
161195 if (currentTps .getValue ())
@@ -164,13 +198,29 @@ protected void renderModules() {
164198 }
165199
166200 renderText (tps , width - 2 - RENDERER .getStringWidth (tps ), height - 2 - RENDERER .getStringHeightI () - offset - animationY );
167- offset += RENDERER .getStringHeightI () + 3 ;
201+ offset += RENDERER .getStringHeightI () + textOffset . getValue () ;
168202 }
203+
204+ if (time .getValue ()) {
205+ LocalDateTime time = LocalDateTime .now ();
206+ String text ;
207+ try {
208+ text = "Time " + TextColor .GRAY + formatter .format (time );
209+ } catch (DateTimeException e ) {
210+ ModuleUtil .sendMessageWithAquaModule (this , TextColor .RED + "Can not render time: " + e .getMessage (), "time" );
211+ text = "Time " + TextColor .GRAY + TextColor .RED + "Invalid" ;
212+ }
213+
214+ renderText (text , width - 2 - RENDERER .getStringWidth (text ), height - 2 - RENDERER .getStringHeightI () - offset - animationY );
215+ offset += RENDERER .getStringHeightI () + textOffset .getValue ();
216+ }
217+
169218 if (fps .getValue ()) {
170219 String fps = "FPS " + TextColor .GRAY + Minecraft .getDebugFPS ();
171220 renderText (fps , width - 2 - RENDERER .getStringWidth (fps ), height - 2 - RENDERER .getStringHeightI () - offset - animationY );
172- offset += RENDERER .getStringHeightI () + 3 ;
221+ offset += RENDERER .getStringHeightI () + textOffset . getValue () ;
173222 }
223+
174224 if (ping .getValue ()) {
175225 String ping = "Ping " + TextColor .GRAY + ServerUtil .getPing ();
176226 renderText (ping , width - 2 - RENDERER .getStringWidth (ping ), height - 2 - RENDERER .getStringHeightI () - offset - animationY );
@@ -196,6 +246,7 @@ protected void renderModules() {
196246 boolean move = potions .getValue () == Potions .Move && !mc .player .getActivePotionEffects ().isEmpty ();
197247 int j = move ? 2 : 0 ;
198248 int o = move ? 5 : 2 ;
249+ int moduleOffset = Managers .TEXT .getStringHeightI () + textOffset .getValue ();
199250 if (animations .getValue ()) {
200251 for (Map .Entry <String , Module > module : modules ) {
201252 if (isArrayMember (module .getValue ()))
@@ -217,14 +268,14 @@ protected void renderModules() {
217268 LinkedHashMap ::new ));
218269 }
219270 for (ArrayEntry arrayEntry : arrayEntriesSorted .values ()) {
220- arrayEntry .drawArrayEntry (width - 2 , o + j * 10 );
271+ arrayEntry .drawArrayEntry (width - 2 , o + j * moduleOffset );
221272 j ++;
222273 }
223274 getRemoveEntries ().forEach ((key , value ) -> getArrayEntries ().remove (key ));
224275 getRemoveEntries ().clear ();
225276 } else {
226277 for (Map .Entry <String , Module > module : modules ) {
227- renderText (module .getKey (), width - 2 - RENDERER .getStringWidth (module .getKey ()), o + j * 10 );
278+ renderText (module .getKey (), width - 2 - RENDERER .getStringWidth (module .getKey ()), o + j * moduleOffset );
228279 j ++;
229280 }
230281 }
0 commit comments