1+ package me .voidxwalker .anchiale .mixin ;
2+
3+ import me .voidxwalker .anchiale .Anchiale ;
4+ import net .minecraft .client .gui .screen .GameMenuScreen ;
5+ import net .minecraft .client .gui .screen .Screen ;
6+ import net .minecraft .client .gui .screen .TitleScreen ;
7+ import net .minecraft .client .gui .screen .multiplayer .MultiplayerScreen ;
8+ import net .minecraft .client .gui .widget .ButtonWidget ;
9+ import net .minecraft .client .resource .language .I18n ;
10+ import net .minecraft .client .world .ClientWorld ;
11+ import net .minecraft .realms .RealmsBridge ;
12+ import org .spongepowered .asm .mixin .Mixin ;
13+ import org .spongepowered .asm .mixin .injection .At ;
14+ import org .spongepowered .asm .mixin .injection .Inject ;
15+ import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
16+
17+ @ Mixin (GameMenuScreen .class )
18+ public class GameMenuScreenMixin extends Screen {
19+ @ Inject (method = "init" , at = @ At ("TAIL" ))
20+ private void addMenuQuitWorldButton (CallbackInfo ci ) {
21+ this .buttons .add (new ButtonWidget (1507 , this .width - 200 , this .height - 20 , I18n .translate ("menu.quitWorld" )));
22+ }
23+
24+ @ Inject (method = "buttonClicked" , at = @ At ("HEAD" ), cancellable = true )
25+ private void onMenuQuitWorldClicked (ButtonWidget button , CallbackInfo ci ) {
26+ if (button .id == 1507 ) {
27+ Anchiale .fastReset = true ;
28+ boolean bl = this .client .isIntegratedServerRunning ();
29+ boolean bl2 = this .client .isConnectedToRealms ();
30+ button .active = false ;
31+ this .client .world .disconnect ();
32+ this .client .connect ((ClientWorld )null );
33+ Anchiale .fastReset = false ;
34+ if (bl ) {
35+ this .client .openScreen (new TitleScreen ());
36+ } else if (bl2 ) {
37+ RealmsBridge realmsBridge = new RealmsBridge ();
38+ realmsBridge .switchToRealms (new TitleScreen ());
39+ } else {
40+ this .client .openScreen (new MultiplayerScreen (new TitleScreen ()));
41+ }
42+ ci .cancel ();
43+ }
44+ }
45+ }
0 commit comments