23
23
import dev .ftb .mods .ftbchunks .api .client .icon .MapType ;
24
24
import dev .ftb .mods .ftbchunks .api .client .icon .WaypointIcon ;
25
25
import dev .ftb .mods .ftbchunks .api .client .waypoint .Waypoint ;
26
+ import dev .ftb .mods .ftbchunks .client .gui .AddWaypointOverlay ;
26
27
import dev .ftb .mods .ftbchunks .client .gui .ChunkScreen ;
27
28
import dev .ftb .mods .ftbchunks .client .gui .LargeMapScreen ;
28
29
import dev .ftb .mods .ftbchunks .client .gui .WaypointEditorScreen ;
31
32
import dev .ftb .mods .ftbchunks .client .mapicon .*;
32
33
import dev .ftb .mods .ftbchunks .net .PartialPackets ;
33
34
import dev .ftb .mods .ftbchunks .net .SendGeneralDataPacket .GeneralChunkData ;
35
+ import dev .ftb .mods .ftblibrary .config .ColorConfig ;
34
36
import dev .ftb .mods .ftblibrary .config .StringConfig ;
35
- import dev .ftb .mods .ftblibrary .config .ui .EditConfigFromStringScreen ;
36
37
import dev .ftb .mods .ftblibrary .icon .Color4I ;
37
38
import dev .ftb .mods .ftblibrary .icon .FaceIcon ;
38
39
import dev .ftb .mods .ftblibrary .icon .Icon ;
39
40
import dev .ftb .mods .ftblibrary .math .MathUtils ;
40
41
import dev .ftb .mods .ftblibrary .math .XZ ;
41
42
import dev .ftb .mods .ftblibrary .snbt .SNBTCompoundTag ;
43
+ import dev .ftb .mods .ftblibrary .ui .BaseScreen ;
42
44
import dev .ftb .mods .ftblibrary .ui .CustomClickEvent ;
43
45
import dev .ftb .mods .ftblibrary .ui .GuiHelper ;
46
+ import dev .ftb .mods .ftblibrary .ui .Theme ;
44
47
import dev .ftb .mods .ftblibrary .ui .input .Key ;
45
48
import dev .ftb .mods .ftblibrary .util .StringUtils ;
46
49
import dev .ftb .mods .ftblibrary .util .client .ClientUtils ;
@@ -145,7 +148,7 @@ public enum FTBChunksClient {
145
148
private Matrix4f worldMatrix ;
146
149
private Vec3 cameraPos ;
147
150
148
- public void init () {
151
+ public void init () {
149
152
if (Minecraft .getInstance () == null ) {
150
153
return ;
151
154
}
@@ -362,7 +365,7 @@ public EventResult keyPressed(Minecraft client, int keyCode, int scanCode, int a
362
365
public EventResult keyPressed (Minecraft client , Screen screen , int keyCode , int scanCode , int modifiers ) {
363
366
if (doesKeybindMatch (openMapKey , keyCode , scanCode , modifiers )) {
364
367
LargeMapScreen gui = ClientUtils .getCurrentGuiAs (LargeMapScreen .class );
365
- if (gui != null ) {
368
+ if (gui != null && ! gui . anyModalPanelOpen () ) {
366
369
gui .closeGui (false );
367
370
return EventResult .interruptTrue ();
368
371
}
@@ -377,16 +380,9 @@ private EventResult addQuickWaypoint() {
377
380
if (player == null ) return EventResult .pass ();
378
381
379
382
return MapManager .getInstance ().map (manager -> {
380
- new EditConfigFromStringScreen <>(name , set -> {
381
- if (set && !name .getValue ().isEmpty ()) {
382
- MapDimension mapDimension = manager .getDimension (player .level ().dimension ());
383
- WaypointImpl waypoint = new WaypointImpl (WaypointType .DEFAULT , mapDimension , player .blockPosition ())
384
- .setName (name .getValue ())
385
- .setColor (Color4I .hsb (MathUtils .RAND .nextFloat (), 1F , 1F ).rgba ());
386
- mapDimension .getWaypointManager ().add (waypoint );
387
- }
388
- openGui ();
389
- }).openGuiLater (); // later needed to prevent keypress being passed into gui
383
+ BaseScreen screen = new WaypointAddScreen (name , player );
384
+ screen .openGuiLater ();
385
+ // later needed to prevent keypress being passed into gui
390
386
return EventResult .interruptTrue ();
391
387
}).orElse (EventResult .pass ());
392
388
}
@@ -506,14 +502,14 @@ public void renderHud(GuiGraphics graphics, float tickDelta) {
506
502
currentPlayerChunkZ = cz ;
507
503
}
508
504
509
- if (mc .options . renderDebug || !FTBChunksClientConfig .MINIMAP_ENABLED .get () || FTBChunksClientConfig .MINIMAP_VISIBILITY .get () == 0 || !FTBChunksWorldConfig .shouldShowMinimap (mc .player )) {
505
+ if (mc .getDebugOverlay (). showDebugScreen () || !FTBChunksClientConfig .MINIMAP_ENABLED .get () || FTBChunksClientConfig .MINIMAP_VISIBILITY .get () == 0 || !FTBChunksWorldConfig .shouldShowMinimap (mc .player )) {
510
506
return ;
511
507
}
512
508
513
509
float scale ;
514
510
if (FTBChunksClientConfig .MINIMAP_PROPORTIONAL .get ()) {
515
511
scale = (float ) (4D / guiScale );
516
- scale *= (scaledWidth / 10f ) / (scale * 64D ) * FTBChunksClientConfig .MINIMAP_SCALE .get ();
512
+ scale *= (scaledWidth / 10f ) / (scale * 64f ) * FTBChunksClientConfig .MINIMAP_SCALE .get (). floatValue ();
517
513
} else {
518
514
scale = (float ) (FTBChunksClientConfig .MINIMAP_SCALE .get () * 4D / guiScale );
519
515
}
@@ -1161,4 +1157,50 @@ public List<Component> getChunkSummary() {
1161
1157
public int getMinimapTextureId () {
1162
1158
return minimapTextureId ;
1163
1159
}
1160
+
1161
+ public static Waypoint addWaypoint (Player player , String name , BlockPos position , int color ) {
1162
+ return FTBChunksAPI .clientApi ().getWaypointManager (player .level ().dimension ()).map (mgr -> {
1163
+ Waypoint wp = mgr .addWaypointAt (position , name );
1164
+ wp .setColor (color );
1165
+ return wp ;
1166
+ }).orElse (null );
1167
+ }
1168
+
1169
+ private static class WaypointAddScreen extends BaseScreen {
1170
+ private final StringConfig name ;
1171
+ private final Player player ;
1172
+
1173
+ public WaypointAddScreen (StringConfig name , Player player ) {
1174
+ super ();
1175
+ this .name = name ;
1176
+ this .player = player ;
1177
+ this .setHeight (35 );
1178
+ }
1179
+
1180
+ @ Override
1181
+ public void drawBackground (GuiGraphics graphics , Theme theme , int x , int y , int w , int h ) {
1182
+ }
1183
+
1184
+ @ Override
1185
+ public void addWidgets () {
1186
+ ColorConfig col = new ColorConfig ();
1187
+ col .setValue (Color4I .hsb (MathUtils .RAND .nextFloat (), 1F , 1F ));
1188
+ AddWaypointOverlay overlay = new AddWaypointOverlay (this , name , col , set -> {
1189
+ if (set && !name .getValue ().isEmpty ()) {
1190
+ Waypoint wp = addWaypoint (player , name .getValue (), player .blockPosition (), col .getValue ().rgba ());
1191
+ Minecraft .getInstance ().player .displayClientMessage (
1192
+ Component .translatable ("ftbchunks.waypoint_added" ,
1193
+ Component .literal (wp .getName ()).withStyle (ChatFormatting .YELLOW )
1194
+ ), true );
1195
+ }
1196
+ }) {
1197
+ @ Override
1198
+ public void onClosed () {
1199
+ closeGui ();
1200
+ }
1201
+ };
1202
+ overlay .setWidth (this .width );
1203
+ pushModalPanel (overlay );
1204
+ }
1205
+ }
1164
1206
}
0 commit comments