1616import io .github .gaming32 .bingo .platform .BingoPlatform ;
1717import io .github .gaming32 .bingo .platform .event .ClientEvents ;
1818import io .github .gaming32 .bingo .platform .registrar .KeyMappingBuilder ;
19+ import io .github .gaming32 .bingo .util .BingoUtil ;
1920import io .github .gaming32 .bingo .util .ResourceLocations ;
2021import net .minecraft .ChatFormatting ;
2122import net .minecraft .client .Minecraft ;
@@ -139,7 +140,31 @@ public static void renderBoardOnHud(Minecraft minecraft, GuiGraphics graphics) {
139140 final PositionAndScale pos = getBoardPosition ();
140141 renderBingo (graphics , minecraft .screen instanceof ChatScreen , pos );
141142
142- if (CONFIG .isShowScoreCounter () && clientGame .renderMode () == BingoGameMode .RenderMode .ALL_TEAMS ) {
143+ final Font font = minecraft .font ;
144+ final int scoreX = (int )(pos .x () * pos .scale () + getBoardWidth () * pos .scale () / 2 );
145+ int scoreY ;
146+ if (CONFIG .getBoardCorner ().isOnBottom ) {
147+ scoreY = (int )((pos .y () - BOARD_OFFSET ) * pos .scale () - font .lineHeight );
148+ } else {
149+ scoreY = (int )(pos .y () * pos .scale () + (getBoardHeight () + BOARD_OFFSET ) * pos .scale ());
150+ }
151+ final int shift = CONFIG .getBoardCorner ().isOnBottom ? -12 : 12 ;
152+
153+ if (clientGame .getScheduledEndTime () > 0 ) {
154+ long remainingTime = clientGame .getScheduledEndTime () - System .currentTimeMillis ();
155+ String formatedRemainingTime = " - " + BingoUtil .formatRemainingTime (remainingTime );
156+ int color = 0xffffffff ;
157+ if (remainingTime < 30 * 60 * 1000 )
158+ color = 0xffffaf00 ;
159+ if (remainingTime < 5 * 60 * 1000 )
160+ color = 0xffff0000 ;
161+ final MutableComponent remainingTimeLabel = Component .translatable ("bingo.remaining_time" );
162+ graphics .drawString (font , remainingTimeLabel , scoreX - font .width (remainingTimeLabel ), scoreY , color );
163+ graphics .drawString (font , Component .literal (formatedRemainingTime ), scoreX , scoreY , color );
164+ scoreY += shift ;
165+ }
166+
167+ if (CONFIG .isShowScoreCounter () && clientGame .getRenderMode () == BingoGameMode .RenderMode .ALL_TEAMS ) {
143168 class TeamValue {
144169 final BingoBoard .Teams team ;
145170 int score ;
@@ -149,13 +174,13 @@ class TeamValue {
149174 }
150175 }
151176
152- final TeamValue [] teams = new TeamValue [clientGame .teams ().length ];
177+ final TeamValue [] teams = new TeamValue [clientGame .getTeams ().length ];
153178 for (int i = 0 ; i < teams .length ; i ++) {
154179 teams [i ] = new TeamValue (BingoBoard .Teams .fromOne (i ));
155180 }
156181
157182 int totalScore = 0 ;
158- for (final BingoBoard .Teams state : clientGame .states ()) {
183+ for (final BingoBoard .Teams state : clientGame .getStates ()) {
159184 if (state .any ()) {
160185 totalScore ++;
161186 teams [state .getFirstIndex ()].score ++;
@@ -164,18 +189,9 @@ class TeamValue {
164189
165190 Arrays .sort (teams , Comparator .comparing (v -> -v .score )); // Sort in reverse
166191
167- final Font font = minecraft .font ;
168- final int scoreX = (int )(pos .x () * pos .scale () + getBoardWidth () * pos .scale () / 2 );
169- int scoreY ;
170- if (CONFIG .getBoardCorner ().isOnBottom ) {
171- scoreY = (int )((pos .y () - BOARD_OFFSET ) * pos .scale () - font .lineHeight );
172- } else {
173- scoreY = (int )(pos .y () * pos .scale () + (getBoardHeight () + BOARD_OFFSET ) * pos .scale ());
174- }
175- final int shift = CONFIG .getBoardCorner ().isOnBottom ? -12 : 12 ;
176192 for (final TeamValue teamValue : teams ) {
177193 if (teamValue .score == 0 ) break ;
178- final PlayerTeam team = clientGame .teams ()[teamValue .team .getFirstIndex ()];
194+ final PlayerTeam team = clientGame .getTeams ()[teamValue .team .getFirstIndex ()];
179195 final MutableComponent leftText = getDisplayName (team ).copy ();
180196 final MutableComponent rightText = Component .literal (" - " + teamValue .score );
181197 if (team .getColor () != ChatFormatting .RESET ) {
@@ -188,18 +204,18 @@ class TeamValue {
188204 }
189205
190206 final MutableComponent leftText = Component .translatable ("bingo.unclaimed" );
191- final MutableComponent rightText = Component .literal (" - " + (clientGame .states ().length - totalScore ));
207+ final MutableComponent rightText = Component .literal (" - " + (clientGame .getStates ().length - totalScore ));
192208 graphics .drawString (font , leftText , scoreX - font .width (leftText ), scoreY , 0xffffffff );
193209 graphics .drawString (font , rightText , scoreX , scoreY , 0xffffffff );
194210 }
195211 }
196212
197213 public static int getBoardWidth () {
198- return 14 + 18 * clientGame .size ();
214+ return 14 + 18 * clientGame .getSize ();
199215 }
200216
201217 public static int getBoardHeight () {
202- return 24 + 18 * clientGame .size ();
218+ return 24 + 18 * clientGame .getSize ();
203219 }
204220
205221 public static void renderBingo (GuiGraphics graphics , boolean mouseHover , PositionAndScale pos ) {
@@ -213,13 +229,13 @@ public static void renderBingo(GuiGraphics graphics, boolean mouseHover, Positio
213229 graphics .pose ().scale (pos .scale (), pos .scale (), 1 );
214230 graphics .pose ().translate (pos .x (), pos .y (), 0 );
215231
216- final BingoMousePos mousePos = mouseHover ? BingoMousePos .getPos (minecraft , clientGame .size (), pos ) : null ;
232+ final BingoMousePos mousePos = mouseHover ? BingoMousePos .getPos (minecraft , clientGame .getSize (), pos ) : null ;
217233
218234 graphics .blitSprite (
219235 RenderType ::guiTextured ,
220236 BOARD_TEXTURE , 0 , 0 ,
221- 7 + 18 * clientGame .size () + 7 ,
222- 17 + 18 * clientGame .size () + 7
237+ 7 + 18 * clientGame .getSize () + 7 ,
238+ 17 + 18 * clientGame .getSize () + 7
223239 );
224240 renderBoardTitle (graphics , minecraft .font );
225241
@@ -232,8 +248,8 @@ public static void renderBingo(GuiGraphics graphics, boolean mouseHover, Positio
232248 }
233249
234250 final boolean spectator = minecraft .player != null && minecraft .player .isSpectator ();
235- for (int sx = 0 ; sx < clientGame .size (); sx ++) {
236- for (int sy = 0 ; sy < clientGame .size (); sy ++) {
251+ for (int sx = 0 ; sx < clientGame .getSize (); sx ++) {
252+ for (int sy = 0 ; sy < clientGame .getSize (); sy ++) {
237253 final var goal = clientGame .getGoal (sx , sy );
238254 final int slotX = sx * 18 + 8 ;
239255 final int slotY = sy * 18 + 18 ;
@@ -244,14 +260,14 @@ public static void renderBingo(GuiGraphics graphics, boolean mouseHover, Positio
244260 final BingoBoard .Teams state = clientGame .getState (sx , sy );
245261 boolean isGoalCompleted = state .and (clientTeam );
246262
247- final Integer color = switch (clientGame .renderMode ()) {
263+ final Integer color = switch (clientGame .getRenderMode ()) {
248264 case FANCY -> isGoalCompleted ? Integer .valueOf (0x55ff55 ) : goal .specialType ().incompleteColor ;
249265 case ALL_TEAMS -> {
250266 if (!state .any ()) {
251267 yield null ;
252268 }
253269 final BingoBoard .Teams team = isGoalCompleted ? clientTeam : state ;
254- final Integer maybeColor = clientGame .teams ()[team .getFirstIndex ()].getColor ().getColor ();
270+ final Integer maybeColor = clientGame .getTeams ()[team .getFirstIndex ()].getColor ().getColor ();
255271 yield maybeColor != null ? maybeColor : 0x55ff55 ;
256272 }
257273 };
@@ -338,7 +354,7 @@ public static boolean detectClickOrPress(InputConstants.Key key, PositionAndScal
338354 return false ;
339355 }
340356
341- final BingoMousePos mousePos = BingoMousePos .getPos (Minecraft .getInstance (), clientGame .size (), boardPos );
357+ final BingoMousePos mousePos = BingoMousePos .getPos (Minecraft .getInstance (), clientGame .getSize (), boardPos );
342358 if (!mousePos .hasSlotPos ()) {
343359 return false ;
344360 }
0 commit comments