2424import com .lambda .event .events .TickEvent ;
2525import com .lambda .interaction .PlayerPacketManager ;
2626import com .lambda .interaction .request .rotation .RotationManager ;
27+ import com .lambda .module .modules .player .PortalGui ;
28+ import net .minecraft .client .MinecraftClient ;
29+ import net .minecraft .client .gui .screen .DeathScreen ;
30+ import net .minecraft .client .gui .screen .Screen ;
31+ import net .minecraft .client .gui .screen .ingame .HandledScreen ;
2732import net .minecraft .client .input .Input ;
2833import net .minecraft .client .network .ClientPlayerEntity ;
2934import net .minecraft .entity .MovementType ;
3035import net .minecraft .entity .damage .DamageSource ;
3136import net .minecraft .util .Hand ;
3237import net .minecraft .util .math .Vec3d ;
38+ import org .spongepowered .asm .mixin .Final ;
3339import org .spongepowered .asm .mixin .Mixin ;
3440import org .spongepowered .asm .mixin .Shadow ;
3541import org .spongepowered .asm .mixin .injection .At ;
@@ -51,6 +57,8 @@ public abstract class ClientPlayerEntityMixin extends EntityMixin {
5157 @ Shadow
5258 protected abstract void autoJump (float dx , float dz );
5359
60+ @ Shadow @ Final protected MinecraftClient client ;
61+
5462 /**
5563 * Post movement events and applies the modified player velocity
5664 */
@@ -150,4 +158,22 @@ void onSwingHandPre(Hand hand, CallbackInfo ci) {
150158 public void damage (DamageSource source , float amount , CallbackInfoReturnable <Boolean > cir ) {
151159 if (EventFlow .post (new PlayerEvent .Damage (source , amount )).isCanceled ()) cir .setReturnValue (false );
152160 }
161+
162+ /**
163+ * Prevents the game from closing Guis when the player is in a nether portal
164+ * <pre>{@code
165+ * if (this.client.currentScreen != null && !this.client.currentScreen.shouldPause() && !(this.client.currentScreen instanceof DeathScreen)) {
166+ * if (this.client.currentScreen instanceof HandledScreen) {
167+ * this.closeHandledScreen();
168+ * }
169+ *
170+ * this.client.setScreen((Screen)null);
171+ * }
172+ * }</pre>
173+ */
174+ @ Redirect (method = "updateNausea" , at = @ At (value = "FIELD" , target = "Lnet/minecraft/client/MinecraftClient;currentScreen:Lnet/minecraft/client/gui/screen/Screen;" ))
175+ Screen keepScreensInPortal (MinecraftClient instance ) {
176+ if (PortalGui .INSTANCE .isEnabled ()) return null ;
177+ else return client .currentScreen ;
178+ }
153179}
0 commit comments