1717import net .minecraft .client .gui .GuiCreateWorld ;
1818import net .minecraft .client .gui .GuiMainMenu ;
1919import net .minecraft .client .gui .GuiScreen ;
20+ import net .minecraft .client .resources .I18n ;
2021import net .minecraft .util .text .TextFormatting ;
2122import net .minecraft .world .GameType ;
2223import net .minecraft .world .WorldSettings ;
@@ -48,6 +49,7 @@ public final class ClientProbeTestMod {
4849 private boolean worldSettingsOpened ;
4950 private boolean longEditorRoundTrip ;
5051 private boolean oreSourceFixturesVerified ;
52+ private boolean vanillaOreSourcesVerified ;
5153 private List <GuiButton > worldCreationButtons ;
5254
5355 public ClientProbeTestMod () {
@@ -117,6 +119,21 @@ private void handleClientTick() {
117119 worldSettingsOpened = true ;
118120 validateCaptions ((OreSpawnWorldSettingsScreen ) minecraft .currentScreen );
119121 validateLongEditorRoundTrip (minecraft , minecraft .currentScreen );
122+ String localizedCaption = System .getProperty ("clientprobe.recommendedCaption" , "" );
123+ if (!localizedCaption .isEmpty ()) {
124+ String actual = I18n .format ("button.orespawn.recommended" );
125+ if (!localizedCaption .equals (actual )) {
126+ throw new IllegalStateException ("Unexpected Recommended Defaults caption: " + actual );
127+ }
128+ Properties values = new Properties ();
129+ values .setProperty ("recommended" , actual );
130+ try (FileOutputStream output = new FileOutputStream ("client-locale-pass.properties" )) {
131+ values .store (output , "OreSpawn localized editor check" );
132+ }
133+ minecraft .shutdown ();
134+ nextState (10 );
135+ break ;
136+ }
120137 if (Boolean .getBoolean ("clientprobe.oreSourcesFixtures" )) {
121138 validateOreSourceFixtures (minecraft , minecraft .currentScreen );
122139 oreSourceFixturesVerified = true ;
@@ -202,8 +219,8 @@ private Button nextNavigationButton(OreSpawnWorldSettingsScreen root) {
202219 Button button = (Button ) widget ;
203220 String caption = TextFormatting .getTextWithoutFormattingCodes (button .getMessage ());
204221 if (!attemptedButtons .add (caption )) continue ;
205- String lower = caption . toLowerCase ( java . util . Locale . ROOT );
206- if ( lower . equals ( "done" ) || lower . equals ( "cancel" ) || lower . contains ( "recommended" )) continue ;
222+ if ( I18n . format ( "gui.done" ). equals ( caption ) || I18n . format ( "gui.cancel" ). equals ( caption )
223+ || I18n . format ( "button.orespawn.recommended" ). equals ( caption )) continue ;
207224 return button ;
208225 }
209226 return null ;
@@ -224,7 +241,7 @@ private static void validateCaptions(OreSpawnScreen screen) {
224241 }
225242 }
226243
227- private static void validateOreSourcesRoute (Minecraft minecraft , OreSpawnScreen materials ) {
244+ private void validateOreSourcesRoute (Minecraft minecraft , OreSpawnScreen materials ) {
228245 Button ores = buttonWithCaption (materials ,
229246 net .minecraft .client .resources .I18n .format ("tab.orespawn.ores" ));
230247 if (ores == null ) throw new IllegalStateException ("Missing ORES tab" );
@@ -239,6 +256,10 @@ private static void validateOreSourcesRoute(Minecraft minecraft, OreSpawnScreen
239256 throw new IllegalStateException ("Ore Sources route did not open" );
240257 }
241258 OreSourceListScreen opened = (OreSourceListScreen ) minecraft .currentScreen ;
259+ if (!vanillaOreSourcesVerified && Boolean .getBoolean ("clientprobe.vanillaOreSources" )) {
260+ validateVanillaOreSources (opened );
261+ vanillaOreSourcesVerified = true ;
262+ }
242263 validateEmptyOreSources (minecraft , materials );
243264 Button addGroup = buttonWithCaption (opened , "+" );
244265 if (addGroup == null ) throw new IllegalStateException ("Missing Add Group control" );
@@ -254,6 +275,55 @@ private static void validateOreSourcesRoute(Minecraft minecraft, OreSpawnScreen
254275 }
255276 }
256277
278+ private static void validateVanillaOreSources (OreSourceListScreen screen ) {
279+ WorldGeologyProfile pending = WorldGeologyProfileManager .pendingNewWorldProfile ();
280+ if (pending .manageVanillaOres ()) {
281+ throw new IllegalStateException ("The standalone Show All check must run with vanilla management off" );
282+ }
283+ validateVanillaOreRows (screen );
284+ GeologyEditorSession session = new GeologyEditorSession (pending );
285+ JsonObject before = session .profile ().rootCopy ();
286+ for (GeologyEditorSession .OreSourceGroup group : session .oreSourceGroups ()) {
287+ if (group .hasManagedPlacementSource () || !"keep_separate" .equals (group .mode )) {
288+ throw new IllegalStateException ("Show All should not put OreSpawn in charge of vanilla generation" );
289+ }
290+ }
291+ if (!before .equals (session .profile ().rootCopy ())) {
292+ throw new IllegalStateException ("Listing vanilla ores must not change the profile" );
293+ }
294+ System .out .println ("VANILLA_ORE_SOURCES_PASS management=off rows=8 profile=unchanged" );
295+ }
296+
297+ private static void validateVanillaOreRows (OreSourceListScreen screen ) {
298+ if (firstList (screen ).size () != 0 ) {
299+ throw new IllegalStateException ("Routine vanilla ores should start hidden" );
300+ }
301+ Button showAll = buttonWithCaption (screen , I18n .format ("button.orespawn.show_all" ));
302+ if (showAll == null ) throw new IllegalStateException ("Missing Show All control" );
303+ ((GuiButton ) showAll ).onClick (0 , 0 );
304+ CompactScrollList groups = firstList (screen );
305+ String [] expected = { "Coal" , "Diamond" , "Emerald" , "Gold" , "Iron" , "Lapis" , "Quartz" , "Redstone" };
306+ if (groups .size () != expected .length ) {
307+ throw new IllegalStateException ("Show All should list eight vanilla ores, found " + groups .size ());
308+ }
309+ for (int row = 0 ; row < expected .length ; row ++) {
310+ if (!groups .rowText (row ).startsWith (expected [row ] + " - " )) {
311+ throw new IllegalStateException ("Unexpected vanilla ore row: " + groups .rowText (row ));
312+ }
313+ }
314+ Button hideSingles = buttonWithCaption (screen , I18n .format ("button.orespawn.ore_source.hide_single" ));
315+ if (hideSingles == null ) throw new IllegalStateException ("Missing Hide Singles control" );
316+ ((GuiButton ) hideSingles ).onClick (0 , 0 );
317+ if (firstList (screen ).size () != 0 ) throw new IllegalStateException ("Hide Singles should hide vanilla ores" );
318+ }
319+
320+ private static CompactScrollList firstList (OreSpawnScreen screen ) {
321+ for (GuiButton widget : screen .qualificationButtons ()) {
322+ if (widget instanceof CompactScrollList ) return (CompactScrollList ) widget ;
323+ }
324+ throw new IllegalStateException ("Missing Groups list" );
325+ }
326+
257327 private static void validateEmptyOreSources (Minecraft minecraft , GuiScreen parent ) {
258328 for (int [] size : new int [][] { { 426 , 265 }, { 320 , 240 } }) {
259329 OreSourceListScreen empty = new OreSourceListScreen (parent ,
@@ -440,7 +510,7 @@ private static void pressDone(OreSpawnScreen screen) {
440510 for (GuiButton widget : screen .qualificationButtons ()) {
441511 if (!(widget instanceof Button )) continue ;
442512 String caption = TextFormatting .getTextWithoutFormattingCodes (((Button ) widget ).getMessage ());
443- if (" done". equalsIgnoreCase (caption )) {
513+ if (I18n . format ( "gui. done"). equals (caption )) {
444514 ((GuiButton ) widget ).onClick (0 , 0 );
445515 return ;
446516 }
@@ -462,6 +532,7 @@ private void writeMarker() throws IOException {
462532 values .setProperty ("world_settings_opened" , Boolean .toString (worldSettingsOpened ));
463533 values .setProperty ("long_editor_roundtrip" , Boolean .toString (longEditorRoundTrip ));
464534 values .setProperty ("ore_source_fixtures_verified" , Boolean .toString (oreSourceFixturesVerified ));
535+ values .setProperty ("vanilla_ore_sources_verified" , Boolean .toString (vanillaOreSourcesVerified ));
465536 values .setProperty ("editor_routes" , Integer .toString (editorRoutes .size ()));
466537 values .setProperty ("editor_classes" , editorRoutes .toString ());
467538 values .setProperty ("first_world_rendered" , Boolean .toString (firstWorldFrames >= 8 ));
0 commit comments