33import me .voidxwalker .anchiale .Anchiale ;
44import net .minecraft .client .gui .screen .GameMenuScreen ;
55import net .minecraft .client .gui .screen .Screen ;
6- import net .minecraft .client .gui .screen .TitleScreen ;
7- import net .minecraft .client .gui .screen .multiplayer .MultiplayerScreen ;
86import net .minecraft .client .gui .widget .ButtonWidget ;
97import net .minecraft .client .resource .language .I18n ;
10- import net .minecraft .client .world .ClientWorld ;
11- import net .minecraft .realms .RealmsBridge ;
128import org .spongepowered .asm .mixin .Mixin ;
139import org .spongepowered .asm .mixin .injection .At ;
1410import org .spongepowered .asm .mixin .injection .Inject ;
1511import org .spongepowered .asm .mixin .injection .callback .CallbackInfo ;
1612
1713@ Mixin (GameMenuScreen .class )
18- public class GameMenuScreenMixin extends Screen {
14+ public abstract class GameMenuScreenMixin extends Screen {
15+
1916 @ 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" )));
17+ private void anchiale_addMenuQuitWorldButton (CallbackInfo ci ) {
18+ if (this .client .isInSingleplayer ()) {
19+ this .buttons .add (new ButtonWidget (1507 , this .width - 106 , this .height - 24 , 102 , 20 , I18n .translate ("menu.quitWorld" )));
20+ }
2221 }
2322
24- @ Inject (method = "buttonClicked" , at = @ At ("HEAD" ), cancellable = true )
25- private void onMenuQuitWorldClicked (ButtonWidget button , CallbackInfo ci ) {
23+ @ Inject (method = "buttonClicked" , at = @ At ("HEAD" ))
24+ private void anchiale_onMenuQuitWorldClicked (ButtonWidget button , CallbackInfo ci ) {
2625 if (button .id == 1507 ) {
2726 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 ();
27+ button .id = 1 ;
4328 }
4429 }
30+
31+ @ Inject (method = "buttonClicked" , at = @ At (value = "INVOKE" , target = "Lnet/minecraft/client/gui/screen/TitleScreen;<init>()V" ))
32+ private void anchiale_fastResetFalse (CallbackInfo ci ) {
33+ Anchiale .fastReset = false ;
34+ }
4535}
0 commit comments