Skip to content

Commit 745634a

Browse files
committed
PortalGui
1 parent 8cad0d1 commit 745634a

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

common/src/main/java/com/lambda/mixin/entity/ClientPlayerEntityMixin.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,18 @@
2424
import com.lambda.event.events.TickEvent;
2525
import com.lambda.interaction.PlayerPacketManager;
2626
import 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;
2732
import net.minecraft.client.input.Input;
2833
import net.minecraft.client.network.ClientPlayerEntity;
2934
import net.minecraft.entity.MovementType;
3035
import net.minecraft.entity.damage.DamageSource;
3136
import net.minecraft.util.Hand;
3237
import net.minecraft.util.math.Vec3d;
38+
import org.spongepowered.asm.mixin.Final;
3339
import org.spongepowered.asm.mixin.Mixin;
3440
import org.spongepowered.asm.mixin.Shadow;
3541
import 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
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* Copyright 2025 Lambda
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*/
17+
18+
package com.lambda.module.modules.player
19+
20+
import com.lambda.module.Module
21+
import com.lambda.module.tag.ModuleTag
22+
23+
object PortalGui : Module(
24+
name = "PortalGui",
25+
description = "Allows you to open guis in portals",
26+
defaultTags = setOf(ModuleTag.PLAYER),
27+
)

0 commit comments

Comments
 (0)